A research assistant agent uses three tools: search_web, query_database, and fetch_document. For a given user query, the agent determines it needs results from all three tools before generating a final answer. The tools are independent (no output from one is needed as input to another). What is the most efficient API interaction pattern?
Select an answer to reveal the explanation.
Short Explanation
Here's the deal — request all three tools in one model response and return all three tool_result blocks in one follow-up user message. Claude can emit multiple tool_use blocks when tools are independent, so you run them concurrently and cut round-trips from three to one.
Full Explanation
The pattern that requests all three tools in a single model response by including all tool definitions, then submits all three tool_result blocks in a single follow-up user message, is correct because Claude supports parallel tool use. When given multiple tool definitions and a query that benefits from simultaneous tool calls, the model can return multiple tool_use content blocks in a single response. The client executes all three tools concurrently, then submits all three tool_result blocks in a single user message. This reduces round-trips from three to one and allows parallel execution of independent tools. Making three sequential API calls, each requesting one tool, to maintain clear control flow is wrong because sequential tool calls serialize three independent operations — each requires a full LLM round-trip before the next starts, tripling latency unnecessarily. Using three parallel API calls with different system prompts, each requesting one tool, then merging the responses is wrong because using three separate API calls with separate context windows means the model cannot reason holistically about the results from all three tools; merging at the application layer loses semantic coherence. Using streaming to interleave the three tool calls and process results as they arrive is wrong because streaming provides incremental token delivery, not parallel tool execution; tool calls are still sequential in a streaming response.