Mastering Extended Thinking in Claude: A Practical Guide to Adaptive & Manual Reasoning
Learn how to enable and optimize Claude's extended thinking feature for complex reasoning tasks. Covers adaptive thinking, manual budgets, effort parameters, and code examples.
This guide explains how to use Claude's extended thinking feature to get step-by-step reasoning before final answers. You'll learn to configure adaptive thinking with effort parameters or manual budget_tokens, handle thinking blocks in responses, and optimize for complex tasks like math proofs and code analysis.
Mastering Extended Thinking in Claude: A Practical Guide to Adaptive & Manual Reasoning
Claude's extended thinking feature unlocks a new level of reasoning capability. When enabled, Claude outputs its internal thought process as separate thinking content blocks before delivering its final answer. This transparency is invaluable for debugging, understanding model reasoning, and tackling complex tasks that require step-by-step logic.
In this guide, you'll learn:
- How extended thinking works under the hood
- When to use adaptive thinking vs. manual budget_tokens
- How to configure thinking for different Claude models (Opus 4.7, Sonnet 4.6, etc.)
- Practical code examples in Python and TypeScript
- Best practices for production use
How Extended Thinking Works
When you enable extended thinking in the Messages API, Claude generates one or more thinking content blocks before producing the final text response. Each thinking block contains:
type: Always"thinking"thinking: The raw reasoning text (or a summary, depending on configuration)signature: A cryptographic signature for verification (important for safety-critical applications)
{
"content": [
{
"type": "thinking",
"thinking": "Let me break this down step by step...",
"signature": "WaUjzkypQ2mUEVM36O2TxuC06KN8xyfbJwyem2dw3URve/op91XWHOEBLLqIOMfFG/UvLEczmEsUjavL...."
},
{
"type": "text",
"text": "Based on my analysis, the answer is..."
}
]
}
Note: The thinking content is not returned to the user by default in some models (e.g., Claude Mythos Preview). You can request summaries using display: "summarized".
Adaptive Thinking vs. Manual Budget Tokens
Claude offers two modes for extended thinking:
Adaptive Thinking (Recommended)
Use thinking: {type: "adaptive"} with an effort parameter. Claude automatically decides how many tokens to spend on reasoning based on the complexity of the task. This is the only supported mode for Claude Opus 4.7.
effort: A string ("low","medium","high") that controls how much reasoning effort Claude applies. Higher effort means more thorough reasoning but also higher latency and token usage.
import anthropic
client = anthropic.Anthropic()
response = client.messages.create(
model="claude-opus-4-7",
max_tokens=32000,
thinking={
"type": "adaptive",
"effort": "high"
},
messages=[
{
"role": "user",
"content": "Prove that the square root of 2 is irrational."
}
]
)
for block in response.content:
if block.type == "thinking":
print(f"Thinking: {block.thinking}")
elif block.type == "text":
print(f"Final answer: {block.text}")
Manual Budget Tokens (Deprecated)
Use thinking: {type: "enabled", budget_tokens: N} to set a fixed token budget for thinking. This mode is deprecated on Claude Opus 4.7 (returns a 400 error) and will be removed from future models. It still works on Claude Opus 4.6 and Claude Sonnet 4.6, but adaptive thinking is strongly recommended.
budget_tokens: An integer specifying the maximum number of tokens Claude can use for thinking. Must be less thanmax_tokens.
import Anthropic from '@anthropic-ai/sdk';
const client = new Anthropic();
const response = await client.messages.create({
model: 'claude-sonnet-4-6',
max_tokens: 16000,
thinking: {
type: 'enabled',
budget_tokens: 10000
},
messages: [
{
role: 'user',
content: 'Are there an infinite number of prime numbers such that n mod 4 == 3?'
}
]
});
for (const block of response.content) {
if (block.type === 'thinking') {
console.log(Thinking: ${block.thinking});
} else if (block.type === 'text') {
console.log(Final answer: ${block.text});
}
}
Model-Specific Behavior
Different Claude models handle extended thinking differently. Here's a quick reference:
| Model | Adaptive Thinking | Manual Budget | Notes |
|---|---|---|---|
| Claude Opus 4.7 | ✅ Recommended | ❌ Not supported (400 error) | Use effort parameter |
| Claude Opus 4.6 | ✅ Recommended | ✅ Deprecated but functional | Migrate to adaptive soon |
| Claude Sonnet 4.6 | ✅ Recommended | ✅ Deprecated (interleaved mode) | Migrate to adaptive soon |
| Claude Mythos Preview | ✅ Default | ✅ Accepted | thinking: {type: "disabled"} not supported; use display: "summarized" for summaries |
Important: If you're using Claude Opus 4.7, you must use adaptive thinking. Manual budget_tokens will result in a 400 error.
Practical Use Cases
1. Complex Math Proofs
Extended thinking shines when you need step-by-step logical deduction. For example, proving mathematical theorems or solving multi-step equations.
response = client.messages.create(
model="claude-opus-4-7",
max_tokens=64000,
thinking={"type": "adaptive", "effort": "high"},
messages=[
{"role": "user", "content": "Solve the following system of equations:\n"
"1) x + y + z = 6\n"
"2) x^2 + y^2 + z^2 = 14\n"
"3) xyz = 6"}
]
)
2. Code Review & Debugging
When reviewing complex code, extended thinking helps Claude reason about edge cases, performance implications, and correctness before suggesting fixes.
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=32000,
thinking={"type": "adaptive", "effort": "medium"},
messages=[
{"role": "user", "content": "Review this Python function for potential bugs and performance issues:\n\n"
"def fibonacci(n):\n"
" if n <= 1:\n"
" return n\n"
" return fibonacci(n-1) + fibonacci(n-2)"}
]
)
3. Multi-Step Reasoning Tasks
For tasks like legal analysis, strategic planning, or scientific reasoning, extended thinking provides a transparent chain of thought.
Best Practices
- Always use adaptive thinking for Claude Opus 4.7 and newer models. Manual budget tokens are deprecated.
- Set
max_tokensgenerously – thinking tokens count toward the total. A good rule of thumb: setmax_tokensto at least 2x your expected thinking budget. - Handle thinking blocks in your code – don't ignore them. They contain valuable reasoning that can be logged, analyzed, or displayed to users.
- Use
effortwisely – start with"medium"and increase to"high"only for tasks that genuinely require deep reasoning. Higher effort increases latency and cost. - Be aware of token costs – extended thinking can significantly increase token usage. Monitor your usage and set appropriate budgets.
- Verify signatures in safety-critical applications to ensure the thinking content hasn't been tampered with.
Troubleshooting Common Issues
| Issue | Cause | Solution |
|---|---|---|
| 400 error on Opus 4.7 | Using type: "enabled" with budget_tokens | Switch to type: "adaptive" with effort |
| No thinking blocks returned | Model doesn't support display: "full" | Use display: "summarized" or check model docs |
| High latency | effort: "high" or large budget_tokens | Reduce effort or budget; consider streaming |
| Token limit exceeded | max_tokens too low | Increase max_tokens to accommodate thinking + response |
Key Takeaways
- Extended thinking gives Claude enhanced reasoning capabilities and transparent step-by-step reasoning via thinking content blocks.
- Adaptive thinking (
type: "adaptive"witheffort) is the recommended mode for all current Claude models, and the only supported mode for Claude Opus 4.7. - Manual budget tokens (
type: "enabled"withbudget_tokens) are deprecated and will be removed in future model releases. - Model compatibility matters – always check which thinking mode your target model supports before coding.
- Handle thinking blocks in your application to leverage Claude's full reasoning power, whether for debugging, user transparency, or downstream analysis.