← All notes

Nest a compiled LangGraph graph as a subgraph node

Answer: A LangGraph subgraph is a graph used as a node in another graph. You compile the inner graph and add it as a node, then define how parent and subgraph state communicate. Stateful subgraphs can inherit the parent checkpointer so interrupts and persistence still work.

Why subgraphs

This guide explains the mechanics of using subgraphs. A subgraph is a graph that is used as a node in another graph. Subgraphs are useful for building multi-agent systems, reusing a set of nodes in multiple graphs, and distributing development so different teams can work on different parts independently. The subgraph interface is the input and output schemas. If that interface is respected, the parent graph can be built without knowing details of the subgraph. When adding subgraphs, you need to define how the parent graph and the subgraph communicate.

Persistence in subgraphs

Stateful subgraphs inherit the parent graph's checkpointer, which enables interrupts and persistence. The stateful modes differ in how long state is retained. Use per-thread persistence when a subagent needs multi-turn conversation memory. Use per-invocation persistence when each call is independent and the subagent does not need to remember previous calls. The types module documents the checkpointer setting for a subgraph: True enables persistent checkpointing for this subgraph. It also describes a snapshot of the subgraph state, or None if not a subgraph.

| subgraph | checkpointer | |---|---| | subgraph as a node | reuse a compiled graph inside a parent | | input and output schemas | interface the parent graph relies on | | per-thread persistence | subagent needs multi-turn memory | | checkpointer True | persistent checkpointing for the subgraph |

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: LangChain Docs, Subgraphs; langchain-ai/langgraph (GitHub), LangGraph types (subgraph checkpointing). MIT; MIT. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: LangChain Docs, Subgraphs; langchain-ai/langgraph (GitHub), LangGraph types (subgraph checkpointing). MIT; MIT.

Cite this

Permanent ID: iil:note:n0qsanvf

iinventedlight. 2026. "Nest a compiled LangGraph graph as a subgraph node." iinventedlight Library, iil:note:n0qsanvf, version of 2026-11-19. https://iinventedlight.com/library/notes/langgraph-subgraphs/. License: CC-BY-4.0.

@misc{iil_note_n0qsanvf,
  author = {{iinventedlight}},
  title = {{Nest a compiled LangGraph graph as a subgraph node}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-19},
  url = {https://iinventedlight.com/library/notes/langgraph-subgraphs/},
  note = {Permanent ID iil:note:n0qsanvf. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/langgraph-subgraphs.md.