Extended thinking umožňuje Opus “přemýšlet nahlas” před finální odpovědí. Pojďme pochopit, jak to funguje.
Základní princip
Běžný model:
[Input] → [Model] → [Output]
Extended thinking:
[Input] → [Model] → [Thinking tokens] → [Final Output]
↓
(viditelné uživateli)
Jak to vypadá v praxi
Bez extended thinking:
User: What's the bug in this code?
Assistant: The bug is on line 5 where...
S extended thinking:
User: What's the bug in this code?
<thinking>
Let me analyze this step by step...
1. First, I'll trace the data flow...
2. The variable `count` is initialized to 0...
3. In the loop, it's incremented but...
4. Ah, I see - the condition should be <= not <
</thinking>
The bug is on line 5. The loop condition uses `<`
but should use `<=` to include the boundary case...
API aktivace
from anthropic import Anthropic
client = Anthropic()
response = client.messages.create(
model="claude-opus-4-5-20250101",
max_tokens=16000,
thinking={
"type": "enabled",
"budget_tokens": 10000 # max thinking tokens
},
messages=[{
"role": "user",
"content": "Solve this complex problem..."
}]
)
# Thinking je v response
for block in response.content:
if block.type == "thinking":
print("Thinking:", block.thinking)
elif block.type == "text":
print("Answer:", block.text)
Effort Levels
Můžete kontrolovat “hloubku” přemýšlení:
| Budget | Použití | Typický output |
|---|---|---|
| 1,000 | Quick check | 1-2 kroky analýzy |
| 5,000 | Standard | 3-5 kroků |
| 10,000 | Deep | 5-10 kroků |
| 30,000+ | Exhaustive | Komplexní analýza |
Kdy model sám použije více thinking
- Komplexní matematické problémy
- Multi-step reasoning
- Kód s mnoha závislostmi
- Ambiguitní zadání
- Problémy s mnoha edge cases
Interní mechanismus
- Priming: Model rozpozná, že potřebuje reasoning
- Exploration: Generuje alternativní cesty řešení
- Evaluation: Vyhodnocuje jednotlivé cesty
- Selection: Vybírá nejlepší cestu
- Articulation: Formuluje finální odpověď
Tento proces je transparentní - vidíte, jak model “přemýšlí”.
V další lekci se podíváme na cost kalkulace.