Repository navigation
ParallelAgent works with LLMAgent but not with custom agents — is additional setup needed? #2277
|
I'm working with the ADK Agents and have encountered an issue when using ParallelAgent with custom agents. Context: When running, I notice that these agents are executed sequentially(one after the other), not in parallel as expected. However, if I replace the custom agents with LLMAgent instances, the parallel execution works as intended — the LLM calls are dispatched concurrently. Questions: Is there any additional configuration or specific interface/behavior required for custom agents to be compatible with ParallelAgent and actually run in parallel? parallel agent code : parallel_extraction_agent = ParallelAgent( |
Replies: 1 comment
|
Check the implementation of each custom agent's For blocking I/O, use an async client and import asyncio
# Inside your custom agent's async _run_async_impl:
result = await asyncio.to_thread(blocking_extract, document)
# Yield your normal ADK Event containing the result here.
There is no extra |
ParallelAgentalso supports customBaseAgentsubclasses. It runs their async event streams concurrently; it does not automatically move synchronous work into separate threads.Check the implementation of each custom agent's
_run_async_impl. A synchronous HTTP request,time.sleep(), or a long computation inside that method blocks the shared event loop, even though the method is declaredasync.For blocking I/O, use an async client and
awaitit, or move the existing synchronous operation to a thread:asynci…