Class GoalOrientedPlanner
java.lang.Object
dev.langchain4j.agentic.patterns.goap.GoalOrientedPlanner
- All Implemented Interfaces:
Planner
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfirstAction(PlanningContext planningContext) Returns the first action to execute when the planner starts (or resumes).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) GoalOrientedPlanner does not persist execution state becausefirstAction(PlanningContext)recomputes the path from the current scope state via graph search.topology()Returns the topology of the agentic system managed by this planner.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Planner
as, call, call, done, done, executionState, noOp, suspend, terminated
-
Constructor Details
-
GoalOrientedPlanner
public GoalOrientedPlanner()
-
-
Method Details
-
init
-
firstAction
Description copied from interface:PlannerReturns the first action to execute when the planner starts (or resumes). Defaults to delegating toPlanner.nextAction(PlanningContext).- Specified by:
firstActionin interfacePlanner- Parameters:
planningContext- the current planning context- Returns:
- the first action to execute
-
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
-
restoreExecutionState
GoalOrientedPlanner does not persist execution state becausefirstAction(PlanningContext)recomputes the path from the current scope state via graph search. On recovery, completed agents' outputs are already in scope, so the search produces a shorter path containing only the remaining agents. The cursor resets to 0 naturally, making state persistence unnecessary and potentially harmful (a stale cursor could point beyond the bounds of the recomputed path).- Specified by:
restoreExecutionStatein interfacePlanner- Parameters:
state- the previously saved execution state
-
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)
-