Repository navigation
fix(responses): strip max_output_tokens only where the backend rejects it #5753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lidge-jun
merged 4 commits into
lidge-jun:dev
from
vadymhimself:fix/forward-max-output-tokens
Sep 24, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
43e159d
fix(responses): strip max_output_tokens only where the backend reject…
vadymhimself 62a1c9d
docs(reference): note which forward routes keep the caller's output cap
vadymhimself 5bef2b6
Merge remote-tracking branch 'origin/dev' into HEAD
lidge-jun 782b6ed
fix(responses): move the forward output-cap case to a sibling test an…
lidge-jun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| import { describe, expect, test } from "bun:test"; | ||
| import { createResponsesPassthroughAdapter as createResponsesPassthroughAdapterProduction } from "../../src/adapters/openai-responses"; | ||
| import { withTestTranslatorBudget } from "../helpers/translator-budget"; | ||
|
|
||
| const createResponsesPassthroughAdapter = ( | ||
| ...args: Parameters<typeof createResponsesPassthroughAdapterProduction> | ||
| ) => withTestTranslatorBudget(createResponsesPassthroughAdapterProduction(...args)); | ||
|
|
||
| const meta = { headers: new Headers({ authorization: "Bearer token" }) }; | ||
| const rawBody = { | ||
| model: "gpt-5.6-sol", | ||
| input: [{ role: "user", content: [{ type: "input_text", text: "ping" }] }], | ||
| stream: true, | ||
| store: false, | ||
| max_output_tokens: 32000, | ||
| metadata: { user_id: "u-1" }, | ||
| reasoning: { effort: "low" }, | ||
| }; | ||
|
|
||
| describe("OpenAI Responses forward output cap", () => { | ||
| test("noncanonical forward mode keeps the caller's max_output_tokens cap", () => { | ||
| const adapter = createResponsesPassthroughAdapter({ | ||
| adapter: "openai-responses", | ||
| baseUrl: "https://gateway.internal.example/v1", | ||
| authMode: "forward" as const, | ||
| }); | ||
| const request = adapter.buildRequest({ | ||
| modelId: "gpt-5.6-sol", | ||
| context: { messages: [] }, | ||
| stream: true, | ||
| options: {}, | ||
| _rawBody: { ...rawBody }, | ||
| }, meta); | ||
| const body = JSON.parse(request.body) as Record<string, unknown>; | ||
|
|
||
| expect(body.max_output_tokens).toBe(32000); | ||
| expect(body).not.toHaveProperty("metadata"); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
git diff --name-only 1c4bd7ddbeda861dfcd10f4c4aa91a1e73347a4e 43e159de200e5be10962e347bf431735b62f981a -- docs-site rg -n 'max_output_tokens|output cap|output limit' docs-siteRepository: lidge-jun/opencodex
Length of output: 6088
🏁 Script executed:
Repository: lidge-jun/opencodex
Length of output: 16108
Document destination-specific
max_output_tokensforwarding.When
canonicalis false,stripUnsupportedForwardParamsremoves onlymetadata. Whencanonicalis true, it also removesmax_output_tokens. This changes whether the caller's output cap reaches the destination. Document this behavior indocs-site/, such asdocs-site/src/content/docs/reference/proxy-formats.md.🤖 Prompt for AI Agents