Repository navigation
Conversation
…s ticked The "Include max output tokens" checkbox treated an unset value as checked, but the request builder only sent max_completion_tokens for an explicit true. Profiles that never toggled the box showed it ticked and sent no limit. Add DEFAULT_OPEN_AI_INCLUDE_MAX_TOKENS and read it in both places, so only an explicit false opts out. Skip the field when no limit is configured instead of assigning undefined. Kimi Code has no such control, so it keeps the previous opt-in behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedAuto reviews are limited based on label configuration. 🏷️ Required labels (at least one): 1
Please check the settings in the CodeRabbit UI or the
|
| Layer / File(s) | Summary |
|---|---|
Shared setting default packages/types/src/provider-settings/openai.ts, packages/types/src/provider-settings/index.ts, packages/types/src/provider-settings.ts, webview-ui/src/components/settings/providers/OpenAICompatible.tsx |
The exported default is true. The settings checkbox uses this constant when includeMaxTokens is unset. |
Provider request handling src/api/providers/openai.ts, src/api/providers/kimi-code.ts, src/api/providers/__tests__/openai.spec.ts, src/api/providers/__tests__/kimi-code.spec.ts |
The OpenAI handler applies the default when the option is unset and adds max_completion_tokens when the selected token limit is truthy. Kimi Code passes true only when explicitly enabled. Tests cover unset, false, and true cases. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Medium
Merge Risk: 
Minimal · previous review 53fa6
-
The change aligns unset OpenAI-compatible profiles with the checked checkbox while preserving Kimi Code’s opt-in behavior. No established issue requires blocking merge; normal validation still applies.
Pre-merge checks: 
7 · 
1
-
Failed checks: 1 warning Passed checks: 7 passed-
Full details: Linked Issues check
-
Explanation
Issue
#2230requires the OpenAI Compatible request to match the checked checkbox when a maximum-token value exists.OpenAiHandler.addMaxTokensIfNeeded()now treats unsetincludeMaxTokensasDEFAULT_OPEN_AI_INCLUDE_MAX_TOKENS(true), omits the field only for explicitfalse, and assignsmax_completion_tokensonly whenmodelMaxTokensormodelInfo.maxTokensexists.OpenAICompatible.tsxuses the same default. The updated OpenAI tests cover unset, true, and false values for streaming and non-streaming requests.
Full details: Out of Scope Changes check
-
Explanation
The changes remain within issue
#2230. The shared default export supports consistent UI and request-builder behavior. The Kimi Code adapter explicitly preserves its prior opt-in behavior, and its regression test covers that compatibility case. The added provider tests directly validate the requested behavior.
Full details: Security Boundaries
-
Explanation
No changed path violates the security-boundary conditions. The PR adds a boolean default and changes
OpenAiHandler.addMaxTokensIfNeeded()to send only a numericmax_completion_tokensvalue from validated provider/model settings; it does not expose secrets or PII, execute input, or alter URL, header, authentication, approval, or allowlist handling.KimiCodeHandleruses an exact-truecheck and does not broaden its opt-in behavior.
Full details: Persistence Integrity
-
Explanation
No changed persistence path exists. The diff only adds
DEFAULT_OPEN_AI_INCLUDE_MAX_TOKENS, consumes it in the checkbox andOpenAiHandler.addMaxTokensIfNeeded, and sets an in-memory Kimi Code option. Provider settings still storeincludeMaxTokensas an optional field; no write, migration, rollback, or persistence operation changed. Both changed consumers read the shared default, so no persisted default is left unpropagated.
Full details: Lifecycle Resource Cleanup
-
Explanation
No changed lifecycle path exists. The PR changes only the max-token default, request-field assignment, Kimi option mapping, and checkbox fallback. The OpenAI call sites still use the existing request flow and abort signal. The existing UI debounce timer and message subscription are unchanged, including their existing cleanup behavior. No listener, watcher, timer, task, provider, or other resource is newly allocated or duplicated.
-
Full details: Regression Evidence
-
Explanation
The OpenAI request-builder change has focused coverage for unset, true, and false values in streaming and non-streaming requests. However, the changed Kimi Code adapter at
src/api/providers/kimi-code.ts:46-49is covered only bysrc/api/providers/__tests__/kimi-code.spec.ts:49-63, which reads the protectedoptionsfield. This mirrors the assignment and does not verify the concrete request behavior: unset and false must omitmax_completion_tokens, while true must include it. The UI expression keeps the existing visible behavior, so no snapshot is required.Resolution
Add a Kimi Code request-level test using a mocked
client.chat.completions.createcall. ExerciseincludeMaxTokensas unset, false, and true with a model max-token value, then assert that the generated request omitsmax_completion_tokensfor unset/false and includes it for true. Keep or replace the internal-options assertion with this behavioral test.
-
Finishing Touches
-
🧪 Generate unit tests (beta)
-
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Review statusThanks for contributing. This comment tracks the review sequence and the next action. Current step: Address maintainer or CODEOWNER feedback, push an update, then re-request review from the blocking maintainer. Review-state labels are managed by this workflow; do not edit them manually. |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…-include-max-tokens-default Keep the shared DEFAULT_OPEN_AI_INCLUDE_MAX_TOKENS default and adopt the non-optional apiConfiguration access from main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-include-max-tokens-default Keep the provider-settings move from main and place DEFAULT_OPEN_AI_INCLUDE_MAX_TOKENS next to the strict tool schema default in packages/types/src/providers/openai.ts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Related GitHub Issue
Closes: #2230
Description
The "Include max output tokens" checkbox and the request builder use different defaults. The UI reads an unset
includeMaxTokensas checked. The request builder sendsmax_completion_tokensonly for an explicittrue. Thus a profile that does not store the value shows a ticked box and sends no limit.This PR makes the two agree:
DEFAULT_OPEN_AI_INCLUDE_MAX_TOKENS = trueinpackages/types, next toDEFAULT_OPEN_AI_STRICT_TOOL_SCHEMAS.OpenAiHandler.addMaxTokensIfNeeded()readsincludeMaxTokens ?? DEFAULT_OPEN_AI_INCLUDE_MAX_TOKENS. Only an explicitfalseopts out.OpenAiHandler.addMaxTokensIfNeeded()adds the field only when a limit exists (modelMaxTokensorinfo.maxTokens). It does not assignundefined.OpenAICompatible.tsxuses the same constant for the checkbox.KimiCodeHandlerextendsOpenAiHandlerand has no checkbox. It now passesincludeMaxTokens: options.includeMaxTokens === true. This keeps its previous behavior.Reviewers, check these points:
max_completion_tokens. This occurs only when a max output token value is set. Profiles without a value do not change.true, MiMo setsfalse, and Moonshot overridesaddMaxTokensIfNeeded(). These providers do not change.Test Procedure
pnpm --dir src exec vitest run api/providers/__tests__/openai.spec.ts api/providers/__tests__/kimi-code.spec.ts api/providers/__tests__/deepseek.spec.ts api/providers/__tests__/moonshot.spec.ts api/providers/__tests__/mimo.spec.ts: 301 passed, 1 skipped.pnpm --dir webview-ui exec vitest run src/components/settings/providers/__tests__/OpenAICompatible.spec.tsx: 22 passed. The existing test checks that the box shows checked when the value is unset.pnpm --dir src run check-typesandtsc --noEmitinwebview-ui: pass.eslint --prune-suppressions --max-warnings=0on the changedsrcfiles: pass. No suppression count changed.New tests:
openai.spec.ts: anit.eachtest for unset,true, andfalse. It checks streaming and non-streaming requests. It replaces the old test that expected no limit for an unset value.kimi-code.spec.ts: anit.eachtest that checks Kimi Code stays opt-in.Pre-Submission Checklist
Visual Snapshots
Not applicable. The UI does not change visually.
Documentation Updates
Additional Notes
A ticked box still sends no limit when no max output token value exists. This PR does not change that case. A UI hint can be a separate change.
🤖 Generated with Claude Code