Agent skill · software engineering · jeremylongshore
langchain-langgraph-subgraphs
Compose LangGraph 1.0 subgraphs correctly \u2014 shared state key propagation,\n\
Why this skill is useful
Provides specific patterns and practices for composing LangGraph subgraphs that the AI wouldn't reliably generate on its own.
What it needs
Requires langchain-core, langgraph, pytest, python installed locally. About 8k tokens when loaded. Last updated 2026-08-07. 2,604 stars on the source repository.
What this skill does
LangGraph Subgraphs and Composition (Python) Overview A parent StateGraph invokes a compiled child subgraph as a node. The child node writes state["answer"] = "42" and returns. The parent's next node reads state["answer"] and gets None. No error, no warning, no deprecation notice — just a silent None that surfaces as a wrong answer three nodes later when the router picks the "couldn't find it" branch. The cause is pain-catalog entry P21: LangGraph subgraphs run on an independent state schema. Only keys declared in both the parent's TypedDict and the child's TypedDict propagate across the subgraph boundary. answer existed in the child schema but not the parent schema, so it was discarded on return. The fix is to declare answer in both schemas (with matching reducers, if the field is a list) or to use explicit Command(graph=ParentGraph, update={"answer": "42"}) to bubble it up. The second silent failure waits one step further. Attach a tracing callback to the parent runnable via parent.withconfig(callbacks=[tracer]) and invoke. The tracer fires on parent nodes and never on child tool calls. This is pain-catalog entry P28: LangGraph creates a fresh runtime per subgraph, so callbacks bound at definition time do not inherit. The fix is to pass callbacks at invocation time via config["callbacks"], which does propagate. This skill walks through the shared-state contract, three dispatch patterns (compiled subgraph as a node, Send fan-out, Command(graph=Parent) bubble-up), callback scoping, per-subgraph recursionlimit budgets, and a testing pattern that exercises every subgraph in isolation before composition. Pin: langgraph 1.0.x, langchain-core 1.0.x. Pain-catalog anchors: P21, P28, with supporting references to P18 (reducers), P19 (stream modes on nested graphs), and P55 (recursion budget). A planner-executor is typically 1 parent + 2-4 subgraphs; a hierarchical agent team with a supervisor and N specialists is 1 parent + N subgraphs. …
How to use it
Reference it in AdaL, Claude Code, Cursor or any coding agent — nothing to install:
@skills jeremylongshore/langchain-langgraph-subgraphs