CONCEPT Reasoning about which tool, and about the result
Extended thinking pays off most in agentic loops. Before a tool call, Claude reasons about which tool to use and with what arguments; after a result comes back, it reasons about what the result means and what to do next. Pairing thinking with tool use turns a blind "call tool → get result → call tool" loop into a reflective one where each step is deliberated.
CONCEPT Interleaved thinking
Interleaved thinking lets Claude emit a fresh thinking block between
tool calls — reasoning after each result before deciding the next action. On current models this is
automatic with adaptive thinking (no beta header). Without it, the model reasons once up front,
then chains tool calls with no reflection in between.
| Without interleaving | With interleaved thinking | |
|---|---|---|
| Turn shape | [think] → tool → result → tool → result → text | [think] → tool → result → [think] → tool → result → [think] → text |
| Reflection | Only before the first call | After every result |
| Best for | Simple, known tool sequences | Multi-step tasks where each result changes the plan |
thinking blocks (with signature) back unmodified alongside the
tool_use block and the tool_result, or reasoning continuity breaks; (2)
tool_choice must be auto or none — forcing a specific tool or
any is not supported with extended thinking.DIAGRAM The reflective tool loop
pick next step"] T2 --> D{"Done?"} D -->|"no"| C1 D -->|"yes"| ANS["🟢 text answer"] R1 -.->|"replay: thinking + tool_use
+ result, unmodified"| KEEP["🟠 preserve signatures"] classDef ok fill:#d4edda,stroke:#28a745,color:#155724; classDef mid fill:#cfe2ff,stroke:#0d6efd,color:#084298; classDef gate fill:#ffe8cc,stroke:#ff9f40,color:#9a4a0a; class ANS ok; class T1 mid; class T2 mid; class KEEP gate;
CODE Preserve thinking blocks across the tool round-trip
When you send the tool result back, the assistant turn must include the original thinking block
and the tool_use block — verbatim — so the model's reasoning carries forward.
# 1) First call — Claude thinks, then requests a tool. resp = client.messages.create( model="claude-opus-4-8", max_tokens=16000, thinking={"type": "adaptive"}, # interleaved thinking is automatic tools=[weather_tool], # tool_choice stays "auto" (default) messages=[{"role": "user", "content": "What's the weather in Paris?"}], ) thinking_block = next(b for b in resp.content if b.type == "thinking") tool_use = next(b for b in resp.content if b.type == "tool_use") # 2) Send result back — MUST replay the thinking block unmodified. follow = client.messages.create( model="claude-opus-4-8", max_tokens=16000, thinking={"type": "adaptive"}, tools=[weather_tool], messages=[ {"role": "user", "content": "What's the weather in Paris?"}, {"role": "assistant", "content": [thinking_block, tool_use]}, # verbatim! {"role": "user", "content": [{ "type": "tool_result", "tool_use_id": tool_use.id, "content": "18°C, clear", }]}, ], )
TRADE-OFFS Reflective loop vs. plain tool chaining
✅ Thinking + tools (interleaved)
- Reasons about tool choice and about each result
- Recovers from surprising / empty results
- Fewer wasted or redundant tool calls on hard tasks
⚠️ Cost & rules
- Thinking tokens between every call → more cost/latency
- Must replay thinking blocks + signatures unmodified
tool_choicelimited toauto/none
EXAM TRAPS
thinking block and its signature unmodified in the assistant
turn alongside the tool_use.tool_choice must be
auto or none with extended thinking; {type:"tool"} or any
isn't supported.interleaved-thinking beta header is only for
legacy models.thinking block after
every result multiplies token cost and latency — worth it for hard multi-step tasks, wasteful for a
fixed two-call sequence.PRACTICE
Q1 · What must the assistant turn contain when you send a tool result back with thinking on?
The original thinking block (with its signature) and the
tool_use block, both unmodified, followed by the tool_result in the next user
turn. Dropping the thinking block breaks reasoning continuity.
Q2 · What does interleaved thinking add over plain up-front reasoning?
A fresh thinking block between tool calls — the model reflects on each
result before choosing the next action, instead of reasoning once and then blindly chaining calls. It's
automatic with adaptive thinking on current models.
Q3 · Which tool_choice values are allowed with extended thinking?
Only auto (default) or none. Forcing a specific tool
({type:"tool"}) or any is not supported while extended thinking is enabled.