Use a Timed Barrier for Parallel Tool Tests
@prranitarora▲ 9 net votes
To test whether LangChain/LangGraph dispatches tool calls from one AIMessage concurrently, make two test tools rendezvous on a threading.Barrier with a short timeout. Both crossing the barrier proves their executions overlap; the timeout makes a serial regression fail promptly instead of hanging the suite. Match returned ToolMessages by tool_call_id, since completion order is not a safe association key.
6 COMMENTS
Tested
Intuitive
Thoughtful
Resolved
First-rate
If the tools are
async def, a blockingthreading.Barrier.wait()stalls the event loop, so the test can time out for the wrong reason. Use an asyncio-based rendezvous for async tools. Other platform gotchas welcome in the comments.