From 1c2f4aba17d302f725b9d15276d3ed3ee9a366af Mon Sep 17 00:00:00 2001 From: "Balor.LC3" Date: Mon, 6 Apr 2026 20:54:39 -0700 Subject: [PATCH] feat(anthropic): add adaptive thinking mode Extends reasoning_effort to accept 'adaptive' in addition to low/medium/high. When set, uses Anthropic's type: 'adaptive' thinking API instead of a fixed budget, letting the model decide when and how much to think per turn. Also auto-enables interleaved thinking between tool calls on claude-sonnet-4-6 and claude-opus-4-6. Usage: "reasoning_effort": "adaptive" in agents.defaults config --- nanobot/providers/anthropic_provider.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nanobot/providers/anthropic_provider.py b/nanobot/providers/anthropic_provider.py index e389b51ed..8c1d5cc21 100644 --- a/nanobot/providers/anthropic_provider.py +++ b/nanobot/providers/anthropic_provider.py @@ -380,9 +380,15 @@ class AnthropicProvider(LLMProvider): if system: kwargs["system"] = system - if thinking_enabled: + if reasoning_effort == "adaptive": + # Adaptive thinking: model decides when and how much to think + # Supported on claude-sonnet-4-6 and claude-opus-4-6. + # Also auto-enables interleaved thinking between tool calls. + kwargs["thinking"] = {"type": "adaptive"} + kwargs["temperature"] = 1.0 + elif thinking_enabled: budget_map = {"low": 1024, "medium": 4096, "high": max(8192, max_tokens)} - budget = budget_map.get(reasoning_effort.lower(), 4096) # type: ignore[union-attr] + budget = budget_map.get(reasoning_effort.lower(), 4096) kwargs["thinking"] = {"type": "enabled", "budget_tokens": budget} kwargs["max_tokens"] = max(max_tokens, budget + 4096) kwargs["temperature"] = 1.0