Package com.google.adk.agents
Class SequentialAgent
java.lang.Object
com.google.adk.workflow.BaseNode
com.google.adk.agents.BaseAgent
com.google.adk.agents.SequentialAgent
- All Implemented Interfaces:
Node
An agent that runs its sub-agents sequentially.
Composition with LlmAgents: a SequentialAgent does not transfer control
back to a parent LlmAgent. Use it as the root or transferred-to agent and place any
follow-up LlmAgent as the next sibling. Upstream publishes via outputKey and
downstream reads via {key} placeholders in its instruction:
var draft =
LlmAgent.builder()
.name("draft")
.model("gemini-flash-latest")
.instruction("Draft a summary.")
.outputKey("draft")
.build();
var reviewer =
LlmAgent.builder()
.name("reviewer")
.model("gemini-flash-latest")
.instruction("Polish the draft: {draft}")
.build();
var pipeline =
SequentialAgent.builder().name("pipeline").subAgents(draft, reviewer).build();
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic SequentialAgent.Builderbuilder()static SequentialAgentfromConfig(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 com.google.adk.agents.BaseAgent
afterAgentCallback, beforeAgentCallback, canonicalAfterAgentCallbacks, canonicalBeforeAgentCallbacks, close, findAgent, findSubAgent, fromConfig, parentAgent, parentAgent, rootAgent, runAsync, runLive, runNode, subAgents, toolOriginMethods inherited from class com.google.adk.workflow.BaseNode
config, description, inputSchema, name, outputSchema, rerunOnResume, stateSchema, waitForOutputMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.google.adk.workflow.Node
requiresAllPredecessors
-
Method Details
-
builder
-
runAsyncImpl
protected io.reactivex.rxjava3.core.Flowable<Event> runAsyncImpl(InvocationContext invocationContext) Runs sub-agents sequentially.Three modes: with resumability on, a resume fast-forwards to the checkpointed sub-agent and pauses on a long-running call; with the deprecated shim on, the same happens but the resume point is reconstructed from history and nothing is checkpointed; with neither, sub-agents just run in order.
- Specified by:
runAsyncImplin classBaseAgent- 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:
runLiveImplin classBaseAgent- 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 configurationconfigAbsPath- The absolute path to the agent config file.- Returns:
- the configured SequentialAgent
- Throws:
ConfigAgentUtils.ConfigurationException- if the configuration is invalid
-