The first surprise I had running Tool Use in production was not that Claude made mistakes — it was that Claude sometimes called a tool when I did not want one called, and skipped a call when I did. Responses looked clever; the bill was about 1.5 times what I had planned. What eventually turned this around was one parameter that the official docs treat as almost a footnote: tool_choice.
In practice, understanding tool_choice is the difference between a pipeline that quietly wastes output tokens and one that does not. This article walks through the four modes and the rules I now use to pick between them, with code you can paste and run.
Four modes, one parameter
tool_choice sits next to tools on a Messages API request. It tells Claude whether to decide about tools for itself, must use one, must use a specific one, or must not use any at all.
from anthropic import Anthropic
client = Anthropic()
response = client.messages.create(
model="claude-sonnet-4-6",
max_tokens=1024,
tools=[
{
"name": "get_weather",
"description": "Return the current weather for a city",
"input_schema": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
}
],
tool_choice={"type": "auto"}, # <-- flip this
messages=[{"role": "user", "content": "What is the weather in Tokyo?"}],
)The four modes behave like this:
- auto (default) — Claude decides whether to call a tool. Best fit for open-ended chat.
- any — Claude must call one of the declared tools, but chooses which.
- tool — Claude must call the named tool (
{"type": "tool", "name": "get_weather"}). - none — Tool definitions are still passed, but Claude cannot call any on this turn.
One detail that is easy to miss: with any and tool, the API starts the assistant turn directly at the tool_use block. The short natural-language preamble ("I'll look up the weather for you...") never appears. That saves output tokens and latency — but it comes with a trade-off, covered under the traps below.
When I reach for each mode
Running enough production traffic, you start to see "auto is fine, but something else would be cheaper and faster." Here is the checklist I apply.
auto — free-form conversation
If your assistant handles small talk alongside tool-capable requests, auto is the only mode that lets it stay conversational. It avoids the anti-pattern of the bot dutifully firing a tool for "thanks!".
any — classifiers and structured output
Whenever the turn must produce a structured result — a category, a scored object, a routing decision — any is almost always the right pick. Each tool becomes a candidate output shape. Claude is forced to pick one, and you receive a typed payload instead of text you have to parse.
# Route an inbound ticket into one of three categories
response = client.messages.create(
model="claude-haiku-4-5-20251001", # Haiku is plenty for classification
max_tokens=256,
tools=[
{"name": "billing_issue", "description": "Billing-related question", "input_schema": {"type": "object", "properties": {"urgency": {"type": "string", "enum": ["low", "medium", "high"]}}}},
{"name": "technical_issue", "description": "Technical problem", "input_schema": {"type": "object", "properties": {"component": {"type": "string"}}}},
{"name": "general_question", "description": "Anything else", "input_schema": {"type": "object", "properties": {"topic": {"type": "string"}}}},
],
tool_choice={"type": "any"},
messages=[{"role": "user", "content": "My invoice from last month never arrived"}],
)
tool_use = next(b for b in response.content if b.type == "tool_use")
print(tool_use.name) # -> 'billing_issue'
print(tool_use.input) # -> {'urgency': 'medium'}You get a typed, schema-validated payload for free — no prompt gymnastics for JSON mode, no regex fallback for misshapen output.
tool — "the turn ends with exactly this"
tool mode is blunt, so I avoid it as a default. It earns its keep in two specific places:
- The tail of a conversation, where
save_conversationabsolutely has to be called. - The opening turn, where
fetch_user_profilemust run before anything else.
The trick is to switch it on for one turn and switch back to auto next. Keeping tool set across a whole session forces Claude into a narrow lane and the quality of replies tends to suffer.
none — debugging and graceful degradation
The mode that quietly earned my trust is none. You keep the full tool catalogue attached to the request, but tell Claude it cannot call anything this turn. Real uses I have seen:
- A summarization turn at the end of a session, where you do not want another tool call creeping in.
- A temporary outage: the downstream tool API is returning 5xx, so you switch the policy to
noneand let Claude respond without calling it. - A "what can you do?" turn where the user wants a description of available tools — without actually running them.
That last one is surprisingly effective. Ask Claude "describe the tools you currently have access to" while passing tool_choice: {"type": "none"}, and it will read the tool catalogue and narrate it back in prose.
What this does to the bill — measure it on your own logs
I cannot give you one reduction figure and stand behind it. The savings depend on how many tools you declare, how long their descriptions are, the prompt, and the model — all of which change how much preamble auto produces. On a small classification toolset I saw a large drop in output tokens, but please do not copy that ratio onto your workload.
What I can say is directional:
- Under
auto, Claude may add a short explanation before a tool call, and you pay for those output tokens. anyandtoolbegin attool_use, so that preamble disappears.noneforbids calls, so the output is prose only. Tool definitions are still sent, and still billed as input.
The tool-use pricing docs also list the extra system-prompt tokens added automatically, broken out by tool_choice. The difference is small per request but compounds at volume; check the current table, since the numbers get revised.
To compare on your own traffic, send the same ~100 prompts with only tool_choice changed and aggregate usage:
from collections import defaultdict
def measure(prompts, tool_choice):
total = defaultdict(int)
for text in prompts:
r = client.messages.create(
model=MODEL, # the model ID you actually run
max_tokens=512,
tools=TOOLS,
tool_choice=tool_choice,
messages=[{"role": "user", "content": text}],
)
total["input"] += r.usage.input_tokens
total["output"] += r.usage.output_tokens
n = len(prompts)
return {k: v / n for k, v in total.items()}
for choice in ({"type": "auto"}, {"type": "any"}):
print(choice["type"], measure(SAMPLE_PROMPTS, choice))If auto clearly emits more output than any, the turns where a tool call is certain are worth switching. If the gap is small, leave it alone. For the broader design, see Claude API cost optimization — production patterns; revisiting tool_choice is an easy place to start.
A dynamic wrapper
In practice, it helps to wrap mode selection in a single function that reads the turn's purpose. Here is a minimal TypeScript sketch:
import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic();
type TurnKind = "greeting" | "classify" | "respond" | "summarize";
function pickToolChoice(kind: TurnKind) {
switch (kind) {
case "greeting":
return { type: "none" as const }; // never call a tool on hello
case "classify":
return { type: "any" as const }; // must produce a typed class
case "respond":
return { type: "auto" as const }; // free-form chat
case "summarize":
return { type: "tool" as const, name: "save_summary" }; // end-of-session save
}
}
async function runTurn(kind: TurnKind, userMessage: string) {
return client.messages.create({
model: "claude-sonnet-4-6",
max_tokens: 1024,
tools: /* the stable set shared across all turns */ [],
tool_choice: pickToolChoice(kind),
messages: [{ role: "user", content: userMessage }],
});
}One subtle but important rule: keep the tools array identical across turns. If you add or remove tool definitions between requests, the cache from tools onward is invalidated. Changing only tool_choice is gentler: it affects the cached message blocks, while the tools and system-prompt caches survive.
I got this wrong at first. On a session with a long history, switching modes every turn means rebuilding the message cache each time, and the cache-write surcharge can outweigh the output tokens you saved. Switch only on turns where the benefit is clear. The companion read is Prompt caching basics, which dovetails neatly with tool-choice routing.
Traps worth knowing about
any with a single tool behaves like tool
If your tools array has exactly one entry and you pass any, Claude will almost always call it — but the guarantee is weaker than tool. Behavior drifts slightly between model snapshots. When you need certainty, use tool explicitly.
tool does not make long arguments free
No preamble is emitted, but the input JSON still costs output tokens. A tool that takes a whole summary as its argument will be expensive regardless of mode, so design arguments around IDs and labels where you can. Setting max_tokens near 200 for pure tool-call turns bounds runaway output — just not so low that a legitimate argument is cut off mid-JSON.
Keep tool_result history under none
With none, you can safely leave prior tool_use / tool_result exchanges in the messages array. In fact you should — Claude uses them to ground its response. Attempting to strip them out corrupts the context. If tool-result bookkeeping is tripping you up, Tool Use error handling patterns is a good companion.
any and tool cannot be combined with extended thinking
When extended thinking is on, only auto and none are accepted; any or tool returns an error. Wanting deep reasoning and wanting a forced call are different turns. I use auto with thinking where reasoning matters, and a thinking-free tool where the call must happen.
Leave any on inside an agent loop and it never ends
After a tool runs, you send the tool_result back and ask again. If tool_choice is still any or tool, Claude must call a tool every time and never gets to write the final answer. The loop runs until your turn limit, and you pay for every lap.
I found this out reading a batch log in the morning — the same tool call repeated down the screen, and my stomach dropped. Force only the first move, and go back to auto the moment results come back. That is the line I hold now.
Pair with disable_parallel_tool_use for transactional turns
For workflows where exactly one tool call per turn is the only acceptable outcome (payment processing, state transitions), pass:
tool_choice = {"type": "auto", "disable_parallel_tool_use": True}This blocks Claude from emitting multiple tool_use blocks in a single response and removes a class of race conditions from your execution layer.
What to try next
Open your logs, pick ten live Tool Use requests, and check how many are still on auto. For each one, ask: "is the decision here genuinely open, or do I actually know the answer?" Every request where the answer is "I know" is a candidate for any, tool, or none. Flip those and watch one day of traffic — the line item will usually move.
If that goes well, pull the mode-picker into a single function so every turn announces its purpose. That small piece of structure is the foundation for every other Tool Use optimization you will reach for later. For a broader survey of Tool Use patterns that pair well with this approach, the advanced Tool Use guide keeps a map of where each technique shines.