API Reference#
Every symbol below is re-exported from the top-level langgoap package
(langgoap.__all__) and is the supported public surface. Anything not
listed here is internal and may change without notice. langgoap.__version__
is the installed version string.
This page is generated by docs/generate_api_index.py from the grouping
comments in langgoap/__init__.py; tests/test_docs_api_index.py fails
when the two drift apart.
Package#
Set the log level for all langgoap loggers. |
Actions#
Specification of a GOAP action for planning. |
|
Base class for object-oriented GOAP action definitions. |
|
Decorator that converts a function into an ActionSpec. |
Conditions (three-valued logic + LLM-evaluated conditions)#
Asynchronous condition resolver — duck-typed protocol. |
|
Synchronous condition resolver — duck-typed protocol. |
|
Three-valued truth value for runtime condition resolution. |
|
Wrap a plain callable into a |
|
Resolve a condition key by querying an LLM. |
|
Async variant of |
|
Run all resolvers against keys and return an updated world-state copy. |
Goals#
A resource/budget constraint for CSP optimization. |
|
Specification of a GOAP goal. |
|
Replanning + multi-goal-priority policy for a |
|
A composite goal made up of one or more |
|
An optional goal condition with a utility weight (oversubscription planning). |
Constraint builder#
Tagged bundle returned by |
|
Output of a single terminated builder chain. |
|
Factory and aggregator for |
|
A single in-progress fluent chain. |
Integrations (low-code LangGraph on-ramp)#
Create a compiled GOAP agent from a list of LangChain tools and a goal. |
|
Create a LangChain |
|
Create a |
|
Format a |
|
Wrap a LangChain |
|
A GOAP planner packaged as a reusable sub-graph. |
|
Attach a GOAP sub-graph as a node inside a parent |
|
Emit a deployable LangGraph directory for a LangGOAP agent. |
Interpreter#
Converts natural language requests into GoalSpec objects via LLM. |
|
A resource constraint extracted from natural language. |
|
Structured goal extracted from a natural language request. |
|
An optimization objective extracted from natural language. |
Graph#
Resolve and await the best async callable for action. |
|
Builder that produces a compiled LangGraph for GOAP execution. |
|
LangGraph node that invokes the planner. |
|
LangGraph node that executes the current action in the plan. |
|
LangGraph node that decides the next step via Command routing. |
|
LangGraph node that executes independent plan actions in parallel. |
|
The GOAP execution state as Python objects. |
|
The state a run stopped in, with the questions people ask of it (issue #101). |
|
LangGraph channel schema for the GOAP loop: the JSON-native state. |
|
Result of executing a single GOAP action. |
|
Return a copy of state with typed |
|
Return names of successfully executed actions from a GOAP result. |
Planning#
Quality metric evaluated against a |
|
Minimise |
|
Minimise the sum of |
|
Minimise the worst-case (maximum) value of |
|
Find an optimal action sequence from start to goal using A*. |
|
Two-phase planning: A* finds sequences, CSP validates/optimizes. |
|
A sequence of actions that achieves a goal from a given start state. |
|
Metadata about how a plan was generated. |
|
Immutable, hashable representation of a GOAP world state. |
|
Build a clean-slate world state from action preconditions and effects. |
Planning strategies#
A pluggable planning strategy. |
|
Pure A* construction heuristic. |
|
Return the best plan found within a wall-clock time budget. |
|
Deprecated: call |
|
Validate |
|
ADaPT-style incremental planning. |
|
Monte Carlo Tree Search planning strategy. |
|
Search budget and exploration knobs for |
|
Tree-reuse and variable-depth selection config. |
|
Observability config for |
|
Plan-repair wrapper around any inner |
|
Outcome of a plan-repair attempt. |
|
Repair a partially-executed plan by reusing its valid prefix. |
|
A* construction + CSP refinement, composed as a single strategy. |
|
Predicts an external agent's next action given a world state. |
|
Baseline |
|
Continuous state-value function consumed by MCTS rollouts. |
|
Pluggable rollout policy Protocol. |
|
Baseline control condition — uniformly random applicable action. |
|
Greedy rollout: pick the applicable action minimising |
|
Rollout policy that advances via a |
Utility (greedy) planner#
Marker goal that is never satisfied. |
|
Greedy one-step utility planner. |
|
Return True iff |
Constants:
langgoap.NIRVANA_NAME(str)
Router#
Cheap-to-compute routing features extracted at plan time. |
|
Lexicographic classifier with conservative defaults. |
|
Maps |
|
Dispatches to a registered |
|
Extract routing features. |
Transition models#
Default model: |
|
Declared divergence between |
|
Separates action specs from world dynamics. |
|
Enforce the |
Guards#
Synchronous action guard protocol. |
|
Asynchronous action guard protocol. |
|
Wraps a callable into an |
|
Immutable result returned by a guard check. |
|
Severity of a guard failure. |
|
Return |
|
Run all guards concurrently via |
|
Run all synchronous guards and return all |
LLM cost / token accounting#
Accumulate LLM cost / tokens / call count into a |
Constants:
langgoap.DEFAULT_COST_PER_1K_TOKENS(dict)
Action QoS / retry policy#
Quality-of-service / retry policy for a single action. |
Constants:
langgoap.DEFAULT_RETRY_POLICY(ActionQos)langgoap.FIRE_ONCE(ActionQos)
Stuck-handler protocol#
Adapter that turns a callable into a |
|
Composite handler that consults each child in order. |
|
Recovery hook fired when the planner cannot find a plan. |
|
Coroutine-based twin of |
|
Outcome of a stuck-handler invocation. |
|
Whether a handler resolved a stuck situation. |
Early-termination policies#
Composite: terminate only when every child policy fires. |
|
Termination decision returned by a policy. |
|
Composite: terminate when any child policy fires. |
|
Terminate after |
|
Terminate when |
|
Terminate when |
|
Terminate when |
|
Terminate after |
|
Convert a |
|
Policy that decides whether the GOAP loop should terminate. |
Scores#
Abstract base for all score types. |
|
A single scalar score. |
|
A two-level score with hard and soft components. |
|
A variable-width score with any number of hard and soft levels. |
CSP#
Results from the CSP optimizer. |
|
Status of a CSP solve attempt. |
|
Per-key resource breakdown for a plan. |
|
Per-action temporal slot in a schedule. |
|
Enumerate the Pareto-optimal subset of candidate plans. |
Plan explanation#
Explanation of why a plan is infeasible. |
|
Explanation of why A* could not find a valid plan. |
|
A single resource that exceeds its constraint. |
|
Analyze an INFEASIBLE plan and explain which constraints conflict. |
|
Explain why A* could not find a valid plan. |
Types#
Protocol for dynamic action cost functions. |
|
Direction for numeric optimization objectives. |
|
Direction for numeric optimization objectives. |
|
Direction for numeric optimization objectives. |
|
When to trigger replanning during execution. |
Visualization#
Render a Plan as a Mermaid |
|
Render a Plan's schedule as a Mermaid |
|
Render a Plan as a Graphviz DOT digraph. |
|
Render a Plan as a top-to-bottom ASCII tree. |
|
Render the plan's schedule as an ASCII Gantt chart. |
|
Render a Plan for display. |
Tracing#
Wrap a |
|
Sync + async observability hooks for the GOAP planning loop. |
|
No-op tracer — the default when no tracer is configured. |
|
Tracer that routes every event through stdlib |
|
Fan a single event out to multiple tracers. |
|
Emit GOAP planning events to LangSmith as a structured run tree. |
|
The |
Execution history#
One planner → executor → observer loop outcome. |
|
Execution history backed by a LangGraph |
|
Return a stable short hash of a goal's conditions. |
Sensors#
Reads external state into the world state before planning. |
|
Async variant of |
|
Convenience wrapper: construct a |
|
Run all sensors synchronously and return (name, updates) pairs. |
|
Run all sensors asynchronously and return (name, updates) pairs. |
Reflexion#
A verbal reflection on an execution failure. |
|
Tracer that captures failures and generates verbal reflections. |
Serde#
Deprecated no-op subclass of LangGraph's |
|
Deprecated no-op: returns checkpointer unchanged. |
Constants:
langgoap.LANGGOAP_ALLOWED_MSGPACK_TYPES(tuple)