fix(responses): strip max_output_tokens and metadata in forward mode#489
Conversation
The ChatGPT backend (authMode: "forward") enforces a strict parameter
allowlist and rejects unknown top-level fields with HTTP 400
{"detail":"Unsupported parameter: …"}. The stripPreviousResponseId
doc-comment already documents that the backend rejects metadata and
max_output_tokens, but only previous_response_id was actually stripped.
Third-party Responses API clients (GJC, SDK wrappers) send
max_output_tokens per the public OpenAI spec, causing every request
through a forward-mode provider to fail with 400. Codex CLI never sends
these fields (it uses reasoning.effort for output control), so the
strip is a no-op for the primary client.
Add stripUnsupportedForwardParams() inside the existing forward block,
removing both max_output_tokens and metadata before the wire request
is built. Key-auth mode is unaffected.
Verified live: the exact request that returned 400 (max_output_tokens:
32000 + reasoning.effort: low) now returns 200 with response.completed.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe Responses passthrough adapter now strips ChangesForward request sanitization
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Ingwannu
left a comment
There was a problem hiding this comment.
Reviewed exact head 112b8c6. The change is correctly limited to forward-mode Responses requests; persisted configuration reserves that mode for the canonical built-in ChatGPT backend, while key-auth providers retain max_output_tokens and metadata. The sanitizer is top-level only, allocation-free when absent, and covered by forward-strip/no-op/key-preserve regressions. All 29 focused tests and TypeScript typecheck pass locally. Approved pending required CI.
The prior 260726_pr_close_rework map is stale: eight of its nine targets are already CLOSED or MERGED. This unit re-inventories the 14 currently open PRs, applies the MAINTAINERS.md security boundary, and writes diff-level decade docs for the three that a maintainer can land directly (#489, #464, #483). Eight PRs stay held for security review (OAuth, credential routing, UAC, release automation) and three are held for their authors.
Summary
The ChatGPT backend (
authMode: "forward") enforces a strict parameter allowlist and rejects unknown top-level fields with HTTP 400{"detail":"Unsupported parameter: …"}.The
stripPreviousResponseIddoc-comment (line 452) already documents that the backend also rejectsmetadataandmax_output_tokens, but onlyprevious_response_idwas actually stripped. Third-party Responses API clients (e.g. GJC, SDK wrappers) sendmax_output_tokensper the public OpenAI/v1/responsesspec, causing every request through a forward-mode provider to fail with 400.Codex CLI never sends these fields — it controls output length via
reasoning.effort— so the strip is a no-op for the primary client. Claude Code uses theanthropic.tsadapter and is unaffected. Key-auth mode preserves both fields (the platform API supports them).Change: add
stripUnsupportedForwardParams()inside the existingif (forward)block inbuildRequest(), removing bothmax_output_tokensandmetadatabefore the wire request is serialized.Verification
bun test tests/openai-responses-passthrough.test.ts— 29/29 pass (3 new tests)bun run typecheck— cleanmax_output_tokens: 32000,reasoning.effort: "low",store: false) now returns HTTP 200 withresponse.completedthrough a forward-mode providerChecklist
Summary by CodeRabbit
Bug Fixes
max_output_tokensandmetadatarequest parameters before submission.Tests