Extended and adaptive thinking

Claude API · Advanced · 13 min

Thinking improves hard tasks, and handling it wrongly breaks tool loops or wastes tokens.

Claude can reason step by step before it answers. The reasoning comes back as thinking blocks before the text blocks. On current models this is adaptive thinking: Claude decides per request whether and how much to think.

You enable it with thinking={"type": "adaptive"} and steer it with effort, set in output_config={"effort": ...}. Levels run low, medium, high, xhigh and max (availability varies by model). Higher effort usually means better answers on hard problems but more output tokens and more waiting. Effort is guidance, not a guarantee; Claude may still skip thinking on easy requests. Some models always think, others let you turn it off.

Older models used extended thinking with a fixed budget, thinking={"type": "enabled", "budget_tokens": N}. Newer models reject that form, and older ones reject adaptive, so match the style to the model.

Rules that matter:

  • max_tokens caps thinking plus answer together; leave room for both.
  • By default you see a summary of the thinking, but you are billed for the full thinking tokens.
  • In tool loops, append the assistant content unchanged, thinking blocks included. They carry a signature, and edited or dropped blocks cause errors or worse tool decisions.
  • Changing effort or thinking settings mid-conversation invalidates the prompt cache.

Use more effort for planning, maths, tricky code and multi-step agent work; use less for simple lookups and chat.

Example

import anthropic

client = anthropic.Anthropic()
resp = client.messages.create(
    model="claude-opus-5-5",
    max_tokens=16000,                    # room for thinking + answer
    thinking={"type": "adaptive"},
    output_config={"effort": "high"},
    messages=[{"role": "user", "content":
        "A bat and ball cost $1.10; the bat costs $1 more. Price of the ball?"}],
)

for block in resp.content:
    if block.type == "thinking":
        print("[thinking summary]", block.thinking[:200])
    elif block.type == "text":
        print(block.text)
print(resp.usage.output_tokens)             # includes thinking tokens

Remember

  • Current models: thinking={"type": "adaptive"} + output_config.effort
  • max_tokens covers thinking and answer; thinking is billed in full
  • Pass thinking blocks back unchanged in tool loops

Watch out for

  • Using budget_tokens examples from older docs on a model that only accepts adaptive thinking.

Check yourself

  1. In a tool loop with thinking on, what do you do with the thinking blocks?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: platform.claude.com/docs/en/build-with-claude/thinking