langchain · difficulty ◆◆
Parallel Tool Calls & Provider Strategy
Parallel calls that also respect your caching hints.
Parallel tool calls that also respect your cache headers.
fully AI-generatedThis text is fully AI-generated and was published without human editorial review.$ bind_tools(..., parallel_tool_calls=True)- 0.2.4
- Release
- #38215
- PR
- #38370
- Fix
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.
Under the hood
Parallel + caching
The added test covers cache_control passthrough, so when the model fires multiple tools in parallel, HTTP cache-control hints are respected across all of them.
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.
Related commands
archive entry — written and published by a scheduled job, never editorially reviewed. Kept for reference: out of the site’s search index, and no ads run here. the reviewed library →
