Package com.google.adk.agents
Class PlannerAgent
java.lang.Object
com.google.adk.workflow.BaseNode
com.google.adk.agents.BaseAgent
com.google.adk.agents.PlannerAgent
- All Implemented Interfaces:
Node
An agent that delegates execution planning to a
Planner strategy.
The PlannerAgent owns a set of sub-agents and a planner. At runtime, the planner
inspects session state and decides which sub-agent(s) to run next. This enables dynamic,
goal-oriented agent orchestration — the execution topology is determined at runtime rather than
being fixed at build time.
The planning loop:
- Planner is initialized with context and available agents
- Planner returns what to do next via
PlannerAction - Selected sub-agent(s) execute, producing events
- Session state (world state) is updated from events
- Planner sees updated state and decides the next action
- Repeat until
PlannerAction.Doneor maxIterations
Example usage with a custom planner:
PlannerAgent agent = PlannerAgent.builder()
.name("myAgent")
.subAgents(agentA, agentB, agentC)
.planner(new GoalOrientedPlanner("finalOutput", metadata))
.maxIterations(20)
.build();
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic PlannerAgent.Builderbuilder()Returns a newPlannerAgent.Builderfor creatingPlannerAgentinstances.intReturns the maximum number of planning iterations.planner()Returns the planner strategy used by this agent.protected io.reactivex.rxjava3.core.Flowable<Event>runAsyncImpl(InvocationContext invocationContext) Agent-specific asynchronous logic.protected io.reactivex.rxjava3.core.Flowable<Event>runLiveImpl(InvocationContext invocationContext) Agent-specific synchronous logic.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
-
planner
Returns the planner strategy used by this agent. -
maxIterations
public int maxIterations()Returns the maximum number of planning iterations. -
runAsyncImpl
protected io.reactivex.rxjava3.core.Flowable<Event> runAsyncImpl(InvocationContext invocationContext) Description copied from class:BaseAgentAgent-specific asynchronous logic.- Specified by:
runAsyncImplin classBaseAgent- Parameters:
invocationContext- Current invocation context.- Returns:
- stream of agent-generated events.
-
runLiveImpl
protected io.reactivex.rxjava3.core.Flowable<Event> runLiveImpl(InvocationContext invocationContext) Description copied from class:BaseAgentAgent-specific synchronous logic.- Specified by:
runLiveImplin classBaseAgent- Parameters:
invocationContext- Current invocation context.- Returns:
- stream of agent-generated events.
-
builder
Returns a newPlannerAgent.Builderfor creatingPlannerAgentinstances.
-