Skip to content

fix: handle invalid maxOutputTokens value (0 or undefined)#1

Open
Jedeiah wants to merge 1 commit intodevfrom
fix/maxOutputTokens-validation
Open

fix: handle invalid maxOutputTokens value (0 or undefined)#1
Jedeiah wants to merge 1 commit intodevfrom
fix/maxOutputTokens-validation

Conversation

@Jedeiah
Copy link
Copy Markdown
Owner

@Jedeiah Jedeiah commented Apr 11, 2026

Fixes anomalyco#21858
Fixes anomalyco#21522

What

  • Fixes maxOutputTokens returning 0 when model.limit.output is 0, undefined, or negative
  • Returns OUTPUT_TOKEN_MAX (32000) as fallback when model output limit is invalid

Why

  • When plugins pass maxOutputTokens=0 via chat.params hook, OpenCode 1.4.0+ requires >= 1
  • This causes "maxOutputTokens must be >= 1" error for local providers like Ollama

Verification

  • Added 5 unit tests for maxOutputTokens function covering edge cases
  • All tests pass

Fixes anomalyco#21858
Fixes anomalyco#21522

- Returns OUTPUT_TOKEN_MAX when model.limit.output is 0, undefined, or negative
- Adds unit tests for maxOutputTokens function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Ollama integration: Invalid maxOutputTokens error Invalid argument for parameter maxOutputTokens: maxOutputTokens must be >= 1

1 participant