Class ParallelAgent

java.lang.Object
com.google.adk.agents.BaseAgent
com.google.adk.agents.ParallelAgent

public class ParallelAgent extends BaseAgent
A shell agent that runs its sub-agents in parallel in isolated manner.

This approach is beneficial for scenarios requiring multiple perspectives or attempts on a single task, such as running different algorithms simultaneously or generating multiple responses for review by a subsequent evaluation agent.

  • Method Details

    • builder

      public static ParallelAgent.Builder builder()
    • fromConfig

      public static ParallelAgent fromConfig(ParallelAgentConfig config, String configAbsPath) throws ConfigAgentUtils.ConfigurationException
      Creates a ParallelAgent from configuration.
      Parameters:
      config - the agent configuration
      configAbsPath - The absolute path to the agent config file.
      Returns:
      the configured ParallelAgent
      Throws:
      ConfigAgentUtils.ConfigurationException - if the configuration is invalid
    • runAsyncImpl

      protected io.reactivex.rxjava3.core.Flowable<Event> runAsyncImpl(InvocationContext invocationContext)
      Runs sub-agents in parallel and emits their events.

      Sets the branch and merges event streams from all sub-agents.

      Specified by:
      runAsyncImpl in class BaseAgent
      Parameters:
      invocationContext - Invocation context.
      Returns:
      Flowable emitting events from all sub-agents.
    • runLiveImpl

      protected io.reactivex.rxjava3.core.Flowable<Event> runLiveImpl(InvocationContext invocationContext)
      Not supported for ParallelAgent.
      Specified by:
      runLiveImpl in class BaseAgent
      Parameters:
      invocationContext - Invocation context.
      Returns:
      Flowable that always throws UnsupportedOperationException.