Skip to content

ParallelAgent executes sub-agents sequentially instead of concurrently #903

@fedorovychh

Description

@fedorovychh

The Bug
Despite its name, ParallelAgent executes its sub-agents sequentially on a single thread rather than in parallel. This defeats the purpose of using a parallel agent, as total execution time equals the sum of all individual agent execution times rather than the longest single execution time.

To Reproduce

  1. Configure a ParallelAgent with multiple sub-agents.
  2. Trigger the agent execution using Runner.runAsync(...) and subscribe to the resulting Flowable.
  3. Observe the logs or execution times: the sub-agents process their requests one after the other, not simultaneously.

Root Cause Analysis
The bug is located in ParallelAgent.java inside the runAsyncImpl method.

  • The method maps over currentSubAgents and calls runAsync on each to create a list of Flowable<Event> streams.
  • It then passes this list directly into Flowable.merge(...).
  • Because it does not explicitly apply a concurrent scheduler (such as .subscribeOn(Schedulers.io())) to the individual sub-agent flows before merging them, RxJava defaults to executing the merged "cold" streams sequentially on the caller's thread.

Expected behavior
ParallelAgent should internally handle thread scheduling for its sub-agents (e.g., dispatching them to an I/O thread pool before the merge step) so that Flowable.merge() can actually process their streams concurrently.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions