langchain · difficulty ◆◆
Parallel Tool Calls via bind_tools
Assistant → Tool A + Tool B → Assistant.
Two independent tools, one response, zero waiting in line.
$ model.bind_tools([tool_a, tool_b], parallel_tool_calls=True)What it does
bind_tools on a LangChain OpenRouter chat model surfaces parallel_tool_calls, letting the model request multiple tool calls in a single response turn. The provider records the preference and the model can return two or more ToolCall chunks simultaneously instead of forcing a strict sequential back-and-forth.
Why it matters
If your agent needs a calculator and a date lookup in one step, parallel_tool_calls removes the round-trip tax. Instead of Assistant → Tool A → Assistant → Tool B → Assistant, you get Assistant → Tool A + Tool B → Assistant. This is especially valuable for independent tools and mirrors how frontier models handle concurrent tool use.
Example
$ model = ChatOpenRouter(model="openrouter/anthropic/claude-3-haiku", api_key="your-openrouter-api-key")
bound = model.bind_tools([get_weather, get_time], parallel_tool_calls=True)
resp = bound.invoke("What's the weather and current time in Vienna?")
print("Tool calls:", resp.tool_calls)Tool calls: [
{'name': 'get_weather', 'args': {'city': 'Vienna'}, 'id': '...'},
{'name': 'get_time', 'args': {'city': 'Vienna'}, 'id': '...'}
]Both tool calls appear in a single response object — no sequential invocation needed.
Common flags
- ChatOpenRouter.bind_tools
- Binds tools to the chat model, with parallel_tool_calls option
- BaseTool.invoke
- Synchronous tool execution for @tool decorated functions
- strict=True
- Enforces JSON-schema strictness for tool args
History
Picking up the prior release
The latest release, langchain-openrouter==0.2.5, contained only bug fixes like deduplicating repeated finish metadata and stripping Responses reasoning IDs. This tutorial picks up the most impactful feature from 0.2.4: parallel_tool_calls.
Fun facts
Pros & cons
pros
- + Removes round-trip tax
- + Independent tools run together
- + Mirrors frontier model behavior
cons
- − Behavior varies by model
- − Needs langchain-openrouter 0.2.4+
Takeaways
- 1parallel_tool_calls collapses two round-trips into one.
- 2Only truly independent tools should parallelize.
- 3Toggle it off to compare against sequential behavior.