Skip to content

Fix temperature=400 retry for OpenAI-compatible endpoints#81

Open
mhupfauer wants to merge 1 commit into
bugbasesecurity:mainfrom
mhupfauer:fix/openai-compatible-temperature-retry
Open

Fix temperature=400 retry for OpenAI-compatible endpoints#81
mhupfauer wants to merge 1 commit into
bugbasesecurity:mainfrom
mhupfauer:fix/openai-compatible-temperature-retry

Conversation

@mhupfauer

Copy link
Copy Markdown

Problem

Users pointing the tool at an OpenAI-compatible endpoint hit:

Error: 400 Unsupported value: 'temperature' does not support 0.7 with this model. Only the default (1) value is supported.

The existing retry handler only recovered when the OpenAI SDK populated err.code === "unsupported_value" and err.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

  • Extract detection into isTemperatureUnsupportedError, which matches:
    • the structured err.code/err.param fields (real OpenAI),
    • a nested err.error.* shape, and
    • the message text ("does not support" / "only the default" / "unsupported value" + "temperature").
  • Use it in both the non-streaming (invoke_llm) and streaming retry paths, which already fall back to temperature=1.
  • Add unit tests covering each error shape (backend/tests/temperatureRetry.test.ts).

Testing

npm test (node:test via tsx) — new temperatureRetry.test.ts covers structured, message-only, nested, and unrelated errors.

🤖 Generated with Claude Code

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant