fix(auxiliary): retry on temperature deprecation + memoize rejecting models#12523
Closed
avaclaw1 wants to merge 1 commit into
Closed
fix(auxiliary): retry on temperature deprecation + memoize rejecting models#12523avaclaw1 wants to merge 1 commit into
avaclaw1 wants to merge 1 commit into
Conversation
…g models `_forbids_sampling_params` statically matches "4-7"/"4.7" and misses other families that also 400 with "`temperature` is deprecated for this model." (confirmed for Haiku 4.5; per upstream, Opus 4.6 rejects it too). Add a third layer of defence next to the existing static + safety-net strips: catch the specific 400 from `messages.create`, drop `temperature`, retry once, and cache the model in `_TEMP_UNSUPPORTED_MODELS` so later calls in the same process skip the param pre-emptively. - One-time ~30ms retry per (model, process) pair; zero latency after that. - Self-healing for future restricted families — no code change required. - Older models keep their `temperature` value (no OCR/vision quality regression). Covered by tests for the retry path, memoization, unrelated 400 passthrough, and the no-op case when `temperature` wasn't sent.
This was referenced Apr 24, 2026
Contributor
|
Thanks for the detailed write-up and the reproduction evidence — this is a real bug and the analysis is solid. However, the core fix landed on
The implementation in Closing as implemented. — automated hermes-sweeper review |
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
The
_forbids_sampling_paramscheck inagent/anthropic_adapter.pystatically matches the substrings4-7/4.7, so other restricted families still forwardtemperatureand 400 with`temperature` is deprecated for this model.Confirmed forclaude-haiku-4-5-20251001(observed in production logs); per internal comments,claude-opus-4-6also rejects it.Adds a runtime layer of defence in
_AnthropicCompletionsAdapter.create()that complements the two existing static strips:_forbids_sampling_params(model)guard at the call site (unchanged).build_anthropic_kwargs(unchanged).temperature, retry once, and memoize the model name in a module-level_TEMP_UNSUPPORTED_MODELSset so subsequent calls skip the param pre-emptively.One-time ~30ms retry per (model, process) pair; zero overhead on subsequent calls. No regression on older models that still accept
temperature(they keep their configured values — avoids quality loss on OCR / vision defaults that rely ontemperature=0.1). Self-healing against future restricted families with no code change needed.Why not just expand the static substring list
Tempting, but
4-5matchesclaude-sonnet-4-5(accepts temperature) as well asclaude-haiku-4-5-20251001(rejects it), so substrings alone can't disambiguate. A runtime-learned set avoids that brittleness and stays correct when Anthropic ships a new restricted family tomorrow.Test plan
tests/agent/test_auxiliary_temperature_retry.py— 4 new tests:_TEMP_UNSUPPORTED_MODELSand skipped on the next callBadRequestErrorpropagates unchanged; model not cachedtemperaturein kwargs does not infinite-looptests/agent/suite (1,402 tests) — all pass🤖 Generated with Claude Code