LangGraph Workflow Patterns
Comprehensive patterns for building production LangGraph workflows. LangGraph 1.x is LTS (Long Term Support) — the first stable major release, powering agents at Uber, LinkedIn, and Klarna. Each category has individual rule files in rules/ loaded on-demand.
Quick Reference
| Category |
Rules |
Impact |
When to Use |
| State Management |
4 |
CRITICAL |
Designing workflow state schemas, accumulators, reducers |
| Routing & Branching |
4 |
HIGH |
Dynamic routing, retry loops, semantic routing, cross-graph |
| Parallel Execution |
3 |
HIGH |
Fan-out/fan-in, map-reduce, concurrent agents |
| Supervisor Patterns |
3 |
HIGH |
Central coordinators, round-robin, priority dispatch |
| Tool Calling |
4 |
CRITICAL |
Binding tools, ToolNode, dynamic selection, approvals |
| Checkpointing |
3 |
HIGH |
Persistence, recovery, cross-thread Store memory |
| Human-in-Loop |
3 |
MEDIUM |
Approval gates, feedback loops, interrupt/resume |
| Streaming |
3 |
MEDIUM |
Real-time updates, token streaming, custom events |
| Subgraphs |
3 |
MEDIUM |
Modular composition, nested graphs, state mapping |
| Functional API |
3 |
MEDIUM |
@entrypoint/@task decorators, migration from StateGraph |
| Platform |
3 |
HIGH |
Deployment, RemoteGraph, double-texting strategies |
Total: 37 rules across 11 categories
State Management
State schemas determine how data flows between nodes. Wrong schemas cause silent data loss.
| Rule |
File |
Key Pattern |
| TypedDict State |
rules/state-typeddict.md |
TypedDict + Annotated[list, add] for accumulators |
| Pydantic Validation |
rules/state-pydantic.md |
BaseModel at boundaries, TypedDict internally |
| MessagesState |
rules/state-messages.md |
MessagesState or add_messages reducer |
| Custom Reducers |
rules/state-reducers.md |
Annotated[T, reducer_fn] for merge/overwrite |
Routing & Branching
Control flow between nodes. Always include END fallback to prevent hangs.
| Rule |
File |
Key Pattern |
| Conditional Edges |
rules/routing-conditional.md |
add_conditional_edges with explicit mapping |
| Retry Loops |
rules/routing-retry-loops.md |
Loop-back edges with max retry counter |
| Semantic Routing |
rules/routing-semantic.md |
Embedding similarity or Command API routing |
| Cross-Graph Navigation |
rules/routing-cross-graph.md |
Command(graph=Command.PARENT) for parent/sibling routing |
Parallel Execution
Run independent nodes concurrently. Use Annotated[list, add] to accumulate results.
| Rule |
File |
Key Pattern |
| Fan-Out/Fan-In |
rules/parallel-fanout-fanin.md |
Send API for dynamic parallel branches |
| Map-Reduce |
rules/parallel-map-reduce.md |
asyncio.gather + result aggregation |
| Error Isolation |
rules/parallel-error-isolation.md |
return_exceptions=True + per-branch timeout |
Supervisor Patterns
Central coordinator routes to specialized workers. Workers return to supervisor.
| Rule |
File |
Key Pattern |
| Basic Supervisor |
rules/supervisor-basic.md |
Command API for state update + routing |
| Priority Routing |
rules/supervisor-priority.md |
Priority dict ordering agent execution |
| Round-Robin |
rules/supervisor-round-robin.md |
Completion tracking with agents_completed |
Tool Calling
Integrate function calling into LangGraph agents. Keep tools under 10 per agent.
| Rule |
File |
Key Pattern |
| Tool Binding |
rules/tools-bind.md |
model.bind_tools(tools) + tool_choice |
| ToolNode Execution |
rules/tools-toolnode.md |
ToolNode(tools) prebuilt parallel executor |
| Dynamic Selection |
rules/tools-dynamic.md |
Embedding-based tool relevance filtering |
| Tool Interrupts |
rules/tools-interrupts.md |
interrupt() for approval gates on tools |
Checkpointing
Persist workflow state for recovery and debugging.
| Rule |
File |
Key Pattern |
| Checkpointer Setup |
rules/checkpoints-setup.md |
MemorySaver dev / PostgresSaver prod |
| State Recovery |
rules/checkpoints-recovery.md |
thread_id resume + get_state_history |
| Cross-Thread Store |
rules/checkpoints-store.md |
Store for long-term memory across threads |
Human-in-Loop
Pause workflows for human intervention. Requires checkpointer for state persistence.
| Rule |
File |
Key Pattern |
| Interrupt/Resume |
rules/human-in-loop-interrupt.md |
interrupt() function + Command(resume=) |
| Approval Gate |
rules/human-in-loop-approval.md |
interrupt_before + state update + resume |
| Feedback Loop |
rules/human-in-loop-feedback.md |
Iterative interrupt until approved |
Streaming
Real-time updates and progress tracking for workflows. LangGraph 1.1 introduces version="v2" — an opt-in streaming format with full type safety on stream(), astream(), invoke(), and ainvoke().
| Rule |
File |
Key Pattern |
| Stream Modes |
rules/streaming-modes.md |
5 modes: values, updates, messages, custom, debug |
| Token Streaming |
rules/streaming-tokens.md |
messages mode with node/tag filtering |
| Custom Events |
rules/streaming-custom-events.md |
get_stream_writer() for progress events |
| Streaming v2 |
rules/streaming-v2-format.md |
version="v2" for typed streaming (LG 1.1+) |
Subgraphs
Compose modular, reusable workflow components with nested graphs.
| Rule |
File |
Key Pattern |
| Invoke from Node |
rules/subgraphs-invoke.md |
Different schemas, explicit state mapping |
| Add as Node |
rules/subgraphs-add-as-node.md |
Shared state, add_node(name, compiled_graph) |
| State Mapping |
rules/subgraphs-state-mapping.md |
Boundary transforms between parent/child |
Functional API
Build workflows using @entrypoint and @task decorators instead of explicit graph construction.
| Rule |
File |
Key Pattern |
| @entrypoint |
rules/functional-entrypoint.md |
Workflow entry point with optional checkpointer |
| @task |
rules/functional-task.md |
Returns futures, .result() to block |
| Migration |
rules/functional-migration.md |
StateGraph to Functional API conversion |
Platform
Deploy graphs as managed APIs with persistence, streaming, and multi-tenancy.
| Rule |
File |
Key Pattern |
| Deployment |
rules/platform-deployment.md |
langgraph.json + CLI + Assistants API |
| RemoteGraph |
rules/platform-remote-graph.md |
RemoteGraph for calling deployed graphs |
| Double Texting |
rules/platform-double-texting.md |
4 strategies: reject, rollback, enqueue, interrupt |
Quick Start Example
from langgraph.graph import StateGraph, START, END
from langgraph.types import Command
from typing import TypedDict, Annotated, Literal
from operator import add
class State(TypedDict):
input: str
results: Annotated[list[str], add]
def supervisor(state) -> Command[Literal["worker", END]]:
if not state.get("results"):
return Command(update={"input": state["input"]}, goto="worker")
return Command(goto=END)
def worker(state) -> dict:
return {"results": [f"Processed: {state['input']}"]}
graph = StateGraph(State)
graph.add_node("supervisor", supervisor)
graph.add_node("worker", worker)
graph.add_edge(START, "supervisor")
graph.add_edge("worker", "supervisor")
app = graph.compile()
2026 Key Patterns
- Streaming v2 (LG 1.1): Use
version="v2" for type-safe streaming — fully typed stream() and astream() returns. Default remains "v1" for backwards compat.
- Command API: Use
Command(update=..., goto=...) when updating state AND routing together
- context_schema: Pass runtime config (temperature, provider) without polluting state
- CachePolicy: Cache expensive node results with TTL via
InMemoryCache
- RemainingSteps: Proactively handle recursion limits
- Store: Cross-thread memory separate from Checkpointer (thread-scoped)
- interrupt(): Dynamic interrupts inside node logic (replaces
interrupt_before for conditional cases)
- add_edge(START, node): Not
set_entry_point() (deprecated)
- LTS release: LangGraph 1.x is LTS — will remain ACTIVE until v2.0
Key Decisions
| Decision |
Recommendation |
| State type |
TypedDict internally, Pydantic at boundaries |
| Entry point |
add_edge(START, node) not set_entry_point() |
| Routing + state update |
Command API |
| Routing only |
Conditional edges |
| Accumulators |
Annotated[list[T], add] always |
| Dev checkpointer |
MemorySaver |
| Prod checkpointer |
PostgresSaver |
| Short-term memory |
Checkpointer (thread-scoped) |
| Long-term memory |
Store (cross-thread, namespaced) |
| Max parallel branches |
5-10 concurrent |
| Tools per agent |
5-10 max (dynamic selection for more) |
| Approval gates |
interrupt() for high-risk operations |
| Stream modes |
["updates", "custom"] for most UIs |
| Subgraph pattern |
Invoke for isolation, Add-as-Node for shared state |
| Functional vs Graph |
Functional for simple flows, Graph for complex topology |
Common Mistakes
- Forgetting
add reducer (overwrites instead of accumulates)
- Mutating state in place (breaks checkpointing)
- No END fallback in routing (workflow hangs)
- Infinite retry loops (no max counter)
- Side effects in router functions
- Too many tools per agent (context overflow)
- Raising exceptions in tools (crashes agent loop)
- No checkpointer in production (lose progress on crash)
- Wrapping
interrupt() in try/except (breaks the mechanism)
- Not transforming state at subgraph boundaries
- Forgetting
.result() on Functional API tasks
- Using
set_entry_point() (deprecated, use add_edge(START, ...))
Evaluations
See test-cases.json for consolidated test cases across all categories.
Related Skills
ork:agent-orchestration - Higher-level multi-agent coordination, ReAct loop patterns, and framework comparisons
temporal-io - Durable execution alternative
ork:llm-integration - General LLM function calling
type-safety-validation - Pydantic model patterns
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: langgraph3description: LangGraph 1.x (LTS) workflow patterns for state management, routing, parallel execution, supervisor-worker, tool calling, checkpointing, human-in-loop, streaming (v2 format), subgraphs, and functional API. Use when building LangGraph pipelines, multi-agent systems, or AI workflows. Use when this capability is needed.4---56# LangGraph Workflow Patterns78Comprehensive patterns for building production LangGraph workflows. **LangGraph 1.x is LTS** (Long Term Support) — the first stable major release, powering agents at Uber, LinkedIn, and Klarna. Each category has individual rule files in `rules/` loaded on-demand.910## Quick Reference1112| Category | Rules | Impact | When to Use |13|----------|-------|--------|-------------|14| [State Management](#state-management) | 4 | CRITICAL | Designing workflow state schemas, accumulators, reducers |15| [Routing & Branching](#routing--branching) | 4 | HIGH | Dynamic routing, retry loops, semantic routing, cross-graph |16| [Parallel Execution](#parallel-execution) | 3 | HIGH | Fan-out/fan-in, map-reduce, concurrent agents |17| [Supervisor Patterns](#supervisor-patterns) | 3 | HIGH | Central coordinators, round-robin, priority dispatch |18| [Tool Calling](#tool-calling) | 4 | CRITICAL | Binding tools, ToolNode, dynamic selection, approvals |19| [Checkpointing](#checkpointing) | 3 | HIGH | Persistence, recovery, cross-thread Store memory |20| [Human-in-Loop](#human-in-loop) | 3 | MEDIUM | Approval gates, feedback loops, interrupt/resume |21| [Streaming](#streaming) | 3 | MEDIUM | Real-time updates, token streaming, custom events |22| [Subgraphs](#subgraphs) | 3 | MEDIUM | Modular composition, nested graphs, state mapping |23| [Functional API](#functional-api) | 3 | MEDIUM | @entrypoint/@task decorators, migration from StateGraph |24| [Platform](#platform) | 3 | HIGH | Deployment, RemoteGraph, double-texting strategies |2526**Total: 37 rules across 11 categories**2728## State Management2930State schemas determine how data flows between nodes. Wrong schemas cause silent data loss.3132| Rule | File | Key Pattern |33|------|------|-------------|34| TypedDict State | `rules/state-typeddict.md` | `TypedDict` + `Annotated[list, add]` for accumulators |35| Pydantic Validation | `rules/state-pydantic.md` | `BaseModel` at boundaries, TypedDict internally |36| MessagesState | `rules/state-messages.md` | `MessagesState` or `add_messages` reducer |37| Custom Reducers | `rules/state-reducers.md` | `Annotated[T, reducer_fn]` for merge/overwrite |3839## Routing & Branching4041Control flow between nodes. Always include END fallback to prevent hangs.4243| Rule | File | Key Pattern |44|------|------|-------------|45| Conditional Edges | `rules/routing-conditional.md` | `add_conditional_edges` with explicit mapping |46| Retry Loops | `rules/routing-retry-loops.md` | Loop-back edges with max retry counter |47| Semantic Routing | `rules/routing-semantic.md` | Embedding similarity or `Command` API routing |48| Cross-Graph Navigation | `rules/routing-cross-graph.md` | `Command(graph=Command.PARENT)` for parent/sibling routing |4950## Parallel Execution5152Run independent nodes concurrently. Use `Annotated[list, add]` to accumulate results.5354| Rule | File | Key Pattern |55|------|------|-------------|56| Fan-Out/Fan-In | `rules/parallel-fanout-fanin.md` | `Send` API for dynamic parallel branches |57| Map-Reduce | `rules/parallel-map-reduce.md` | `asyncio.gather` + result aggregation |58| Error Isolation | `rules/parallel-error-isolation.md` | `return_exceptions=True` + per-branch timeout |5960## Supervisor Patterns6162Central coordinator routes to specialized workers. Workers return to supervisor.6364| Rule | File | Key Pattern |65|------|------|-------------|66| Basic Supervisor | `rules/supervisor-basic.md` | `Command` API for state update + routing |67| Priority Routing | `rules/supervisor-priority.md` | Priority dict ordering agent execution |68| Round-Robin | `rules/supervisor-round-robin.md` | Completion tracking with `agents_completed` |6970## Tool Calling7172Integrate function calling into LangGraph agents. Keep tools under 10 per agent.7374| Rule | File | Key Pattern |75|------|------|-------------|76| Tool Binding | `rules/tools-bind.md` | `model.bind_tools(tools)` + `tool_choice` |77| ToolNode Execution | `rules/tools-toolnode.md` | `ToolNode(tools)` prebuilt parallel executor |78| Dynamic Selection | `rules/tools-dynamic.md` | Embedding-based tool relevance filtering |79| Tool Interrupts | `rules/tools-interrupts.md` | `interrupt()` for approval gates on tools |8081## Checkpointing8283Persist workflow state for recovery and debugging.8485| Rule | File | Key Pattern |86|------|------|-------------|87| Checkpointer Setup | `rules/checkpoints-setup.md` | `MemorySaver` dev / `PostgresSaver` prod |88| State Recovery | `rules/checkpoints-recovery.md` | `thread_id` resume + `get_state_history` |89| Cross-Thread Store | `rules/checkpoints-store.md` | `Store` for long-term memory across threads |9091## Human-in-Loop9293Pause workflows for human intervention. Requires checkpointer for state persistence.9495| Rule | File | Key Pattern |96|------|------|-------------|97| Interrupt/Resume | `rules/human-in-loop-interrupt.md` | `interrupt()` function + `Command(resume=)` |98| Approval Gate | `rules/human-in-loop-approval.md` | `interrupt_before` + state update + resume |99| Feedback Loop | `rules/human-in-loop-feedback.md` | Iterative interrupt until approved |100101## Streaming102103Real-time updates and progress tracking for workflows. **LangGraph 1.1 introduces `version="v2"`** — an opt-in streaming format with full type safety on `stream()`, `astream()`, `invoke()`, and `ainvoke()`.104105| Rule | File | Key Pattern |106|------|------|-------------|107| Stream Modes | `rules/streaming-modes.md` | 5 modes: values, updates, messages, custom, debug |108| Token Streaming | `rules/streaming-tokens.md` | `messages` mode with node/tag filtering |109| Custom Events | `rules/streaming-custom-events.md` | `get_stream_writer()` for progress events |110| Streaming v2 | `rules/streaming-v2-format.md` | `version="v2"` for typed streaming (LG 1.1+) |111112## Subgraphs113114Compose modular, reusable workflow components with nested graphs.115116| Rule | File | Key Pattern |117|------|------|-------------|118| Invoke from Node | `rules/subgraphs-invoke.md` | Different schemas, explicit state mapping |119| Add as Node | `rules/subgraphs-add-as-node.md` | Shared state, `add_node(name, compiled_graph)` |120| State Mapping | `rules/subgraphs-state-mapping.md` | Boundary transforms between parent/child |121122## Functional API123124Build workflows using `@entrypoint` and `@task` decorators instead of explicit graph construction.125126| Rule | File | Key Pattern |127|------|------|-------------|128| @entrypoint | `rules/functional-entrypoint.md` | Workflow entry point with optional checkpointer |129| @task | `rules/functional-task.md` | Returns futures, `.result()` to block |130| Migration | `rules/functional-migration.md` | `StateGraph` to Functional API conversion |131132## Platform133134Deploy graphs as managed APIs with persistence, streaming, and multi-tenancy.135136| Rule | File | Key Pattern |137|------|------|-------------|138| Deployment | `rules/platform-deployment.md` | `langgraph.json` + CLI + Assistants API |139| RemoteGraph | `rules/platform-remote-graph.md` | `RemoteGraph` for calling deployed graphs |140| Double Texting | `rules/platform-double-texting.md` | 4 strategies: reject, rollback, enqueue, interrupt |141142## Quick Start Example143144```python145from langgraph.graph import StateGraph, START, END146from langgraph.types import Command147from typing import TypedDict, Annotated, Literal148from operator import add149150class State(TypedDict):151 input: str152 results: Annotated[list[str], add]153154def supervisor(state) -> Command[Literal["worker", END]]:155 if not state.get("results"):156 return Command(update={"input": state["input"]}, goto="worker")157 return Command(goto=END)158159def worker(state) -> dict:160 return {"results": [f"Processed: {state['input']}"]}161162graph = StateGraph(State)163graph.add_node("supervisor", supervisor)164graph.add_node("worker", worker)165graph.add_edge(START, "supervisor")166graph.add_edge("worker", "supervisor")167app = graph.compile()168```169170## 2026 Key Patterns171172- **Streaming v2 (LG 1.1)**: Use `version="v2"` for type-safe streaming — fully typed `stream()` and `astream()` returns. Default remains `"v1"` for backwards compat.173- **Command API**: Use `Command(update=..., goto=...)` when updating state AND routing together174- **context_schema**: Pass runtime config (temperature, provider) without polluting state175- **CachePolicy**: Cache expensive node results with TTL via `InMemoryCache`176- **RemainingSteps**: Proactively handle recursion limits177- **Store**: Cross-thread memory separate from Checkpointer (thread-scoped)178- **interrupt()**: Dynamic interrupts inside node logic (replaces `interrupt_before` for conditional cases)179- **add_edge(START, node)**: Not `set_entry_point()` (deprecated)180- **LTS release**: LangGraph 1.x is LTS — will remain ACTIVE until v2.0181182## Key Decisions183184| Decision | Recommendation |185|----------|----------------|186| State type | TypedDict internally, Pydantic at boundaries |187| Entry point | `add_edge(START, node)` not `set_entry_point()` |188| Routing + state update | Command API |189| Routing only | Conditional edges |190| Accumulators | `Annotated[list[T], add]` always |191| Dev checkpointer | MemorySaver |192| Prod checkpointer | PostgresSaver |193| Short-term memory | Checkpointer (thread-scoped) |194| Long-term memory | Store (cross-thread, namespaced) |195| Max parallel branches | 5-10 concurrent |196| Tools per agent | 5-10 max (dynamic selection for more) |197| Approval gates | `interrupt()` for high-risk operations |198| Stream modes | `["updates", "custom"]` for most UIs |199| Subgraph pattern | Invoke for isolation, Add-as-Node for shared state |200| Functional vs Graph | Functional for simple flows, Graph for complex topology |201202## Common Mistakes2032041. Forgetting `add` reducer (overwrites instead of accumulates)2052. Mutating state in place (breaks checkpointing)2063. No END fallback in routing (workflow hangs)2074. Infinite retry loops (no max counter)2085. Side effects in router functions2096. Too many tools per agent (context overflow)2107. Raising exceptions in tools (crashes agent loop)2118. No checkpointer in production (lose progress on crash)2129. Wrapping `interrupt()` in try/except (breaks the mechanism)21310. Not transforming state at subgraph boundaries21411. Forgetting `.result()` on Functional API tasks21512. Using `set_entry_point()` (deprecated, use `add_edge(START, ...)`)216217## Evaluations218219See `test-cases.json` for consolidated test cases across all categories.220221## Related Skills222223- `ork:agent-orchestration` - Higher-level multi-agent coordination, ReAct loop patterns, and framework comparisons224- `temporal-io` - Durable execution alternative225- `ork:llm-integration` - General LLM function calling226- `type-safety-validation` - Pydantic model patterns227228---229> Converted and distributed by [TomeVault](https://tomevault.io/claim/yonatangross) — claim your Tome and manage your conversions.230<!-- tomevault:4.0:skill_md:2026-04-11 -->