langchain · difficulty ◆◆
Parallel Tool Calls & Provider Strategy
Parallel calls that also respect your caching hints.
Parallel tool calls that also respect your cache headers.
$ bind_tools(..., parallel_tool_calls=True)What it does
parallel_tool_calls is surfaced on bind_tools for the OpenRouter integration. Under the hood it sets the appropriate OpenRouter API flag so the model decides whether to call tools in parallel. Your code receives tool calls as a batch, and the test in this release (PR #38215) covers cache_control passthrough so parallel calls also respect caching hints.
Why it matters
Branching decisions, like looking up account status and product inventory at once, previously forced serialized calls or manual orchestration. With parallel_tool_calls=True the model decides when to parallelize, and LangChain collects results cleanly — powerful for supervisor agents delegating to multiple tools in one round.
Example
$ model = ChatOpenRouter(model="anthropic/claude-3.5-sonnet", openrouter_api_key="<your-key>", parallel_tool_calls=True)
bound = model.bind_tools([get_weather, get_time], parallel_tool_calls=True)
resp = bound.invoke([HumanMessage(content="Weather in Paris and time in London?")])
print(f"Tool calls: {len(resp.tool_calls)}")
for tc in resp.tool_calls:
print(f" Tool: {tc['name']} | Args: {tc['args']}")Number of tool calls: 2
Tool: get_weather | Args: {'city': 'Paris'}
Tool: get_time | Args: {'timezone': 'London'}Common flags
- ProviderStrategy
- Strategy class that routes to provider-specific model behaviors
- cache_control passthrough
- Ensures parallel tool calls also respect HTTP cache-control headers
- ToolCall
- Structured representation of a tool invocation returned by the model
History
ProviderStrategy bug fix
langchain==1.3.11 contained a notable fix: strict=True was being applied to tools for all providers, not just OpenAI. On OpenAI-compatible providers like OpenRouter and Azure this caused valid tool calls to be rejected. PR #38370 corrected the ProviderStrategy routing.
Fun facts
Pros & cons
pros
- + Parallel calls with cache hints
- + Clean batch results
- + ProviderStrategy fix for non-OpenAI
cons
- − Behavior is model-dependent
- − Needs recent langchain-core
Takeaways
- 1parallel_tool_calls pairs with cache_control passthrough.
- 2strict=True no longer leaks to every provider after 1.3.11.
- 3ProviderStrategy routes behavior per provider.