What Are Subgraphs in LangGraph?
A subgraph is a complete LangGraph graph that runs as part of another LangGraph graph. The graph that contains and uses the subgraph is…
What Are Subgraphs in LangGraph?
A subgraph is a complete LangGraph graph that runs as part of another LangGraph graph. The graph that contains and uses the subgraph is called the parent graph.
You build a subgraph the same way you build any other LangGraph graph. You define a state schema, add nodes, connect them with edges, and compile the graph.
The only difference is how it is used. Instead of running it on its own, you use it as a single node inside a parent graph. This lets you reuse the same workflow in one or more parent graphs.

Why Use Subgraphs?
As your LangGraph applications grow, a single graph can become large and difficult to manage. Subgraphs help by breaking a large workflow into smaller, independent parts.
They offer 3 main benefits:
1] Building Multi-Agent Systems
Multi-agent systems are usually not built as one large flow. Each agent can have its own steps, tools, and logic. Using subgraphs lets you keep each agent separate and manage them through a parent graph. This keeps the internal logic of one agent from mixing with the rest of the system.
2] Reusability
Once a subgraph is built and compiled, you can use it in more than one parent graph. That means you do not have to repeat the same logic in different places. If you update the subgraph later, every parent graph that uses it gets the same improvement.
3] Independent Development
Subgraphs make it easier for teams to work independently. One team can build and maintain a subgraph, while another team builds the parent graph. The parent graph only needs to know what data the subgraph accepts and what it returns. It doesn’t need to know how the subgraph works internally.
Two Ways to Connect a Subgraph to a Parent Graph
LangGraph provides 2 ways to use a subgraph inside a parent graph. The choice depends on whether the parent graph and the subgraph use the same state schema or different state schemas.
1] Call a Subgraph Inside a Node
Use this approach when the parent graph and the subgraph use different state schemas.
A node in the parent graph calls the subgraph. It passes the data the subgraph needs and receives the result when the subgraph finishes. The node then updates the parent graph’s state with that result. This approach is useful when the parent graph and the subgraph do not use the same state fields.
For example: A parent graph called Getting Ready for Office may track simple fields like current_activity and status. It can call a subgraph called Making Tea, which tracks its own fields like water, milk, tea_leaves, sugar, and tea_masala. These two graphs do not share the same state, so a node in the parent graph passes data to the subgraph and brings the result back.
2] Add a subgraph as a node
Use this approach when the parent graph and the subgraph use the same state keys. Since both read from and write to the same fields, no data conversion is needed. The compiled subgraph can be passed directly to add_node because both graphs share the same state.
For example: A Project Planning parent graph and a Risk Assessment subgraph both use the same state fields: project details, priority, and status. Because they share the same state structure, the subgraph can be added as a node without any additional setup.
Choosing between the two patterns comes down to a single question: do the subgraph and the parent graph share the same state, or do they use different state?
If they share state, add the subgraph directly as a node. If they use different state, invoke the subgraph inside a node function.
This article focuses on understanding subgraphs and the two ways to use them in LangGraph. The implementation details, along with complete, runnable examples, will be covered in separate articles.
메타데이터
- post_id
- 7a1dd325eb7d
- slug
- what-are-subgraphs-in-langgraph-7a1dd325eb7d
- url
- https://medium.com/@nachiket4jan/what-are-subgraphs-in-langgraph-7a1dd325eb7d
- canonical_url
- https://medium.com/@nachiket4jan/what-are-subgraphs-in-langgraph-7a1dd325eb7d
- author_url
- https://medium.com/@nachiket4jan
- status
- ok
- fetched_at
- 2026-07-25 14:00:21