# Interface Planner

All Known Implementing Classes:
  `GoalOrientedPlanner, LoopPlanner, P2PPlanner, ParallelPlanner, SequentialPlanner, SupervisorPlanner`

public interface Planner
Strategy interface for planning which sub-agent(s) to execute next.

A `Planner` is used by `PlannerAgent` to dynamically determine execution order at runtime. The planning loop works as follows:

1. `init(PlanningContext)` is called once before the loop starts
2. `firstAction(PlanningContext)` returns the first action to execute
3. The selected agent(s) execute, producing events and updating session state
4. `nextAction(PlanningContext)` is called with updated context to decide what to do next
5. Steps 3-4 repeat until `PlannerAction.Done` or max iterations

Returns `Single``<PlannerAction>` to support both synchronous planners (wrap in `Single.just()`) and asynchronous planners that call an LLM.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `io.reactivex.rxjava3.core.Single<PlannerAction>`
  `firstAction(PlanningContext context)`
  Select the first action to execute.
  `default void`
  `init(PlanningContext context)`
  Initialize the planner with context and available agents.
  `io.reactivex.rxjava3.core.Single<PlannerAction>`
  `nextAction(PlanningContext context)`
  Select the next action based on updated state and events.

- ## Method Details

  - ### init

    default void init(PlanningContext context)
    Initialize the planner with context and available agents. Called once before the planning loop starts.

    Default implementation is a no-op. Override to perform setup like building dependency graphs.

  - ### firstAction

    io.reactivex.rxjava3.core.Single<PlannerAction> firstAction(PlanningContext context)
    Select the first action to execute.

  - ### nextAction

    io.reactivex.rxjava3.core.Single<PlannerAction> nextAction(PlanningContext context)
    Select the next action based on updated state and events.