Lv.1 0 XP

tool_choice — auto, any, and Forced Selection

⚡ Exam Tested 9 min +40 XP
💡
THE ANALOGY

Giving instructions to a contractor. 'Use whatever you think is best' (auto). 'You must use a tool — pick which one' (any). 'Use specifically the drill for this step' (forced). Each is appropriate in different situations — choosing wrong wastes time or produces wrong results.

⚠️ EXAM TRAP — The Wrong Answer People Choose

Using tool_choice: 'auto' when you need guaranteed tool usage. 'auto' means Claude MAY return text instead of calling a tool. For structured output pipelines, document processing, or any workflow where a tool MUST be called, 'any' or forced is required.

KEY POINTS
1 tool_choice: 'auto' — Claude decides whether to call a tool or respond with text. Default. Use when task might or might not require a tool.
2 tool_choice: 'any' — Claude MUST call a tool, but chooses which one. Use when you need guaranteed tool invocation but document type/content determines the right tool.
3 tool_choice: {type: 'tool', name: 'specific_tool'} — Claude MUST call this exact tool. Use for sequential workflows where a specific step must execute.
4 The exam specifically tests: when document type is unknown and multiple extraction schemas exist → use 'any' not 'auto'.
5 Forced tool_choice is commonly used for structured output extraction — guarantees Claude produces the schema you need.