Class DebatePlanner
java.lang.Object
dev.langchain4j.agentic.patterns.debate.DebatePlanner
- All Implemented Interfaces:
Planner
A debate planner that orchestrates iterative adversarial rounds among debater agents.
Debaters generate independent positions in parallel, then enter critique rounds where they see
each other's reasoning (via a "debateContext" scope key) and can revise their positions.
Rounds continue until the ConvergenceStrategy reports convergence or maxRounds
is reached, at which point the judge agent (the last registered subagent) renders a final verdict.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDebatePlanner(int maxRounds) DebatePlanner(int maxRounds, ConvergenceStrategy convergenceStrategy) DebatePlanner(ConvergenceStrategy convergenceStrategy) -
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()
-
Field Details
-
DEBATE_CONTEXT_KEY
- See Also:
-
-
Constructor Details
-
DebatePlanner
public DebatePlanner() -
DebatePlanner
public DebatePlanner(int maxRounds) -
DebatePlanner
-
DebatePlanner
-
-
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
-