Skip to content

fix: fallback custom model output limit to OUTPUT_TOKEN_MAX instead of 0 - #22587

Closed
comzip wants to merge 1 commit into
anomalyco:devfrom
comzip:fix/custom-model-output-limit-fallback
Closed

fix: fallback custom model output limit to OUTPUT_TOKEN_MAX instead of 0#22587
comzip wants to merge 1 commit into
anomalyco:devfrom
comzip:fix/custom-model-output-limit-fallback

Conversation

@comzip

@comzip comzip commented Apr 15, 2026

Copy link
Copy Markdown

Issue for this PR

Fixes #22253

Type of change

  • Bug fix

What does this PR do?

Custom provider models without an explicit limit.output get output: 0 as a sentinel value. This 0 propagates to the API call, causing maxOutputTokens must be >= 1 errors. Changed the fallback from 0 to ProviderTransform.OUTPUT_TOKEN_MAX (32000), consistent with built-in model behavior.

How did you verify your code works?

Added a test: custom model without limit.output now gets OUTPUT_TOKEN_MAX instead of 0. Also updated an existing test that was asserting the old (broken) behavior.

Screenshots / recordings

N/A

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on the search results, I found two potentially related PRs that might be addressing similar issues:

  1. PR fix: guard Anthropic thinking budgetTokens for unknown output limits #22581: fix: guard Anthropic thinking budgetTokens for unknown output limits

    • Related because it also deals with handling unknown/unset output limits
  2. PR fix: handle invalid maxOutputTokens value (0 or undefined) #22016: fix: handle invalid maxOutputTokens value (0 or undefined)

    • Related because it addresses the exact issue of handling 0 values for maxOutputTokens that should be treated differently

These PRs appear to be addressing similar token limit validation issues, though they may target different providers or specific cases. You may want to check if they overlap in scope or if they're complementary fixes.

@comzip
comzip force-pushed the fix/custom-model-output-limit-fallback branch 5 times, most recently from 62f9c7e to 26d3f0b Compare April 16, 2026 13:31
@comzip

comzip commented Apr 16, 2026

Copy link
Copy Markdown
Author

The unit (windows) CI failure is in packages/opencode/test/cli/tui/plugin-loader.test.ts and is unrelated to this PR. My changes only touch packages/opencode/src/provider/provider.ts. This appears to be a pre-existing issue on the base branch.

Custom provider models without a limit field were getting limit.output = 0
(sentinel value), causing downstream errors like 'maxOutputTokens must be >= 1'.

Changed the fallback from 0 to ProviderTransform.OUTPUT_TOKEN_MAX (32000),
consistent with built-in model behavior.

Fixes anomalyco#22253
@comzip
comzip force-pushed the fix/custom-model-output-limit-fallback branch from 26d3f0b to 95b26f6 Compare April 23, 2026 09:26
@rekram1-node

Copy link
Copy Markdown
Collaborator

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Custom provider models fail with "maxOutputTokens must be >= 1" when limit is not defined

2 participants