# Class GoalOrientedPlanner

java.lang.Object
com.google.adk.planner.goap.GoalOrientedPlanner

All Implemented Interfaces:
  `Planner`

public final class GoalOrientedPlanner extends Object implements Planner
A planner that resolves agent execution order based on input/output dependencies and a target goal (output key).

Given agent metadata declaring what each agent reads (inputKeys) and writes (outputKey), this planner uses backward-chaining dependency resolution to compute the execution path from initial preconditions to the goal.

Example:

      Agent A: inputs=[], output="person"
      Agent B: inputs=[], output="sign"
      Agent C: inputs=["person", "sign"], output="horoscope"
      Agent D: inputs=["person", "horoscope"], output="writeup"
      Goal: "writeup"

      Resolved groups: [A, B] → [C] → [D]
      (A and B are independent and run in parallel)

Supports configurable failure handling via `ReplanPolicy`:

- `ReplanPolicy.Ignore` — proceed regardless of missing outputs (default)
- `ReplanPolicy.FailStop` — halt on first missing output
- `ReplanPolicy.Replan` — recompute the remaining plan from current world state

Supports pluggable search strategies via `SearchStrategy`: backward-chaining DFS (`DfsSearchStrategy`) or forward A* (`AStarSearchStrategy`).

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `GoalOrientedPlanner(String goal, List<AgentMetadata> metadata)`
  `GoalOrientedPlanner(String goal, List<AgentMetadata> metadata, boolean validateOutputs)`
  `GoalOrientedPlanner(String goal, List<AgentMetadata> metadata, SearchStrategy searchStrategy, ReplanPolicy replanPolicy)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `io.reactivex.rxjava3.core.Single<PlannerAction>`
  `firstAction(PlanningContext context)`
  Select the first action to execute.
  `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.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### GoalOrientedPlanner

    public GoalOrientedPlanner(String goal, List<AgentMetadata> metadata)

  - ### GoalOrientedPlanner

    public GoalOrientedPlanner(String goal, List<AgentMetadata> metadata, boolean validateOutputs)

  - ### GoalOrientedPlanner

    public GoalOrientedPlanner(String goal, List<AgentMetadata> metadata, SearchStrategy searchStrategy, ReplanPolicy replanPolicy)

- ## Method Details

  - ### init

    public void init(PlanningContext context)
    Description copied from interface: `Planner`
    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.

    Specified by:
      `init` in interface `Planner`

  - ### firstAction

    public io.reactivex.rxjava3.core.Single<PlannerAction> firstAction(PlanningContext context)
    Description copied from interface: `Planner`
    Select the first action to execute.
    Specified by:
      `firstAction` in interface `Planner`

  - ### nextAction

    public io.reactivex.rxjava3.core.Single<PlannerAction> nextAction(PlanningContext context)
    Description copied from interface: `Planner`
    Select the next action based on updated state and events.
    Specified by:
      `nextAction` in interface `Planner`