fix: preserve max_output_tokens in transformed requests#89
Conversation
|
Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits. |
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
fix: preserve max_output_tokens in transformed requests
fix: preserve max_output_tokens in transformed requests
Summary
max_output_tokenswhen transforming Responses requestsmax_completion_tokens, which is still unsupported in this bridge pathWhy
Some newer Responses callers rely on
max_output_tokensfor output budgeting. The transformer was unconditionally clearing it alongsidemax_completion_tokens, which silently dropped an explicit user/runtime setting.Changes
body.max_output_tokens = undefinedreset inlib/request/request-transformer.tstest/request-transformer.test.tsmax_output_tokenssurvives when providedmax_completion_tokensremoval behavior coveredmax_output_tokensis preserved from the in-memory request body only, with no filesystem or token-handling impact at this pipeline stageSafety notes
test/request-transformer.test.tscovers both preserve-when-set and unset-when-omitted behaviorValidation
npm run typechecknpm testnote: greptile review for oc-chatgpt-multi-auth. cite files like
lib/foo.ts:123. confirm regression tests + windows concurrency/token redaction coverage.Greptile Summary
this pr correctly preserves caller-supplied
max_output_tokensthrough the responses-api transform path by removing one unconditional= undefinedassignment, while keeping themax_completion_tokensremoval that is still required. regression coverage is solid: two focused unit tests (preserve-when-set, unset-when-omitted) plus a fast-check property test across three model families and arbitrary positive token budgets.lib/request/request-transformer.ts): removesbody.max_output_tokens = undefined; adds inline comment addressing windows filesystem safety (no file i/o), token redaction (numeric field, not a credential), and regression test pointer. fulfills the concurrency/token-safety policy.test/request-transformer.test.ts): old "remove unsupported parameters" test correctly split into two: one asserting the value survives, one asserting it staysundefinedwhen never set. bothmax_completion_tokensremoval assertions retained.test/property/transformer.property.test.ts): newtransformRequestBody property testsdescribe block exercisesmax_output_tokensacross 3 model families × 1–1 000 000 token range; also cleans up mixed tab/space indentation in existing property tests.max_output_tokens: 0is not covered by the property range (likely intentional, but worth documenting).Confidence Score: 5/5
Important Files Changed
body.max_output_tokens = undefinedreset; keepsmax_completion_tokensremoval; adds inline safety comment fulfilling windows/token-redaction policy. one-line behavioral change, no i/o or concurrency risk introduced.transformRequestBodyproperty test over 3 model families and arbitrary positive token budgets; also fixes mixed-indent whitespace in existing property tests.max_output_tokens: 0not covered (see comment).Sequence Diagram
sequenceDiagram participant Caller as Responses Caller participant Transformer as transformRequestBody participant API as ChatGPT Codex API Caller->>Transformer: RequestBody { max_output_tokens: N, max_completion_tokens: M } Note over Transformer: resolveInclude(modelConfig, body) Note over Transformer: body.max_completion_tokens = undefined (removed — unsupported) Note over Transformer: max_output_tokens preserved (no-op) Transformer->>API: RequestBody { max_output_tokens: N } API-->>Caller: response (output budget respected)Comments Outside Diff (1)
test/property/transformer.property.test.ts, line 220-236 (link)gpt-5.4-prodropped from "none → low" upgrade testthe original test ("codex/pro models upgrade none to low") included
"gpt-5.4-pro"becauseisGpt54Prois explicitly excluded fromsupportsNoneinrequest-transformer.ts(line 544-548), so the!supportsNone && effort === "none"guard at line 595 upgrades it to"low". that production behaviour is still present but the PR silently removes the only property-based regression coverage for it.Prompt To Fix With AI
Prompt To Fix All With AI
Last reviewed commit: "Merge origin/main in..."
Context used: