Class SequentialPlanner
java.lang.Object
dev.langchain4j.agentic.workflow.impl.SequentialPlanner
- All Implemented Interfaces:
Planner
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the planner's current execution state as a map of serializable values.voidinit(InitPlanningContext initPlanningContext) nextAction(PlanningContext planningContext) Determines the next action to execute based on the result of the previous agent invocation.voidrestoreExecutionState(Map<String, Object> state) Restores the planner's execution state from a previously saved map.booleanReturnstrueif the planner has reached a terminal state and will not produce further actions.topology()Returns the topology of the agentic system managed by this planner.
-
Constructor Details
-
SequentialPlanner
public SequentialPlanner()
-
-
Method Details
-
init
-
nextAction
Description copied from interface:PlannerDetermines the next action to execute based on the result of the previous agent invocation.- Specified by:
nextActionin interfacePlanner- Parameters:
planningContext- the current planning context, including the previous agent's result- Returns:
- the next action to execute
-
topology
Description copied from interface:PlannerReturns the topology of the agentic system managed by this planner.- Specified by:
topologyin interfacePlanner- Returns:
- the topology (defaults to
AgenticSystemTopology.SEQUENCE)
-
terminated
public boolean terminated()Description copied from interface:PlannerReturnstrueif the planner has reached a terminal state and will not produce further actions.- Specified by:
terminatedin interfacePlanner- Returns:
trueif the planner is terminated
-
executionState
Description copied from interface:PlannerReturns the planner's current execution state as a map of serializable values. This state is persisted to theAgenticScopeafter each agent invocation, enabling the planner to resume from the correct position after a crash.The returned state must be such that, when passed to
Planner.restoreExecutionState(Map)andPlanner.firstAction(PlanningContext)is called, the planner produces the correct resume action.Stateless planners (e.g., parallel, conditional) can use the default empty implementation.
- Specified by:
executionStatein interfacePlanner- Returns:
- a map of state entries to persist, or an empty map if no state needs saving
-
restoreExecutionState
Description copied from interface:PlannerRestores the planner's execution state from a previously saved map. Called by the execution loop beforePlanner.firstAction(PlanningContext)when recovering from a persisted scope.- Specified by:
restoreExecutionStatein interfacePlanner- Parameters:
state- the previously saved execution state
-