Lesson 33.3 · 3 of 6 · 5 min read · Reviewed 24 Nov 2026
Parallel tool calls
By the end, you can
- Handle several tool_use blocks in one turn.
- Decide when to turn parallel tool use off.
Sometimes Claude needs several pieces of information that do not depend on each other, such as the weather in two cities. It can return multiple tool_use blocks in a single response.
Handling parallel calls
- Collect every
tool_useblock in the response. - Run them. Because they are independent, you can run them concurrently.
- Send all the
tool_resultblocks back together, in one user message, each with its matchingtool_use_id.
Splitting results across several messages, or dropping one, produces an error or confuses the model.
Parallel vs sequential
If call B needs the output of call A (look up a customer, then their orders), Claude will make A, wait for the result, then make B in the next turn. You do not need to orchestrate that yourself: the loop from lesson 15.2 handles it naturally.
When to turn it off
If your tools have side effects that must happen one at a time, set "disable_parallel_tool_use": true inside tool_choice so Claude asks for at most one tool per turn.
Key points
- Claude can return several tool_use blocks in one turn when calls are independent.
- Run them (in parallel if you like) and return every result in one user message.
- Dependent calls happen across turns, because each needs the previous result.
Run parallel tool calls together
Handle several tool calls in one turn, run them concurrently, and compare with parallel use turned off.
You will have: A run() that gathers tool calls with asyncio and returns every result in one message, with call counts for both settings.
Steps
- Run the starter and see three tool calls arrive in one turn.
- Run them together with asyncio.gather.
- Send all three tool_result blocks in one user message.
- Run again with disable_parallel_tool_use and compare the calls per turn.
Done when
- With parallel use, one turn carries 3 calls.
- With it off, each turn carries 1 call.
- The comparison line shows 1 vs 3 turns.
Open in the Playground No API key needed.
Starter code (Python)
# Run parallel tool calls together, then compare with parallel use turned off.
import asyncio
import json
import anthropic
client = anthropic.Anthropic()
WEATHER = {"Lisbon": (19, "sunny"), "Paris": (12, "cloudy"), "Tokyo": (16, "light rain")}
tools = [{
"name": "get_weather",
"description": "Current weather for one city: temperature in Celsius and conditions. Use when asked about the weather now.",
"input_schema": {"type": "object", "properties": {"city": {"type": "string", "description": "City name, e.g. Paris"}}, "required": ["city"]},
}]
async def get_weather(city):
await asyncio.sleep(0.05) # pretend network call
t, c = WEATHER[city]
return json.dumps({"temp_c": t, "conditions": c})
async def run(tool_choice):
messages = [{"role": "user", "content": "What's the weather in Lisbon, Paris and Tokyo?"}]
calls_per_turn = []
for _ in range(8):
r = client.messages.create(model="claude-sonnet-5-5", max_tokens=500, tools=tools, tool_choice=tool_choice, messages=messages)
messages.append({"role": "assistant", "content": r.content})
if r.stop_reason != "tool_use":
return calls_per_turn
uses = [b for b in r.content if b.type == "tool_use"]
calls_per_turn.append(len(uses))
# TODO: run every get_weather call together with asyncio.gather
# TODO: send all the tool_result blocks back in ONE user message, matched by tool_use_id
return calls_per_turn # TODO: remove once results go back
return calls_per_turn
par = asyncio.run(run({"type": "auto"}))
print("parallel: tool calls per turn", par)
# TODO: run again with {"type": "auto", "disable_parallel_tool_use": True} and compare
Show a solution
# Run parallel tool calls together, then compare with parallel use turned off.
import asyncio
import json
import anthropic
client = anthropic.Anthropic()
WEATHER = {"Lisbon": (19, "sunny"), "Paris": (12, "cloudy"), "Tokyo": (16, "light rain")}
tools = [{
"name": "get_weather",
"description": "Current weather for one city: temperature in Celsius and conditions. Use when asked about the weather now.",
"input_schema": {"type": "object", "properties": {"city": {"type": "string", "description": "City name, e.g. Paris"}}, "required": ["city"]},
}]
async def get_weather(city):
await asyncio.sleep(0.05) # pretend network call
t, c = WEATHER[city]
return json.dumps({"temp_c": t, "conditions": c})
async def run(tool_choice):
messages = [{"role": "user", "content": "What's the weather in Lisbon, Paris and Tokyo?"}]
calls_per_turn = []
for _ in range(8):
r = client.messages.create(model="claude-sonnet-5-5", max_tokens=500, tools=tools, tool_choice=tool_choice, messages=messages)
messages.append({"role": "assistant", "content": r.content})
if r.stop_reason != "tool_use":
return calls_per_turn
uses = [b for b in r.content if b.type == "tool_use"]
calls_per_turn.append(len(uses))
outputs = await asyncio.gather(*(get_weather(b.input["city"]) for b in uses)) # run together
messages.append({"role": "user", "content": [
{"type": "tool_result", "tool_use_id": b.id, "content": out} for b, out in zip(uses, outputs)
]}) # every result in ONE user message
return calls_per_turn
par = asyncio.run(run({"type": "auto"}))
seq = asyncio.run(run({"type": "auto", "disable_parallel_tool_use": True}))
print("parallel: tool calls per turn", par)
print("parallel off: tool calls per turn", seq)
print(f"model turns that asked for tools: {len(par)} vs {len(seq)}")
Do it Run a parallel tool call in the Playground. No API key needed.