← Production Insights

#9

Subgraphs Are State Ownership Boundaries

Stop putting an entire workflow inside one LangGraph node.

When logic starts owning its own decisions, steps, tools, retries, and state boundaries, it is no longer node logic.

It is a subgraph.

The production decision is not only whether to use a subgraph.

It is what kind of state boundary the subgraph needs.

There are two patterns:

1. Shared-state subgraph

Use this when the subgraph works on the same business state as the parent graph.

The subgraph reads and updates MainState.

The parent continues with the updated state.

This works when the subgraph is not hiding a separate internal workflow.

A compiled subgraph can be added to the parent graph as a node.

2. Private-state subgraph with a wrapper node

Use this when the subgraph has internal processing state the parent graph should not own.

This is handled by a wrapper node.

The wrapper node is the adapter boundary between MainState and the private subgraph.

  • Reads MainState.
  • Builds the private subgraph input.
  • Invokes the subgraph.
  • Maps the subgraph output back to MainState.
  • Hides private execution details from the parent graph.

Subgraphs are not about splitting code.

They are about protecting state ownership.