# Class SequentialAgent

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

public class SequentialAgent extends BaseAgent
An agent that runs its sub-agents sequentially.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `static class`
  `SequentialAgent.Builder`
  Builder for `SequentialAgent`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static SequentialAgent.Builder`
  `builder()`
  `static SequentialAgent`
  `fromConfig(SequentialAgentConfig config, String configAbsPath)`
  Creates a SequentialAgent from configuration.
  `protected io.reactivex.rxjava3.core.Flowable<Event>`
  `runAsyncImpl(InvocationContext invocationContext)`
  Runs sub-agents sequentially.
  `protected io.reactivex.rxjava3.core.Flowable<Event>`
  `runLiveImpl(InvocationContext invocationContext)`
  Runs sub-agents sequentially in live mode.

  ### Methods inherited from class BaseAgent

  `afterAgentCallback, beforeAgentCallback, canonicalAfterAgentCallbacks, canonicalBeforeAgentCallbacks, close, description, findAgent, findSubAgent, fromConfig, name, parentAgent, parentAgent, rootAgent, runAsync, runLive, subAgents, toolOrigin`
  Modifier and Type
  Method
  Description
  `com.google.common.collect.ImmutableList<? extends Callbacks.AfterAgentCallback>`
  `afterAgentCallback()`
  `com.google.common.collect.ImmutableList<? extends Callbacks.BeforeAgentCallback>`
  `beforeAgentCallback()`
  `com.google.common.collect.ImmutableList<? extends Callbacks.AfterAgentCallback>`
  `canonicalAfterAgentCallbacks()`
  The resolved afterAgentCallback field as a list.
  `com.google.common.collect.ImmutableList<? extends Callbacks.BeforeAgentCallback>`
  `canonicalBeforeAgentCallbacks()`
  The resolved beforeAgentCallback field as a list.
  `io.reactivex.rxjava3.core.Completable`
  `close()`
  Closes all sub-agents.
  `final String`
  `description()`
  Gets the one-line description of the agent's capability.
  `Optional<BaseAgent>`
  `findAgent(String name)`
  Finds an agent (this or descendant) by name.
  `Optional<BaseAgent>`
  `findSubAgent(String name)`
  Recursively search sub agent by name.
  `static BaseAgent`
  `fromConfig(BaseAgentConfig config, String configAbsPath)`
  Creates a new agent instance from a configuration object.
  `final String`
  `name()`
  Gets the agent's unique name.
  `BaseAgent`
  `parentAgent()`
  Retrieves the parent agent in the agent tree.
  `protected void`
  `parentAgent(BaseAgent parentAgent)`
  Sets the parent agent.
  `BaseAgent`
  `rootAgent()`
  Returns the root agent for this agent by traversing up the parent chain.
  `io.reactivex.rxjava3.core.Flowable<Event>`
  `runAsync(InvocationContext parentContext)`
  Runs the agent asynchronously.
  `io.reactivex.rxjava3.core.Flowable<Event>`
  `runLive(InvocationContext parentContext)`
  Runs the agent synchronously.
  `List<? extends BaseAgent>`
  `subAgents()`
  `AgentEnums.AgentOrigin`
  `toolOrigin()`
  Returns the origin of the tool when this agent is used as a tool.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### builder

    public static SequentialAgent.Builder builder()

  - ### runAsyncImpl

    protected io.reactivex.rxjava3.core.Flowable<Event> runAsyncImpl(InvocationContext invocationContext)
    Runs sub-agents sequentially.
    Specified by:
      `runAsyncImpl` in class `BaseAgent`
    Parameters:
      `invocationContext` - Invocation context.
    Returns:
      Flowable emitting events from sub-agents.

  - ### runLiveImpl

    protected io.reactivex.rxjava3.core.Flowable<Event> runLiveImpl(InvocationContext invocationContext)
    Runs sub-agents sequentially in live mode.
    Specified by:
      `runLiveImpl` in class `BaseAgent`
    Parameters:
      `invocationContext` - Invocation context.
    Returns:
      Flowable emitting events from sub-agents in live mode.

  - ### fromConfig

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