DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(anthropic): stop sending `temperature` to Claude Sonnet 5 / Opus 4.8
Ruslan807a6fc2bf7f
diff --git a/deeptutor/services/provider_registry.py b/deeptutor/services/provider_registry.pyindex da976a8fc..5f8fc13f7 100644--- a/deeptutor/services/provider_registry.py+++ b/deeptutor/services/provider_registry.py@@ -329,6 +329,16 @@ PROVIDERS: tuple[ProviderSpec, ...] = (backend="anthropic",default_api_base="https://api.anthropic.com/v1",supports_prompt_caching=True,+ # Claude Sonnet 5 and Opus 4.8 reject an explicit `temperature`+ # outright ("`temperature` is deprecated for this model."), where+ # earlier Claude models still accept it. Dropping the parameter+ # (value None) lets the API apply its own default. Like the Kimi+ # case below, the limit is the vendor API's, not the route's, so it+ # must live here to survive binding="openai" through a gateway.+ model_overrides=(+ ("claude-sonnet-5", {"temperature": None}),+ ("claude-opus-4-8", {"temperature": None}),+ ),),ProviderSpec(name="openai",diff --git a/tests/services/llm/test_model_overrides.py b/tests/services/llm/test_model_overrides.pyindex 553469697..8f4d5abc4 100644--- a/tests/services/llm/test_model_overrides.py+++ b/tests/services/llm/test_model_overrides.py@@ -57,11 +57,31 @@ def test_tunable_moonshot_series_keeps_the_callers_temperature(model: str) -> Noassert _payload("moonshot", model)["temperature"] == pytest.approx(0.7)[email protected]("model", ["gpt-4o", "claude-sonnet-5", "deepseek-chat"])+ "model", ["gpt-4o", "claude-haiku-4-5-20251001", "claude-3-5-sonnet", "deepseek-chat"]+)def test_unrelated_models_are_untouched(model: str) -> None:assert _payload("openai", model)["temperature"] == pytest.approx(0.7)[email protected]("model", ["claude-sonnet-5", "claude-opus-4-8"])[email protected]("binding", ["openai", "anthropic", "no-such-provider"])+def test_claude_models_that_deprecated_temperature_never_send_it(+ binding: str, model: str+) -> None:+ """Anthropic answers HTTP 400 ``\`temperature\` is deprecated for this+ model.`` for Sonnet 5 and Opus 4.8. Haiku 4.5 still accepts it, so the+ rule names models, not the vendor prefix.++ Verified against the live API on 2026-09-09. Like the Kimi case, the limit+ belongs to Anthropic's API and not to the route, so it must also fire for+ ``binding="openai"`` — which is how every OpenAI-compatible gateway in+ front of Claude reaches these models.+ """+ assert "temperature" not in _payload(binding, model)+ assert model_overrides_for(model, find_by_name(binding)) == {"temperature": None}++def test_configured_binding_wins_over_the_vendor_fallback() -> None:"""An explicit binding is the user's statement about the route; thevendor lookup is only consulted when it says nothing about this model."""