Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
fix: skip setting max_reasoning_tokens for Opus 4.6/Sonnet 4.6 adaptive thinking models (#9795)
jnjpngbe364efec3da
diff --git a/letta/schemas/llm_config.py b/letta/schemas/llm_config.pyindex 8d9148139..6b387acca 100644--- a/letta/schemas/llm_config.py+++ b/letta/schemas/llm_config.py@@ -563,7 +563,9 @@ class LLMConfig(BaseModel):if cls.is_anthropic_reasoning_model(config) or is_google_reasoner_with_configurable_thinking:config.enable_reasoner = bool(reasoning)config.put_inner_thoughts_in_kwargs = False- if config.enable_reasoner and config.max_reasoning_tokens == 0:+ # Opus 4.6 / Sonnet 4.6 use adaptive thinking (no budget_tokens), so max_reasoning_tokens is unused+ is_adaptive_thinking_model = config.model.startswith("claude-opus-4-6") or config.model.startswith("claude-sonnet-4-6")+ if config.enable_reasoner and config.max_reasoning_tokens == 0 and not is_adaptive_thinking_model:config.max_reasoning_tokens = 1024# Set default effort level for Claude Opus 4.5 and Opus 4.6if (@@ -636,7 +638,9 @@ class LLMConfig(BaseModel):config.enable_reasoner = Trueif cls.is_anthropic_reasoning_model(config):config.put_inner_thoughts_in_kwargs = False- if config.max_reasoning_tokens == 0:+ # Opus 4.6 / Sonnet 4.6 use adaptive thinking (no budget_tokens), so max_reasoning_tokens is unused+ is_adaptive_thinking_model = config.model.startswith("claude-opus-4-6") or config.model.startswith("claude-sonnet-4-6")+ if config.max_reasoning_tokens == 0 and not is_adaptive_thinking_model:config.max_reasoning_tokens = 1024# Set default effort level for Claude Opus 4.5 and Opus 4.6if (diff --git a/tests/test_providers.py b/tests/test_providers.pyindex a7ab5830a..66f8e5b5a 100644--- a/tests/test_providers.py+++ b/tests/test_providers.py@@ -411,6 +411,11 @@ async def test_provider_llm_models_consistency():("anthropic/claude-3-7-sonnet", AgentType.memgpt_v2_agent, False, False, False, 0, None),("anthropic/claude-sonnet-4", AgentType.memgpt_v2_agent, True, True, False, 1024, None),("anthropic/claude-sonnet-4", AgentType.memgpt_v2_agent, False, False, False, 0, None),+ # Opus 4.6 / Sonnet 4.6 use adaptive thinking - max_reasoning_tokens should stay 0+ ("anthropic/claude-opus-4-6", AgentType.memgpt_v2_agent, True, True, False, 0, None),+ ("anthropic/claude-opus-4-6", AgentType.memgpt_v2_agent, False, False, False, 0, None),+ ("anthropic/claude-sonnet-4-6", AgentType.memgpt_v2_agent, True, True, False, 0, None),+ ("anthropic/claude-sonnet-4-6", AgentType.memgpt_v2_agent, False, False, False, 0, None),("google_vertex/gemini-2.0-flash", AgentType.memgpt_v2_agent, True, True, True, 0, None),("google_vertex/gemini-2.0-flash", AgentType.memgpt_v2_agent, False, False, False, 0, None),("google_vertex/gemini-2.5-flash", AgentType.memgpt_v2_agent, True, True, True, 1024, None),@@ -428,6 +433,11 @@ async def test_provider_llm_models_consistency():("anthropic/claude-3-7-sonnet", AgentType.letta_v1_agent, False, False, False, 0, None),("anthropic/claude-sonnet-4", AgentType.letta_v1_agent, True, True, False, 1024, None),("anthropic/claude-sonnet-4", AgentType.letta_v1_agent, False, False, False, 0, None),+ # Opus 4.6 / Sonnet 4.6 use adaptive thinking - max_reasoning_tokens should stay 0+ ("anthropic/claude-opus-4-6", AgentType.letta_v1_agent, True, True, False, 0, None),+ ("anthropic/claude-opus-4-6", AgentType.letta_v1_agent, False, False, False, 0, None),+ ("anthropic/claude-sonnet-4-6", AgentType.letta_v1_agent, True, True, False, 0, None),+ ("anthropic/claude-sonnet-4-6", AgentType.letta_v1_agent, False, False, False, 0, None),("google_vertex/gemini-2.0-flash", AgentType.letta_v1_agent, True, False, False, 0, None),("google_vertex/gemini-2.0-flash", AgentType.letta_v1_agent, False, False, False, 0, None),("google_vertex/gemini-2.5-flash", AgentType.letta_v1_agent, True, True, False, 1024, None),