Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Oct 3, 2025

This PR standardizes GPT-5 output token limits with all other models:\n\n- Remove GPT-5 exception in getModelMaxOutputTokens() so max output = min(model.maxTokens, ceil(0.2 * contextWindow)).\n- Update tests accordingly: src/shared/tests/api.spec.ts, src/shared/tests/api.spec.ts.\n- Verified locally: all tests passing (298 files, 3906 tests).\n\nExample: 400k context → 80k max output tokens.\n\nRationale: Aligns GPT-5 behavior (including OpenRouter) with other models and avoids oversized completions when providers report very high max_completion_tokens.


Important

Standardizes GPT-5 output token limits by applying a 20% cap, aligning with other models, and updates tests accordingly.

  • Behavior:
    • Remove GPT-5 exception in getModelMaxOutputTokens() in api.ts to apply 20% cap on output tokens, aligning with other models.
    • Example: For a 400k context window, max output tokens are capped at 80k.
  • Tests:
    • Update tests in api.spec.ts to reflect the new 20% cap behavior for GPT-5 models.
    • Tests verify that GPT-5 models are capped to 20% of context window or model.maxTokens, whichever is smaller.
  • Rationale:
    • Aligns GPT-5 behavior with other models and prevents oversized completions when providers report high max tokens.

This description was created by Ellipsis for 8acee59. You can customize this summary. It will automatically update as commits are pushed.

@daniel-lxs daniel-lxs requested review from cte, jr and mrubens as code owners October 3, 2025 16:27
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Oct 3, 2025
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Oct 3, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Oct 3, 2025
@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Oct 3, 2025
@mrubens mrubens merged commit 97f9686 into main Oct 3, 2025
23 checks passed
@mrubens mrubens deleted the feat/limit-gpt5-max-output-20pct branch October 3, 2025 16:41
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Oct 3, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Oct 3, 2025
Copy link
Contributor

@roomote roomote bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found some issues that need attention. See inline comments for details.

}

// Test various GPT-5 model IDs
const gpt5ModelIds = ["gpt-5", "gpt-5-turbo", "GPT-5", "openai/gpt-5-preview", "gpt-5-32k", "GPT-5-TURBO"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P3] Missing OpenRouter coverage for GPT-5 clamping. The PR mentions alignment "including OpenRouter", but this test only exercises format: 'openai'. Add a parallel assertion using format: 'openrouter' and settings.apiProvider: 'openrouter' with a GPT-5 modelId (e.g., 'openai/gpt-5-preview') to ensure the 20% cap applies via the OpenRouter path as well.

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

Labels

enhancement New feature or request Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. lgtm This PR has been approved by a maintainer size:M This PR changes 30-99 lines, ignoring generated files.