langgoap.GoapObserver

langgoap.GoapObserver#

class GoapObserver(actions=None, *, tracer=None, history=None, termination_policies=None)[source]#

LangGraph node that decides the next step via Command routing.

After each action execution, the observer checks: 1. Goal achieved → END 2. Action failed → replan 3. EVERY_ACTION replan strategy → replan 4. State deviation from expected → replan 5. More actions remain → continue executing 6. Plan exhausted but goal not met → replan

Parameters:
  • actions (list[ActionSpec] | None) – The available action specs. When provided, deviation detection compares only planning-relevant keys (those appearing in action preconditions/effects and goal conditions) rather than the entire world state. This prevents non-planning data (document lists, LLM responses) from triggering spurious replanning.

  • tracer (PlanningTracer | None) – Optional PlanningTracer invoked on terminal states (on_goal_achieved / on_plan_failed). Known limitation (v0.1.0): mid-run MultiGoal sub-goal completions do not emit tracer events — the tracer stays silent until the whole MultiGoal terminates. A future on_subgoal_achieved hook is out of scope for v0.1.0.

  • history (StoreExecutionHistory | None) – Optional StoreExecutionHistory that records one ExecutionRecord per terminal state so downstream analytics can query past runs by goal or by failing action. For MultiGoal runs the record captures the sub-goal that was active at termination.

  • termination_policies (list[TerminationPolicy] | None)

__init__(actions=None, *, tracer=None, history=None, termination_policies=None)[source]#
Parameters:
Return type:

None

Methods

__init__([actions, tracer, history, ...])

acall(state)

Async variant — mirrors __call__() but fires async hooks.