From f7f140457817fe41cbdc46b74694f4d13e3f33ca Mon Sep 17 00:00:00 2001 From: Justin Skywork Date: Mon, 23 Mar 2026 20:03:36 -0400 Subject: [PATCH] feat: implement ParallelToolExecutor for concurrent tool calling #4429 --- .../agent_framework/tools/parallel/executor.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 python/packages/agent-framework/src/agent_framework/tools/parallel/executor.py diff --git a/python/packages/agent-framework/src/agent_framework/tools/parallel/executor.py b/python/packages/agent-framework/src/agent_framework/tools/parallel/executor.py new file mode 100644 index 0000000000..24d591b285 --- /dev/null +++ b/python/packages/agent-framework/src/agent_framework/tools/parallel/executor.py @@ -0,0 +1,17 @@ +import asyncio +from typing import List, Any, Callable + +class ParallelToolExecutor: + """ + Executor for parallel tool calls in agentic workflows. + Significantly reduces latency for multi-tool operations. + """ + def __init__(self, max_concurrency: int = 5): + self.semaphore = asyncio.Semaphore(max_concurrency) + + async def execute_parallel(self, tool_calls: List[Callable[[], Any]]) -> List[Any]: + async def _run_tool(call): + async with self.semaphore: + return await asyncio.to_thread(call) + + return await asyncio.gather(*[_run_tool(call) for call in tool_calls])