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
PlanningTracerinvoked on terminal states (on_goal_achieved/on_plan_failed). Known limitation (v0.1.0): mid-runMultiGoalsub-goal completions do not emit tracer events — the tracer stays silent until the wholeMultiGoalterminates. A futureon_subgoal_achievedhook is out of scope for v0.1.0.history (StoreExecutionHistory | None) – Optional
StoreExecutionHistorythat records oneExecutionRecordper terminal state so downstream analytics can query past runs by goal or by failing action. ForMultiGoalruns 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:
actions (list[ActionSpec] | None)
tracer (PlanningTracer | None)
history (StoreExecutionHistory | None)
termination_policies (list[TerminationPolicy] | None)
- Return type:
None
Methods
__init__([actions, tracer, history, ...])acall(state)Async variant — mirrors
__call__()but fires async hooks.