fix(mcp): omit temperature for Anthropic/Gemini/Groq when unset (#1103)#1570
fix(mcp): omit temperature for Anthropic/Gemini/Groq when unset (#1103)#1570danielchalef wants to merge 1 commit into
Conversation
The MCP temperature defaults to None. Unlike the OpenAI client (which omits temperature for reasoning models), the Anthropic/Gemini/Groq clients pass config.temperature to their provider APIs verbatim, so a None is sent as `temperature: null` and rejected (the Anthropic 400 in #1103). Build the core LLMConfig via a helper that omits temperature (and base_url) when unset, so core's LLMConfig default (1.0) applies; an explicit value is still preserved. Reimplements #1464 (which was CI-red and behind) directly on main, with unit tests covering all three providers. Fixes #1103 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Claude finished @danielchalef's task in 2m 9s —— View job PR Review: omit temperature for Anthropic/Gemini/Groq when unsetI read the diff and cross-checked the claims against the pinned
Tests are well-structured (parametrized over all three providers + explicit-value preservation). Nice. FindingsThe OpenAI branch builds its # graphiti_core/llm_client/openai_generic_client.py:158
temperature=self.temperature, # unconditional, same as anthropic/gemini/groqSo a user running This is arguably out of scope for "fix #1103", but the PR title frames it as the general "non-OpenAI clients pass temperature verbatim" problem, and the generic client is exactly that. Worth either fixing here (route the generic path through 💡 Suggestion — 💡 Suggestion — 💡 Suggestion — test assertion SummaryThe core fix is correct and verified. No blocking issues. The one thing I'd consider before merge is the OpenAIGenericClient gap — it's the same root cause and the PR's framing implies a general fix. Everything else is cosmetic. |
Summary
The MCP
temperatureconfig defaults toNone. The OpenAI client omits temperature for reasoning models, but the Anthropic / Gemini / Groq clients passconfig.temperatureto their provider APIs verbatim — so aNoneis serialized astemperature: nulland rejected (the Anthropic 400 in #1103).This builds the core
LLMConfigvia a small_build_graphiti_llm_confighelper that omitstemperature(andbase_url) when unset, so core'sLLMConfigdefault (1.0) applies. An explicitly-set temperature is preserved.Verified against the pinned
graphiti-core:LLMConfig().temperature==1.0AnthropicClient(anthropic_client.py:291),GroqClient(:75),GeminiClient(:294) all passtemperature=self.temperatureunconditionally.Provenance
Reimplements #1464 (rafaelreis-r/Yifan… community fix — credit to the original author) directly on
main; the original was CI-red and behind. Same approach + the same test intent, extended to a parametrized suite over all three providers.Tests
Added to
mcp_server/tests/test_factories.py(TestNonOpenAITemperatureDefault):None→ core default1.0for anthropic/gemini/groq, and an explicit value is preserved. 28/28 factory tests pass locally, ruff clean.Fixes #1103
🤖 Generated with Claude Code