passdrill
AI & LLM Engineering · Building with LLM APIs · Card 007/012 hard

A developer is using Anthropic's Messages API with two tools defined, `get_weather` and `send_email`, and wants to guarantee that Claude calls `get_weather` specifically on this turn rather than answering in plain text or calling `send_email`. According to Anthropic's tool-use documentation, how is this accomplished?

  1. By removing `send_email` from the `tools` array entirely for this request, since `tool_choice` can only force "any" tool use, not a specific named tool
  2. By setting `tool_choice` to `{"type": "any"}`, which restricts the model to only the first tool listed in the `tools` array
  3. By setting `tool_choice` to `{"type": "tool", "name": "get_weather"}`, which forces the model to call that specific named tool rather than deciding on its own or calling a different one
  4. By adding the instruction "you must call get_weather" only to the system prompt, since `tool_choice` itself has no mechanism for naming a specific tool
Next card → Shuffle