A developer building a form-filling agent with Claude wants Claude, on this one request, to guarantee it calls the single tool named `submit_form` rather than possibly responding with plain text or calling some other tool it also happens to have defined. Which `tool_choice` value on the Claude API achieves this?
- `{"type": "auto"}`, which lets Claude decide for itself whether to call any of the provided tools or respond directly, without guaranteeing any particular tool -- or any tool at all -- gets called
- `{"type": "none"}`, which prevents Claude from calling any tool whatsoever, forcing a plain-text response instead
- `{"type": "any"}`, which forces Claude to call some tool from the ones provided, but leaves Claude free to pick whichever one of those tools it judges best rather than a specific one
- `{"type": "tool", "name": "submit_form"}`, which forces Claude to always use that one, specifically named tool on this request
Why D? And why not the others?
Correct answer: D. `{"type": "tool", "name": "submit_form"}`, which forces Claude to always use that one, specifically named tool on this request
The `tool` type of `tool_choice`, given a `name`, forces Claude to always use that one particular tool on the request, which is exactly the guarantee needed here: `submit_form` will be called rather than some other tool or a plain-text reply. The option describing `auto` is wrong because `auto` is the default behavior that lets Claude decide on its own whether to call any provided tool or respond directly, which gives no guarantee that `submit_form` specifically -- or any tool at all -- gets called. The option describing `none` is wrong because it does the opposite of what is wanted: it prevents Claude from calling any tool at all, forcing a plain-text response, when the goal here is to force a specific tool call rather than block tool use entirely. The option describing `any` is wrong because, while it does force Claude to call some tool rather than respond in plain text, it leaves the choice of which tool up to Claude among everything provided, which does not guarantee `submit_form` specifically is the one selected if other tools are also defined on the request.
Source: Anthropic, 'Define tools' (platform.claude.com/docs/en/agents-and-tools/tool-use/define-tools#forcing-tool-use) -- 'auto allows Claude to decide whether to call any provided tools or not... any tells Claude that it must use one of the provided tools, but doesn't force a particular tool... tool forces Claude to always use a particular tool... none prevents Claude from using any tools.'