
Claude Advisor Tool: Pair Haiku With Opus in Python
Summary
Let a cheap executor model consult a stronger advisor mid-task in one Messages API call.
Run a Cheap Model, Call a Genius Only When It Counts
Here is the trade every agent builder knows. Run everything on a frontier model and the bill is brutal. Run everything on a small model and it makes confident, wrong decisions at the worst moments. The advisor tool on the Claude API splits the difference: a fast, cheap executor model does the bulk of the work and pulls in a stronger advisor model for a second opinion at the exact moments that decide whether a task succeeds.
This is fresh and moving fast. The advisor tool is in beta behind the header advisor-tool-2026-03-01, and on June 2, 2026 Anthropic added a max_tokens parameter to cap advisor output per call, the single biggest lever on its cost. It already pairs with Claude Opus 4.8, and Anthropic reports that a Haiku executor with an Opus advisor more than doubled accuracy on its BrowseComp evaluation (from about 19.7% to 41.2%) while costing far less than running Sonnet throughout. That combination of cheaper and smarter is why "the advisor strategy" is all over dev feeds this month.
By the end of this guide you will make a working advisor call, read the per-model billing breakdown that the API returns, build a real agent loop where Haiku escalates to Opus, and cap the cost so a runaway loop cannot surprise you. Every code block matches the official docs and the parsing code is tested.
Prerequisites
- Python 3.9+ and the official SDK:
pip install -U anthropic(you need a recent build that exposesclient.beta.messages). - An Anthropic API key in the
ANTHROPIC_API_KEYenvironment variable. - Access to a valid executor/advisor pair. The advisor tool runs on the Claude API and Claude Platform on AWS only. It is not on Amazon Bedrock, Vertex AI, or Microsoft Foundry.
- Basic familiarity with Claude tool use (the
toolsarray and the agentic request/response loop).
How the advisor tool actually works
The advisor is a server tool. You declare it once in your tools array, then the executor decides when to use it, just like any other tool. The difference is that everything happens server-side inside a single /v1/messages request, with no extra round trips on your side.
When the executor invokes the advisor, four things happen:
- The executor emits a
server_tool_useblock withname: "advisor"and an emptyinput. The executor signals the timing; the server supplies the context. - Anthropic runs a separate inference pass on the advisor model, passing it the executor's full transcript: the system prompt, every tool definition, every prior turn, and every tool result.
- The advisor's answer returns to the executor as an
advisor_tool_resultblock (typically 400 to 700 words of advice, plus dropped thinking). - The executor keeps generating, now informed by the plan.
The advisor runs without tools, without context management, and its raw thinking is discarded. Only the advice text reaches the executor. That is the whole mechanism: a stronger brain reads the situation and hands back a plan, then your cheaper model executes it.
Step 1: Your first advisor call
Start with a Sonnet executor and an Opus advisor. Two things are mandatory: the beta header in betas=[...], and using client.beta.messages.create rather than the stable endpoint.
import anthropic
client = anthropic.Anthropic() # reads ANTHROPIC_API_KEY
tools = [
{
"type": "advisor_20260301", # the tool type, with the dated version
"name": "advisor", # must be exactly "advisor"
"model": "claude-opus-4-8", # the ADVISOR model (>= executor)
}
]
response = client.beta.messages.create(
model="claude-sonnet-4-6", # the EXECUTOR model
max_tokens=4096, # caps EXECUTOR output only
betas=["advisor-tool-2026-03-01"],
tools=tools,
messages=[
{
"role": "user",
"content": "Build a concurrent worker pool in Go with graceful shutdown.",
}
],
)
for block in response.content:
print(block.type)
The top-level model is the executor; the model inside the tool definition is the advisor. You never call the advisor yourself, and you never put a question in input: the server builds the advisor's view from the transcript automatically.
What the response looks like
When the executor consults the advisor, the assistant content contains a server_tool_use block immediately followed by an advisor_tool_result. This is the documented shape:
{
"role": "assistant",
"content": [
{ "type": "text", "text": "Let me consult the advisor on this." },
{
"type": "server_tool_use",
"id": "srvtoolu_abc123",
"name": "advisor",
"input": {} // always empty
},
{
"type": "advisor_tool_result",
"tool_use_id": "srvtoolu_abc123",
"content": {
"type": "advisor_result",
"text": "Use a channel-based coordination pattern. The tricky part is
draining in-flight work during shutdown: close the input channel
first, then wait on a WaitGroup..."
}
},
{ "type": "text", "text": "Here's the implementation. I'm using a channel-based..." }
]
}
Two result shapes exist. Most models (including Opus 4.8) return advisor_result with a readable text field. Some return advisor_redacted_result with an opaque encrypted_content blob you cannot read. In both cases you must pass the block back verbatim on later turns; the server decrypts and re-injects the advice for you. Branch on content.type if you switch advisor models mid-conversation.
Step 2: Pick a valid executor/advisor pair
The rule is simple: the advisor must be at least as capable as the executor. The API enforces this and returns a 400 invalid_request_error for an invalid pair (for example, an Opus 4.7 executor with an Opus 4.6 advisor). These are the accepted combinations:
| Executor model | Accepted advisor models |
|---|---|
| Claude Haiku 4.5 (claude-haiku-4-5) | Opus 4.8, Opus 4.7 |
| Claude Sonnet 4.6 (claude-sonnet-4-6) | Opus 4.8, Opus 4.7 |
| Claude Opus 4.6 (claude-opus-4-6) | Opus 4.8, Opus 4.7 |
| Claude Opus 4.7 (claude-opus-4-7) | Opus 4.8, Opus 4.7 |
| Claude Opus 4.8 (claude-opus-4-8) | Opus 4.8 |
| Claude Fable 5 (claude-fable-5) | Fable 5 |
| Claude Mythos 5 (claude-mythos-5) | Mythos 5 |
The high-value pairings are Haiku executor + Opus advisor (lowest-cost worker with strong planning) and Sonnet executor + Opus advisor (a quality lift on complex tasks at similar or lower total cost). Opus-on-Opus is for high-stakes work where an independent second read matters more than price.
Step 3: A real agent loop with pause_turn handling
In production the advisor lives inside your normal tool loop. Two things differ from a plain loop. First, advisor calls do not stream and can leave the response with stop_reason: "pause_turn" when a server tool is still pending; you simply re-send the conversation to let the API finish it. Second, you must carry the assistant content (including the advisor blocks) forward unchanged.
import anthropic
client = anthropic.Anthropic()
ADVISOR_TOOL = {"type": "advisor_20260301", "name": "advisor", "model": "claude-opus-4-8"}
def run_your_tools(content):
"""Execute your own client-side tools and return tool_result blocks.
Server tools like the advisor are handled by Anthropic, not here."""
results = []
for b in content:
if b.type == "tool_use": # your custom tools only
output = dispatch(b.name, b.input) # your code
results.append({
"type": "tool_result",
"tool_use_id": b.id,
"content": output,
})
return results
def agent(task, tools, executor="claude-haiku-4-5", max_turns=20):
messages = [{"role": "user", "content": task}]
all_tools = [ADVISOR_TOOL] + tools
for _ in range(max_turns):
resp = client.beta.messages.create(
model=executor,
max_tokens=4096,
betas=["advisor-tool-2026-03-01"],
tools=all_tools,
messages=messages,
)
messages.append({"role": "assistant", "content": resp.content})
if resp.stop_reason == "end_turn":
return messages
if resp.stop_reason == "pause_turn":
continue # server tool (e.g. advisor) pending: re-send to resume
# otherwise the model called your client-side tools
results = run_your_tools(resp.content)
messages.append({"role": "user", "content": results})
return messages
If your executor is Haiku and it tends to skip the advisor, add a one-time nudge as a separate user message after the first batch of tool results. Anthropic reports this raises Haiku task pass rates by roughly 7 points. Do not nudge an Opus executor, where it slightly lowers results.
NUDGE = ("You have not consulted the advisor yet. If the task has a non-obvious "
"design decision or a failure mode you haven't ruled out, call advisor "
"now before committing to an approach.")
# inside the loop, after appending tool results, fire once around turn 2:
called = any(b.type == "server_tool_use" and b.name == "advisor"
for m in messages if isinstance(m["content"], list)
for b in m["content"])
if turn == 1 and not called:
messages.append({"role": "user", "content": NUDGE})
Step 4: Read the bill correctly
This trips people up. The top-level usage fields count executor tokens only. Advisor tokens are billed at the advisor model's rates and reported separately in usage.iterations[], where each entry is typed message (executor) or advisor_message (advisor, carrying its own model). To know what a turn truly cost, walk the iterations.
# Rates are per 1M tokens. Replace these with current published pricing.
PRICES = {
"claude-haiku-4-5": {"in": 1.00, "out": 5.00}, # illustrative
"claude-opus-4-8": {"in": 5.00, "out": 25.00}, # illustrative
}
def cost_breakdown(usage, executor_model, prices):
exec_in = exec_out = adv_in = adv_out = advisor_calls = 0
adv_model = None
for it in usage["iterations"]:
if it["type"] == "advisor_message":
advisor_calls += 1
adv_model = it["model"]
adv_in += it["input_tokens"] + it["cache_read_input_tokens"]
adv_out += it["output_tokens"]
else: # "message" == executor
exec_in += it["input_tokens"] + it["cache_read_input_tokens"]
exec_out += it["output_tokens"]
def usd(t_in, t_out, model):
p = prices[model]
return t_in / 1e6 * p["in"] + t_out / 1e6 * p["out"]
exec_cost = usd(exec_in, exec_out, executor_model)
adv_cost = usd(adv_in, adv_out, adv_model) if adv_model else 0.0
return {
"advisor_calls": advisor_calls,
"executor_cost_usd": round(exec_cost, 6),
"advisor_cost_usd": round(adv_cost, 6),
"total_usd": round(exec_cost + adv_cost, 6),
}
Feed it the exact usage object from the docs (one advisor call, Opus advisor) and the tested output is:
>>> cost_breakdown(usage, "claude-haiku-4-5", PRICES)
{
"advisor_calls": 1,
"executor_cost_usd": 0.004827,
"advisor_cost_usd": 0.044415,
"total_usd": 0.049242
}
Notice the shape of the spend: the executor side is fractions of a cent, while the single advisor consult is the dominant line item. That is the whole game. You pay advisor rates only on the handful of turns that need a plan, and executor rates on everything else, instead of paying frontier rates on every token.
Step 5: Cap advisor cost so it can't run away
Because the top-level max_tokens does not bound the advisor, you need explicit limits. There are three independent levers, and you can stack them.
1. Hard output cap with max_tokens on the tool. Caps the advisor's thinking-plus-text per call. The minimum is 1024; Anthropic recommends 2048 as a starting point, which cut mean advisor output by roughly 7x in their testing with near-zero truncation.
ADVISOR_TOOL = {
"type": "advisor_20260301",
"name": "advisor",
"model": "claude-opus-4-8",
"max_tokens": 2048, # hard ceiling per advisor call (min 1024)
}
2. Per-request call cap with max_uses. Once the executor hits the cap, further advisor calls return an error result with error_code: "max_uses_exceeded" and the executor just continues without advice; the request itself does not fail.
ADVISOR_TOOL = {
"type": "advisor_20260301", "name": "advisor",
"model": "claude-opus-4-8",
"max_uses": 3, # at most 3 advisor calls in this single request
}
3. Advisor-side prompt caching for long loops. The advisor re-reads the whole transcript every call, so caching its prompt pays off once you expect three or more consults in a conversation. Keep it off for short tasks, where the cache write costs more than the reads save.
ADVISOR_TOOL = {
"type": "advisor_20260301", "name": "advisor",
"model": "claude-opus-4-8",
"caching": {"type": "ephemeral", "ttl": "5m"}, # or "1h"
}
For a softer touch, drop a line addressed to the advisor into your user message: (Advisor: keep your guidance under 80 words.). The advisor sees your messages as quoted context, so a direct request like this is followed reliably and trims output without a hard cut.
Worked example: a research agent that escalates its plan
Put it together for a common real-world case: a multi-step research agent. Haiku does the searching and reading; Opus is consulted to shape the research plan up front and to sanity-check the synthesis before the agent declares done. Web search and the advisor are both server tools, so they share one tools array.
tools = [
{"type": "web_search_20250305", "name": "web_search", "max_uses": 5},
{"type": "advisor_20260301", "name": "advisor",
"model": "claude-opus-4-8", "max_tokens": 2048, "max_uses": 3},
]
SYSTEM = (
"You are a research agent. Call advisor BEFORE substantive work to shape "
"the plan, and once more before declaring the report done. Do orientation "
"(searching, reading) first; orientation is not substantive work."
)
resp = client.beta.messages.create(
model="claude-haiku-4-5",
system=SYSTEM,
max_tokens=4096,
betas=["advisor-tool-2026-03-01"],
tools=tools,
messages=[{"role": "user", "content":
"Compare three open-source vector databases for a 50M-vector RAG workload. "
"(Advisor: keep guidance under 80 words.)"}],
)
print(cost_breakdown(resp.usage.model_dump(), "claude-haiku-4-5", PRICES))
Haiku runs the searches and writes the comparison at Haiku rates. Opus shows up twice: once to pick the evaluation axes (throughput, recall, memory, operational cost) and once to catch a missing axis before the report ships. You get close to Opus-quality structure while the bulk of the tokens are generated cheaply.
Common pitfalls and gotchas
Missing the beta header. Without betas=["advisor-tool-2026-03-01"] the API does not recognize advisor_20260301 and rejects the tool. The header and client.beta.messages.create go together.
Dropping advisor blocks but keeping the tool, or vice versa. If your message history still contains advisor_tool_result blocks, the advisor tool must remain in tools, otherwise you get a 400. To stop using the advisor mid-conversation, remove the tool and strip every advisor_tool_result block together.
Reading cost from the top-level usage. Top-level output_tokens is executor-only. If you bill from it you will understate cost and never see the advisor spend. Always walk usage.iterations[].
Expecting the advisor to stream. It does not. The executor stream pauses (with periodic SSE pings) while the advisor runs, then the full advisor_tool_result arrives in one event. Handle pause_turn by re-sending the conversation.
Trying to ask the advisor a question via input. The server_tool_use.input is always empty and anything you put there is ignored. To steer the advisor, change the system prompt or user message it will read as context.
Capping with the wrong knob. Top-level max_tokens bounds executor output, not the advisor. Use max_tokens on the tool definition (minimum 1024) for a hard advisor ceiling.
Nudging the wrong model. The plain-text nudge helps Haiku and is neutral on Sonnet, but it slightly hurts Opus. Fire it early-but-not-too-early (around turn 2); a turn-2 nudge on a workload whose natural first consult lands at turn 7+ correlated with a small performance drop.
Forgetting the platform limits. Advisor is API and Claude Platform on AWS only, in beta. If your stack runs on Bedrock, Vertex, or Foundry, it is not available there yet.
Quick reference
| Item | Value |
|---|---|
| Beta header | advisor-tool-2026-03-01 |
| Tool type / name | advisor_20260301 / advisor |
| SDK call | client.beta.messages.create(..., betas=[...]) |
| Executor model | top-level model field |
| Advisor model | model inside the tool definition (>= executor) |
| Response blocks | server_tool_use (empty input) + advisor_tool_result |
| Result variants | advisor_result (text) / advisor_redacted_result (encrypted_content) |
| Billing | usage.iterations[]; type message=executor, advisor_message=advisor |
| Hard output cap | max_tokens on tool def (min 1024, ~2048 recommended) |
| Per-request call cap | max_uses on tool def |
| Advisor caching | caching {type: ephemeral, ttl: 5m|1h}; worth it at 3+ calls |
| Resume after consult | stop_reason pause_turn -> re-send conversation |
| Platforms | Claude API + Claude Platform on AWS (beta); not Bedrock/Vertex/Foundry |
Next steps
- Take an existing Sonnet or Haiku agent and add the advisor tool with
max_tokens: 2048. Logusage.iterationsfor a week and compare cost and pass rate against your old setup. - Add the suggested coding system prompt that tells the executor to consult before its first write and before declaring done, then measure how call timing shifts.
- Pair a Sonnet executor at medium effort with an Opus advisor; Anthropic reports this matches Sonnet at default effort for less on coding tasks.
- Build a client-side conversation-level cap: count advisor calls yourself, and when you hit your ceiling, remove the tool and strip the advisor blocks together.
- Compare the advisor against subagents and opusplan for your workload to decide where a second model belongs.
Code and API details verified against Anthropic's official advisor tool documentation (platform.claude.com) and the Claude Developer Platform release notes, June 2026. Pricing figures in the cost helper are illustrative placeholders; substitute current published rates.
Comments
Be the first to comment
Found this useful?
Get new AI guides for builders by email. Free.
Join 3,617 newsletter subscribers.