langgoap.GoapExecutor

langgoap.GoapExecutor#

class GoapExecutor(*, tracer=None, guards=None, transition_model=None, rng=None, actions=None, history_state='full', sensors=None, effects='declared', always_observe=())[source]#

LangGraph node that executes the current action in the plan.

Runs plan.actions[current_step], updates world_state with the action’s effects, and appends to execution_history.

Both sync (__call__()) and async (acall()) paths share the same pre-condition checks, result building, and failure handling via the module-level helpers _prepare_execution(), _apply_result(), _build_success(), and _build_failure().

Parameters:
  • tracer (PlanningTracer | None) – Optional PlanningTracer invoked around each action execution.

  • guards (list[ActionGuard | AsyncActionGuard] | None) – Optional list of ActionGuard or AsyncActionGuard objects evaluated before each action executes. A WARN-severity failure is logged but execution continues. A BLOCK-severity failure aborts the action and immediately blacklists it (equivalent to max_retries + 1 failures), triggering replanning via the observer.

  • transition_model (TransitionModel | None) – Optional TransitionModel that drives runtime effects when an action’s execute callable returns None (or is absent). Dict returns from execute remain authoritative. Pair with a seeded rng for reproducible stochastic rollouts.

  • rng (random.Random | None) – Optional random.Random forwarded to transition_model.sample. When omitted, a single random.Random() is created at construction time and reused for every action — callers who want true reproducibility should pass a seeded instance. QoS back-off jitter uses a separate, unseeded stream, so retries never perturb the sampled effects.

  • history_state (HistoryState) – What each ActionResult keeps of the world state: "full" (default) both complete snapshots, "delta" only the keys the action changed with their prior values, or "planning" only planning-relevant keys. Bounds checkpoint growth with rich world states (issue #74); the realised cost is recorded separately, so accounting is unaffected.

  • sensors (list[Sensor | AsyncSensor] | None) – The graph’s sensors, asked after an action when effects="observed" and by every wait (issue #96).

  • effects (str) – "declared" (default) believes a returned dict, else the declared effects. "merged" applies the declared effects and merges a returned dict on top. "observed" does the same, then lets the sensors overrule them for the action’s keys.

  • always_observe (Iterable[str]) – State keys read from the sensors after every action, besides each action’s effect keys and ActionSpec.observe.

  • actions (list[ActionSpec] | None)

__init__(*, tracer=None, guards=None, transition_model=None, rng=None, actions=None, history_state='full', sensors=None, effects='declared', always_observe=())[source]#
Parameters:
Return type:

None

Methods

__init__(*[, tracer, guards, ...])

acall(state)

Async variant of the executor node.