langgoap.add_goap_subgraph

langgoap.add_goap_subgraph#

add_goap_subgraph(parent_builder, *, name, actions, goal, input_key='world_state', output_key='plan_result')[source]#

Attach a GOAP sub-graph as a node inside a parent StateGraph.

The sub-graph is compiled and wrapped in a closure that:

  1. Reads state[input_key] from the parent state.

  2. Invokes the sub-graph with a fresh GoapState carrying that world state and the configured goal.

  3. Writes the final sub-graph state into state[output_key] as a plain dict so the parent schema stays decoupled from GoapState.

The parent graph must declare input_key and output_key in its state schema (both are plain dict[str, Any] slots).

Parameters:
  • parent_builder (StateGraph) – The parent StateGraph under construction.

  • name (str) – Node name to register in the parent graph.

  • actions (list[ActionSpec]) – Actions for the sub-graph’s planner.

  • goal (GoalSpec) – Goal specification for the sub-graph.

  • input_key (str) – Parent-state key providing the initial world state. Defaults to "world_state".

  • output_key (str) – Parent-state key where the sub-graph’s final state will be stored. Defaults to "plan_result".

Return type:

None