Class SupervisorPlanner
java.lang.Object
dev.langchain4j.agentic.supervisor.SupervisorPlanner
- All Implemented Interfaces:
ChatMemoryAccessProvider, Planner
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionSupervisorPlanner(ChatModel chatModel, ChatMemoryProvider chatMemoryProvider, int maxAgentsInvocations, SupervisorContextStrategy contextStrategy, SupervisorResponseStrategy responseStrategy, Function<AgenticScope, String> requestGenerator, String outputKey, Function<AgenticScope, Object> output) -
Method Summary
Modifier and TypeMethodDescriptionchatMemoryAccess(AgenticScope agenticScope) Returns the planner's current execution state as a map of serializable values.voidinit(InitPlanningContext initPlanningContext) nextAction(PlanningContext planningContext) voidrestoreExecutionState(Map<String, Object> state) Restores the planner's execution state from a previously saved map.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, firstAction, noOp, terminated, topology
-
Field Details
-
SUPERVISOR_CONTEXT_KEY
- See Also:
-
SUPERVISOR_CONTEXT_PREFIX
- See Also:
-
-
Constructor Details
-
SupervisorPlanner
public SupervisorPlanner(ChatModel chatModel, ChatMemoryProvider chatMemoryProvider, int maxAgentsInvocations, SupervisorContextStrategy contextStrategy, SupervisorResponseStrategy responseStrategy, Function<AgenticScope, String> requestGenerator, String outputKey, Function<AgenticScope, Object> output)
-
-
Method Details
-
init
-
nextAction
- Specified by:
nextActionin interfacePlanner
-
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
-
chatMemoryAccess
- Specified by:
chatMemoryAccessin interfaceChatMemoryAccessProvider
-