Class BlackboardPlanner
java.lang.Object
dev.langchain4j.agentic.patterns.blackboard.BlackboardPlanner
- All Implemented Interfaces:
Planner
A blackboard planner that activates agents based on data availability in the shared scope.
Agents are knowledge sources that post partial results to the AgenticScope (the blackboard).
After each agent completes, the planner inspects the blackboard and activates whichever single agent
can contribute next. When multiple agents are ready, a ConflictResolutionStrategy determines
which one fires; if no strategy is provided, declaration order is used.
The planner terminates when:
- The goal predicate is satisfied (by default, when the planner's outputKey is present in scope)
- No agent can fire (quiescence)
- The maximum number of invocations is reached
-
Constructor Summary
ConstructorsConstructorDescriptionBlackboardPlanner(ConflictResolutionStrategy conflictResolutionStrategy) BlackboardPlanner(Predicate<AgenticScope> goalPredicate) BlackboardPlanner(Predicate<AgenticScope> goalPredicate, int maxInvocations) BlackboardPlanner(Predicate<AgenticScope> goalPredicate, int maxInvocations, ConflictResolutionStrategy conflictResolutionStrategy) BlackboardPlanner(Predicate<AgenticScope> goalPredicate, ConflictResolutionStrategy conflictResolutionStrategy) -
Method Summary
Modifier and TypeMethodDescriptionReturns the planner's current execution state as a map of serializable values.firstAction(PlanningContext planningContext) voidinit(InitPlanningContext initPlanningContext) nextAction(PlanningContext planningContext) voidrestoreExecutionState(Map<String, Object> state) Restores the planner's execution state from a previously saved map.topology()
-
Constructor Details
-
BlackboardPlanner
public BlackboardPlanner() -
BlackboardPlanner
-
BlackboardPlanner
-
BlackboardPlanner
-
BlackboardPlanner
public BlackboardPlanner(Predicate<AgenticScope> goalPredicate, ConflictResolutionStrategy conflictResolutionStrategy) -
BlackboardPlanner
public BlackboardPlanner(Predicate<AgenticScope> goalPredicate, int maxInvocations, ConflictResolutionStrategy conflictResolutionStrategy)
-
-
Method Details
-
init
-
firstAction
- Specified by:
firstActionin interfacePlanner
-
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
-
topology
-