Repository navigation
Retry with max_completion_tokens when the endpoint rejects max_tokens - #1231
Closed
Schro-code wants to merge 1 commit into
Closed
Schro-code wants to merge 1 commit into
Schro-code wants to merge 1 commit into
Conversation
Newer OpenAI reasoning models (o1, o3, GPT-5 family) renamed `max_tokens` to `max_completion_tokens` and return a 400 with `error.code: "unsupported_parameter"` when the old name is sent. Similarly, these models reject `temperature` values other than their default (1) with `error.code: "unsupported_value"`. This adds a `send_with_compat_retries` method that detects both cases using the structured `error.param` / `error.code` fields (not free-text matching) and retries once with the corrected parameter. The same detection is added to the streaming path's existing retry loop so both `chat_at` and `chat_at_streaming` handle the transition transparently. Each adjustment applies at most once per request — removing the already-applied key from the body prevents an infinite loop if the endpoint keeps rejecting.
Author
|
Closing to reopen with correct base branch (dev) and signed-off commit per CONTRIBUTING.md. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
max_tokenstomax_completion_tokensand return a 400 error witherror.code: "unsupported_parameter"when the old name is sent. They also rejecttemperaturevalues other than 1 witherror.code: "unsupported_value".send_with_compat_retrieshelper that inspects the structurederror.param/error.codefields in the 400 response (not free-text matching) and retries with the corrected parameter. Used by the non-streamingchat_atpath.chat_at_streaming's existing retry loop, so both code paths handle the transition transparently.Test plan
cargo test -p utopia-llm)max_tokensrenametemperaturerejection is handled gracefully (parameter dropped, retry succeeds)🤖 Generated with Claude Code