fix(ai-import): adapt to models that reject an explicit temperature#4
Open
silasg wants to merge 1 commit into
Open
fix(ai-import): adapt to models that reject an explicit temperature#4silasg wants to merge 1 commit into
silasg wants to merge 1 commit into
Conversation
OpenAI GPT-5.x / reasoning models reject a non-default `temperature` with a 400, which broke AI bean import for those models (graphefruit#1151). Instead of hard-coding a model-name list, send `temperature` best-effort: if a request is rejected specifically because of temperature, drop it, retry once, and remember the provider+model so later requests skip it. This keeps the deterministic low temperature on every model that honors it (Anthropic, Gemini, Mistral, gpt-4o, ...) and self-heals for current and future models that do not. Callers that already know a model's capabilities (e.g. from OpenRouter's supported_parameters) can set `supportsTemperature: false` to skip even the first failed attempt. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DKKv2cbKhcgE2cTbkhvzjd
This was referenced Jul 17, 2026
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
AI Bean Import fails for OpenAI GPT‑5.x / reasoning models (e.g.
gpt-5.6-terra) — they reject a non-defaulttemperaturewith400 Unsupported value: 'temperature'. See graphefruit#1151. The request body hard-codedtemperature: 0.1for every model.Approach
Rather than maintain a model-name allowlist (which would break again on the next new model), send
temperaturebest-effort and adapt:temperature: 0.1as before.400whose body mentions temperature), drop the parameter, retry once, and remember the provider+model so later requests skip it.This keeps the deterministic low temperature on every model that honors it (Anthropic, Gemini, Mistral,
gpt-4o, …) and self-heals for current and future models that don't. Callers that already know a model's capabilities can setsupportsTemperature: falseto skip even the first failed attempt (wired up in a follow-up PR).Changes
temperatureis now an optional, per-protocol build option instead of a hard-coded literal.sendCloudLLMPromptgains the send → drop/retry-once → remember flow, plus a session cache keyed byprovider::baseUrl::model.supportsTemperature?config flag andresetTemperatureSupportCache()export.Testing
Added 7 specs covering: default temperature still sent, retry-without-temperature on rejection, remembering it, no retry on unrelated 400s,
supportsTemperature:falseshort-circuit, keeping the value where accepted, and a failing retry surfacing its error.🤖 Generated with Claude Code
Generated by Claude Code