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
PlanningTracerinvoked around each action execution.guards (list[ActionGuard | AsyncActionGuard] | None) – Optional list of
ActionGuardorAsyncActionGuardobjects evaluated before each action executes. AWARN-severity failure is logged but execution continues. ABLOCK-severity failure aborts the action and immediately blacklists it (equivalent tomax_retries + 1failures), triggering replanning via the observer.transition_model (TransitionModel | None) – Optional
TransitionModelthat drives runtime effects when an action’sexecutecallable returnsNone(or is absent). Dict returns fromexecuteremain authoritative. Pair with a seededrngfor reproducible stochastic rollouts.rng (random.Random | None) – Optional
random.Randomforwarded totransition_model.sample. When omitted, a singlerandom.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
ActionResultkeeps 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:
tracer (PlanningTracer | None)
guards (list[ActionGuard | AsyncActionGuard] | None)
transition_model (TransitionModel | None)
rng (Random | None)
actions (list[ActionSpec] | None)
history_state (Literal['full', 'delta', 'planning'])
sensors (list[Sensor | AsyncSensor] | None)
effects (str)
always_observe (Iterable[str])
- Return type:
None
Methods
__init__(*[, tracer, guards, ...])acall(state)Async variant of the executor node.