Agentic AI Notebook
LangGraph
Phase 10Module 10 of 12

Subgraphs

A mega-graph is unreadable and untestable. Subgraphs let a team own billing without touching classify.

A company org chart. The CEO graph delegates to Finance. Finance can redo internals without rewriting the CEO loop.

Visual Workflows

Start here — scroll inside each diagram frame to explore, then use + / to zoom up to 200% if needed.

Overview

100%
Loading diagram...

Scroll inside the frame to explore · use + / − to zoom up to 200%

100%
Loading diagram...

Scroll inside the frame to explore · use + / − to zoom up to 200%

Map parent fields into the child

100%
Loading diagram...

Scroll inside the frame to explore · use + / − to zoom up to 200%

Do not share one giant state blob. Pass ticket_id in, take result out.

When not to subgraph

100%
Loading diagram...

Scroll inside the frame to explore · use + / − to zoom up to 200%

Two-line helpers stay as nodes. Subgraph when the child has its own loop, tools, or HITL.

Key Takeaways

  • 1.A subgraph is a compiled graph used as a node in a parent graph. Specialists keep their own state contract. The parent only maps the fields it must pass in and take out.
  • 2.This is how multi-agent LangGraph is supposed to look: not 40 nodes in one file, but billing and tech as child graphs. HITL and checkpoints can live inside the child. The parent still owns the thread_id unless you give the child its own.
  • 3.Compile the child, add_node('billing', child). Shared schema or explicit input/output mapping.
  • 4.Command(graph=Command.PARENT) can jump back to a parent node. Test the child with its own invokes before wiring the parent.

Learn elsewhere

  • Multi-agent systems — Phase 18
  • Build a LangGraph Agent

Real Example

Scenario

Support parent: classify → billing subgraph or tech subgraph → reply. Refund interrupt lives only inside billing. Tech never sees refund tools.

What you would do

Draw two boxes. List the two fields that cross the boundary. If you need twelve fields, the contract is wrong — shrink it.

Commands

Commands to Remember

  • Child = compiled graph passed to add_node
  • Map in / map out — do not share a junk drawer
  • HITL can live inside the child
  • Test the child alone first

Cheat Sheet

Quick recap

quick ref
  • Compiled graph as a node
  • Thin contract
  • Test child first
  • Specialists isolate tools

Common Mistakes

  • One shared state object with 40 keys for every specialist
  • Subgraphing a function that is two lines long
  • No route back to the parent, so the child Finish ends the whole ticket