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:
Reads
state[input_key]from the parent state.Invokes the sub-graph with a fresh
GoapStatecarrying that world state and the configuredgoal.Writes the final sub-graph state into
state[output_key]as a plain dict so the parent schema stays decoupled fromGoapState.
The parent graph must declare
input_keyandoutput_keyin its state schema (both are plaindict[str, Any]slots).- Parameters:
parent_builder (StateGraph) – The parent
StateGraphunder 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