mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-05-01 23:35:52 +00:00
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
This commit is contained in:
parent
423aab09dd
commit
1c2f4aba17
@ -380,9 +380,15 @@ class AnthropicProvider(LLMProvider):
|
|||||||
if system:
|
if system:
|
||||||
kwargs["system"] = 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_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["thinking"] = {"type": "enabled", "budget_tokens": budget}
|
||||||
kwargs["max_tokens"] = max(max_tokens, budget + 4096)
|
kwargs["max_tokens"] = max(max_tokens, budget + 4096)
|
||||||
kwargs["temperature"] = 1.0
|
kwargs["temperature"] = 1.0
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user