langgoap.PlanningState

langgoap.PlanningState#

class PlanningState(conditions, context=<factory>)[source]#

Immutable, hashable representation of a GOAP world state.

Internally stores state as a frozenset of (key, value) tuples to ensure immutability and hashability. This enables use as dictionary keys and in sets — critical for A* closed-set tracking.

The public attribute conditions exposes the underlying frozenset so callers can inspect it directly without an allocation.

In practice, a GOAP world state dict may contain both planning flags (hashable booleans/scalars used by the A* planner) and execution context (rich data like document lists or LLM responses). Use the keys parameter of from_dict() to extract only the planning-relevant subset.

Parameters:
  • conditions (frozenset[tuple[str, Any]])

  • context (Mapping[str, Any])

__init__(conditions, context=<factory>)#
Parameters:
  • conditions (frozenset[tuple[str, Any]])

  • context (Mapping[str, Any])

Return type:

None

Methods

__init__(conditions[, context])

apply(effects)

Return a new PlanningState with effects applied.

as_context()

The world state as user callables should see it.

from_dict(d, *[, keys])

Create a PlanningState from a dictionary.

get(key[, default])

Get a value by key, returning default if missing.

satisfies(requirements)

Check if this state satisfies all given conditions.

to_dict()

Convert to a mutable dictionary snapshot.

Attributes

conditions

context

Non-planning entries of the world state the search started from (documents, identifiers, tiers, ...).