-
Notifications
You must be signed in to change notification settings - Fork 541
fix(runtime): send no output-token limit to the OpenAI Codex subscription backend #5738
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
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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
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.
P1: This guard does not protect the actual streamed request.
startStream()at lines 288-295 usesinput.maxOutputTokens ?? selectedModelMaxOutputTokens(...)instead of this guarded method. WhenAiSdkTurnomits the limit foropenai-codex, that fallback recalculates the configured override and passes it tostreamText(line 382). On this head, a Codex adapter with a 4096 override reportsmaxOutputTokensForInput() === undefined, but a directstartStream()probe observesdoStream.maxOutputTokens === 4096. The streamed Codex request therefore still carries the backend-rejected limit. Gate this fallback as well, and test the finaldoStream/wire request rather than only the helper return value.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.
Confirmed, thanks. When its caller passed no limit,
ModelAdapter.startStreamfell back toselectedModelMaxOutputTokens(...)directly. The guard inmaxOutputTokens()/maxOutputTokensForInput()never saw that path, so a Codex turn still sent the configured 4096.Fixed in cad717b. The check now sits at the one place a main-turn limit reaches the wire:
startStreamsends nomaxOutputTokenswhenacceptsOutputTokenLimit()is false, whether the value came from the caller or from the model configuration. Because of that, overflow recovery needs no special case, so I reverted theai-sdk-turn.tschange; this PR no longer touches that file.Tests:
model-adaptercase that goes throughstartStreaminto aMockLanguageModelV4. It asserts what reachesdoStream: onopenai-codexwith a 4096 override, nothing, both with no caller limit and with a caller-supplied 8000. Onopenai, 4096 and 8000 respectively.model-adapter38/38,overflow-reactive-recovery60/60,mid-turn-capacity-backend68/68; runtimetscpasses.On the red CI: I can't read the job log from here (the log download is blocked on my network), so thanks for naming
opencli-chrome.test.js. That test covers the Windows Chrome Web Store launch path, which this PR does not touch. Other unrelated PRs went red around the same time, so I'll see whether it reproduces on this push.On #5723: agreed with your reading. Neither PR alone fixes both call paths.