feat: self-healing temperature retry (cross-provider safety net)#23
Merged
Conversation
…afety net When a model newly rejects the `temperature` parameter, the provider now records it and retries the request once without temperature, instead of 400ing until the catalog static set is updated by hand. This class of bug hit users twice (gpt-5.5, then Opus 4.8). - new `src/duh/providers/temperature.py`: runtime-learned `_LEARNED_NO_TEMPERATURE` set + `omit_temperature` / `record_no_temperature` / `is_temperature_error` - OpenAI + Anthropic `send()`: temperature decision uses the learned set; on a temperature-related 400 (BadRequest), record the model and retry once without temperature. `stream()` honors the learned set. - Static catalog sets remain the fast path for known models; this only adds self-correction for unknown/new ones. Live-verified: with Opus 4.8 temporarily removed from the static set, send() hit a real Anthropic 400, retried without temperature, succeeded, and recorded the model. 1681 Python tests pass, mypy + ruff clean. Closes the open follow-up; memory bank updated to reflect it. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EkrekgzMAQko92UkjnXhHL
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.
Closes the open follow-up. This class of bug bit users twice — gpt-5.5, then Opus 4.8 — when a model dropped
temperaturebefore our catalog knew about it. Now the providers self-correct.How
src/duh/providers/temperature.py: a process-local learned set +omit_temperature/record_no_temperature/is_temperature_error.send(): temperature is sent unless the model is in the static catalog set or the learned set. On atemperature-related 400 (BadRequestError), the provider records the model and retries once without temperature.stream()honors the learned set.NO_TEMPERATURE_MODELS,ANTHROPIC_NO_TEMPERATURE_MODELS) stay the fast path; this only adds self-correction for unknown/new models.Validation
send()hit a real Anthropic 400, retried without temperature, succeeded, and recorded the model.Docs
Memory bank updated (task doc + activeContext/progress/README/toc); the open follow-up is marked resolved.
🤖 Generated with Claude Code
https://claude.ai/code/session_01EkrekgzMAQko92UkjnXhHL