Loading...
Loading...
LangGraph workflow patterns for state management, routing, parallel execution, supervisor-worker, tool calling, checkpointing, human-in-loop, streaming, subgraphs, and functional API. Use when building LangGraph pipelines, multi-agent systems, or AI workflows.
npx skill4agent add yonatangross/orchestkit langgraphrules/| Category | Rules | Impact | When to Use |
|---|---|---|---|
| State Management | 4 | CRITICAL | Designing workflow state schemas, accumulators, reducers |
| Routing & Branching | 3 | HIGH | Dynamic routing, retry loops, semantic routing |
| 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 |
| Rule | File | Key Pattern |
|---|---|---|
| TypedDict State | | |
| Pydantic Validation | | |
| MessagesState | | |
| Custom Reducers | | |
| Rule | File | Key Pattern |
|---|---|---|
| Conditional Edges | | |
| Retry Loops | | Loop-back edges with max retry counter |
| Semantic Routing | | Embedding similarity or |
Annotated[list, add]| Rule | File | Key Pattern |
|---|---|---|
| Fan-Out/Fan-In | | |
| Map-Reduce | | |
| Error Isolation | | |
| Rule | File | Key Pattern |
|---|---|---|
| Basic Supervisor | | |
| Priority Routing | | Priority dict ordering agent execution |
| Round-Robin | | Completion tracking with |
| Rule | File | Key Pattern |
|---|---|---|
| Tool Binding | | |
| ToolNode Execution | | |
| Dynamic Selection | | Embedding-based tool relevance filtering |
| Tool Interrupts | | |
| Rule | File | Key Pattern |
|---|---|---|
| Checkpointer Setup | | |
| State Recovery | | |
| Cross-Thread Store | | |
| Rule | File | Key Pattern |
|---|---|---|
| Interrupt/Resume | | |
| Approval Gate | | |
| Feedback Loop | | Iterative interrupt until approved |
| Rule | File | Key Pattern |
|---|---|---|
| Stream Modes | | 5 modes: values, updates, messages, custom, debug |
| Token Streaming | | |
| Custom Events | | |
| Rule | File | Key Pattern |
|---|---|---|
| Invoke from Node | | Different schemas, explicit state mapping |
| Add as Node | | Shared state, |
| State Mapping | | Boundary transforms between parent/child |
@entrypoint@task| Rule | File | Key Pattern |
|---|---|---|
| @entrypoint | | Workflow entry point with optional checkpointer |
| @task | | Returns futures, |
| Migration | | |
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()Command(update=..., goto=...)InMemoryCacheinterrupt_beforeset_entry_point()| Decision | Recommendation |
|---|---|
| State type | TypedDict internally, Pydantic at boundaries |
| Entry point | |
| Routing + state update | Command API |
| Routing only | Conditional edges |
| Accumulators | |
| 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 | |
| Stream modes | |
| Subgraph pattern | Invoke for isolation, Add-as-Node for shared state |
| Functional vs Graph | Functional for simple flows, Graph for complex topology |
addinterrupt().result()set_entry_point()add_edge(START, ...)test-cases.jsonagent-orchestrationtemporal-iollm-integrationtype-safety-validation