Skip to content

feat: self-healing temperature retry (cross-provider safety net)#23

Merged
msitarzewski merged 1 commit into
mainfrom
feat/temperature-self-heal
Jun 22, 2026
Merged

feat: self-healing temperature retry (cross-provider safety net)#23
msitarzewski merged 1 commit into
mainfrom
feat/temperature-self-heal

Conversation

@msitarzewski

Copy link
Copy Markdown
Owner

Closes the open follow-up. This class of bug bit users twice — gpt-5.5, then Opus 4.8 — when a model dropped temperature before our catalog knew about it. Now the providers self-correct.

How

  • New src/duh/providers/temperature.py: a process-local learned set + omit_temperature / record_no_temperature / is_temperature_error.
  • OpenAI + Anthropic send(): temperature is sent unless the model is in the static catalog set or the learned set. On a temperature-related 400 (BadRequestError), the provider records the model and retries once without temperature. stream() honors the learned set.
  • Static catalog sets (NO_TEMPERATURE_MODELS, ANTHROPIC_NO_TEMPERATURE_MODELS) stay the fast path; this only adds self-correction for unknown/new models.
  • Retry fires only when temperature was actually sent and the error mentions temperature — unrelated 400s propagate normally.

Validation

  • Live: with Opus 4.8 temporarily removed from the static set (simulating a brand-new model), send() hit a real Anthropic 400, retried without temperature, succeeded, and recorded the model.
  • 1681 Python tests pass (4 new), mypy clean (64 files), ruff clean.

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

…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
@msitarzewski msitarzewski merged commit 7cd7a62 into main Jun 22, 2026
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