Open-source personal finance manager. Self-hosted, privacy-first.
fix(agents): stop sending temperature to Anthropic (#997)
Tássio Noronha4dfd1996d728
diff --git a/backend/app/agents/providers/anthropic.py b/backend/app/agents/providers/anthropic.pyindex 98aa0c73..3da3d25e 100644--- a/backend/app/agents/providers/anthropic.py+++ b/backend/app/agents/providers/anthropic.py@@ -98,11 +98,12 @@ class AnthropicProvider(LLMProvider):) -> AsyncIterator[ChatChunk]:url = f"{self.base_url.rstrip('/')}/messages"system, rest = _split_system(messages)+ # `temperature` is intentionally not sent: current Claude models reject it+ # with "temperature is deprecated for this model" (issue #542).payload: dict = {"model": model,"messages": _serialize_messages(rest),"max_tokens": max_tokens or 4096,- "temperature": temperature,"stream": True,}if system:diff --git a/backend/tests/test_agents_providers_streaming.py b/backend/tests/test_agents_providers_streaming.pyindex 80d7bde2..6d02111a 100644--- a/backend/tests/test_agents_providers_streaming.py+++ b/backend/tests/test_agents_providers_streaming.py@@ -341,6 +341,18 @@ async def test_anthropic_includes_system_and_tools_in_payload():assert payload["tools"][0]["name"] == "t"+async def test_anthropic_payload_omits_temperature():+ sse = [f"data: {json.dumps({'type': 'message_delta', 'delta': {'stop_reason': 'end_turn'}, 'usage': {}})}"]+ _FakeAsyncClient.queue_stream.append(_FakeStreamResponse(status_code=200, lines=sse))+ provider = AnthropicProvider(api_key="sk-test")+ msgs = [ChatMessage(role="user", content="hi")]+ async for _ in provider.chat_stream(msgs, model="claude-x", temperature=0.2):+ pass+ _, payload = _FakeAsyncClient.posted[-1]+ assert "temperature" not in payload++# --------------------------------------------------------------------- Anthropic: HTTP errors → typed exceptions@pytest.mark.asyncio