Class GoalOrientedPlanner

java.lang.Object
dev.langchain4j.agentic.patterns.goap.GoalOrientedPlanner
All Implemented Interfaces:
Planner

public class GoalOrientedPlanner extends Object implements Planner
  • Constructor Details

    • GoalOrientedPlanner

      public GoalOrientedPlanner()
  • Method Details

    • init

      public void init(InitPlanningContext initPlanningContext)
      Specified by:
      init in interface Planner
    • firstAction

      public Action firstAction(PlanningContext planningContext)
      Description copied from interface: Planner
      Returns the first action to execute when the planner starts (or resumes). Defaults to delegating to Planner.nextAction(PlanningContext).
      Specified by:
      firstAction in interface Planner
      Parameters:
      planningContext - the current planning context
      Returns:
      the first action to execute
    • nextAction

      public Action nextAction(PlanningContext planningContext)
      Description copied from interface: Planner
      Determines the next action to execute based on the result of the previous agent invocation.
      Specified by:
      nextAction in interface Planner
      Parameters:
      planningContext - the current planning context, including the previous agent's result
      Returns:
      the next action to execute
    • restoreExecutionState

      public void restoreExecutionState(Map<String,Object> state)
      GoalOrientedPlanner does not persist execution state because firstAction(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:
      restoreExecutionState in interface Planner
      Parameters:
      state - the previously saved execution state
    • topology

      public AgenticSystemTopology topology()
      Description copied from interface: Planner
      Returns the topology of the agentic system managed by this planner.
      Specified by:
      topology in interface Planner
      Returns:
      the topology (defaults to AgenticSystemTopology.SEQUENCE)