Fix temperature=400 retry for OpenAI-compatible endpoints#81
Open
mhupfauer wants to merge 1 commit into
Open
Conversation
The temperature-unsupported retry handler only matched when the OpenAI
SDK populated `err.code === "unsupported_value"` and `err.param ===
"temperature"`. Many OpenAI-*compatible* endpoints return the error as a
bare message string ("Unsupported value: 'temperature' does not support
0.7 with this model. Only the default (1) value is supported.") without
those structured fields, so the retry never triggered and the request
failed outright.
Extract detection into `isTemperatureUnsupportedError`, which matches the
structured fields, a nested `err.error.*` shape, or the message text, and
use it in both the non-streaming and streaming retry paths so they fall
back to temperature=1. Add unit tests covering each error shape.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Problem
Users pointing the tool at an OpenAI-compatible endpoint hit:
The existing retry handler only recovered when the OpenAI SDK populated
err.code === "unsupported_value"anderr.param === "temperature". Many OpenAI-compatible servers return the error as a bare message string without those structured fields, so the retry never fired and the request failed outright.Fix
isTemperatureUnsupportedError, which matches:err.code/err.paramfields (real OpenAI),err.error.*shape, and"does not support"/"only the default"/"unsupported value"+"temperature").invoke_llm) and streaming retry paths, which already fall back totemperature=1.backend/tests/temperatureRetry.test.ts).Testing
npm test(node:test via tsx) — newtemperatureRetry.test.tscovers structured, message-only, nested, and unrelated errors.🤖 Generated with Claude Code