Skip to content

Multi-Agent setting - parallel agent not executing in parallel with this configuration #1051

@jruokola

Description

@jruokola

With a configuration like this the parallel agent seems to execute in sequence (at least based on gathered events and timestamps) captured by logging. Does the runner need to be using async for event in async_run() and in streaming mode for parallel orchestration to work as expected? Or is this a result of behaviour on using data_collector_agent outputs from shared context as inputs to the parallel agents and it's caused by lock behaviour causing parallels not being able to read context at the same time?

parallel_executor = ParallelAgent(
    name="parallel_executor",
    description="Runs all specialized analysis agents in parallel on the collected data.",
    sub_agents=[
        data_user_agent_1,
        data_user_agent_2,
        data_user_agent_3,
        data_user_agent_4,
        data_user_agent_5,
    ],
)  

sequential_orchestrator = SequentialAgent(
    name="sequential_orchestrator",
    description="Orchestrates the full agent pipeline using specialized persona agents.",
    sub_agents=[
        data_collector_agent,
        parallel_executor,
        final_response_synthetizer,
    ],
)

session_service = InMemorySessionService()
runner = Runner(
    app_name="multi-agent-configuration",
    agent=sequential_orchestrator,
    session_service=session_service,
)

run_config = RunConfig(
    streaming_mode=StreamingMode.SSE,
    support_cfc=True,
    max_llm_calls=500,
)

message_content = types.Content(parts=[types.Part(text=args.input)])

try:
    events = runner.run(
        user_id="cli_user",
        session_id="cli_session",
        new_message=message_content,
        run_config=run_config,
    )

    outputs = []
    for event in events:
        outputs.append(event)
        logger.debug(f"Event type: {type(event)}, Event: {event}")

    if outputs:
        final_event = outputs[-1]
        logger.info(f"Final event type: {type(final_event)}")
        logger.info(f"Pipeline completed. Final result: {final_event}")
    else:
        logger.warning("No events received from the agent pipeline.")

except Exception as e:
    logger.error(f"Error running agent pipeline: {e}")
    raise

OsX newest
adk-python 1.1.0
Python 3.12

Metadata

Metadata

Assignees

Labels

core[Component] This issue is related to the core interface and implementation

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions