langgraph by yonatangross/orchestkit
npx skills add https://github.com/yonatangross/orchestkit --skill langgraph构建生产级 LangGraph 工作流的综合模式。LangGraph 1.x 是 LTS(长期支持版本)——首个稳定主版本,为 Uber、LinkedIn 和 Klarna 的智能体提供支持。每个类别在 rules/ 目录下都有按需加载的独立规则文件。
| 类别 | 规则数 | 影响程度 | 使用场景 |
|---|---|---|---|
| 状态管理 | 4 | 关键 | 设计工作流状态模式、累加器、归约器 |
| 路由与分支 | 4 | 高 | 动态路由、重试循环、语义路由、跨图路由 |
| 并行执行 | 3 | 高 | 扇出/扇入、映射归约、并发智能体 |
| 监督者模式 | 3 | 高 | 中央协调器、轮询调度、优先级调度 |
| 工具调用 | 4 | 关键 |
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 绑定工具、ToolNode、动态选择、审批 |
| 检查点 | 3 | 高 | 持久化、恢复、跨线程存储内存 |
| 人在回路 | 3 | 中 | 审批关卡、反馈循环、中断/恢复 |
| 流式处理 | 3 | 中 | 实时更新、令牌流式传输、自定义事件 |
| 子图 | 3 | 中 | 模块化组合、嵌套图、状态映射 |
| 函数式 API | 3 | 中 | @entrypoint/@task 装饰器、从 StateGraph 迁移 |
| 平台 | 3 | 高 | 部署、RemoteGraph、双重文本策略 |
总计:11 个类别,共 37 条规则
状态模式决定了数据如何在节点间流动。错误的模式会导致静默数据丢失。
| 规则 | 文件 | 关键模式 |
|---|---|---|
| TypedDict 状态 | rules/state-typeddict.md | TypedDict + Annotated[list, add] 用于累加器 |
| Pydantic 验证 | rules/state-pydantic.md | 在边界使用 BaseModel,内部使用 TypedDict |
| MessagesState | rules/state-messages.md | MessagesState 或 add_messages 归约器 |
| 自定义归约器 | rules/state-reducers.md | Annotated[T, reducer_fn] 用于合并/覆盖 |
控制节点间的流程。始终包含 END 回退以防止挂起。
| 规则 | 文件 | 关键模式 |
|---|---|---|
| 条件边 | rules/routing-conditional.md | add_conditional_edges 配合显式映射 |
| 重试循环 | rules/routing-retry-loops.md | 带最大重试计数器的回环边 |
| 语义路由 | rules/routing-semantic.md | 基于嵌入相似性或 Command API 路由 |
| 跨图导航 | rules/routing-cross-graph.md | Command(graph=Command.PARENT) 用于父/兄弟图路由 |
并发运行独立的节点。使用 Annotated[list, add] 来累积结果。
| 规则 | 文件 | 关键模式 |
|---|---|---|
| 扇出/扇入 | rules/parallel-fanout-fanin.md | 使用 Send API 实现动态并行分支 |
| 映射归约 | rules/parallel-map-reduce.md | asyncio.gather + 结果聚合 |
| 错误隔离 | rules/parallel-error-isolation.md | return_exceptions=True + 每个分支的超时设置 |
中央协调器将任务路由给专门的执行器。执行器完成后返回监督者。
| 规则 | 文件 | 关键模式 |
|---|---|---|
| 基础监督者 | rules/supervisor-basic.md | 使用 Command API 进行状态更新和路由 |
| 优先级路由 | rules/supervisor-priority.md | 使用优先级字典排序智能体执行 |
| 轮询调度 | rules/supervisor-round-robin.md | 使用 agents_completed 跟踪完成情况 |
将函数调用集成到 LangGraph 智能体中。每个智能体保持工具数量不超过 10 个。
| 规则 | 文件 | 关键模式 |
|---|---|---|
| 工具绑定 | rules/tools-bind.md | model.bind_tools(tools) + tool_choice |
| ToolNode 执行 | rules/tools-toolnode.md | ToolNode(tools) 预构建的并行执行器 |
| 动态选择 | rules/tools-dynamic.md | 基于嵌入的工具相关性过滤 |
| 工具中断 | rules/tools-interrupts.md | 使用 interrupt() 实现工具审批关卡 |
持久化工作流状态以便恢复和调试。
| 规则 | 文件 | 关键模式 |
|---|---|---|
| 检查点设置 | rules/checkpoints-setup.md | 开发环境用 MemorySaver / 生产环境用 PostgresSaver |
| 状态恢复 | rules/checkpoints-recovery.md | thread_id 恢复 + get_state_history |
| 跨线程存储 | rules/checkpoints-store.md | 使用 Store 实现跨线程的长期记忆 |
暂停工作流以等待人工干预。需要检查点机制来持久化状态。
| 规则 | 文件 | 关键模式 |
|---|---|---|
| 中断/恢复 | rules/human-in-loop-interrupt.md | interrupt() 函数 + Command(resume=) |
| 审批关卡 | rules/human-in-loop-approval.md | interrupt_before + 状态更新 + 恢复 |
| 反馈循环 | rules/human-in-loop-feedback.md | 迭代中断直至获得批准 |
工作流的实时更新和进度跟踪。LangGraph 1.1 引入了 version="v2" —— 一种可选的流式格式,为 stream()、astream()、invoke() 和 ainvoke() 提供完整的类型安全。
| 规则 | 文件 | 关键模式 |
|---|---|---|
| 流模式 | rules/streaming-modes.md | 5 种模式:值、更新、消息、自定义、调试 |
| 令牌流式传输 | rules/streaming-tokens.md | messages 模式配合节点/标签过滤 |
| 自定义事件 | rules/streaming-custom-events.md | get_stream_writer() 用于进度事件 |
| 流式处理 v2 | rules/streaming-v2-format.md | version="v2" 用于类型安全的流式处理(LG 1.1+) |
使用嵌套图组合模块化、可重用的工作流组件。
| 规则 | 文件 | 关键模式 |
|---|---|---|
| 从节点调用 | rules/subgraphs-invoke.md | 不同的模式,显式的状态映射 |
| 添加为节点 | rules/subgraphs-add-as-node.md | 共享状态,add_node(name, compiled_graph) |
| 状态映射 | rules/subgraphs-state-mapping.md | 父/子图之间的边界转换 |
使用 @entrypoint 和 @task 装饰器构建工作流,而非显式构建图。
| 规则 | 文件 | 关键模式 |
|---|---|---|
| @entrypoint | rules/functional-entrypoint.md | 工作流入口点,可选检查点机制 |
| @task | rules/functional-task.md | 返回 futures,使用 .result() 阻塞等待 |
| 迁移 | rules/functional-migration.md | 从 StateGraph 迁移到函数式 API |
将图部署为具有持久化、流式处理和多租户功能的托管 API。
| 规则 | 文件 | 关键模式 |
|---|---|---|
| 部署 | rules/platform-deployment.md | langgraph.json + CLI + Assistants API |
| RemoteGraph | rules/platform-remote-graph.md | RemoteGraph 用于调用已部署的图 |
| 双重文本 | rules/platform-double-texting.md | 4 种策略:拒绝、回滚、排队、中断 |
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()
version="v2" 进行类型安全的流式处理 —— stream() 和 astream() 返回完全类型化的结果。默认仍为 "v1" 以保持向后兼容。Command(update=..., goto=...)InMemoryCache 缓存开销大的节点结果,并设置 TTLinterrupt_before)set_entry_point()(已弃用)| 决策 | 建议 |
|---|---|
| 状态类型 | 内部使用 TypedDict,边界使用 Pydantic |
| 入口点 | add_edge(START, node) 而非 set_entry_point() |
| 路由 + 状态更新 | Command API |
| 仅路由 | 条件边 |
| 累加器 | 始终使用 Annotated[list[T], add] |
| 开发检查点 | MemorySaver |
| 生产检查点 | PostgresSaver |
| 短期记忆 | Checkpointer(线程作用域) |
| 长期记忆 | Store(跨线程,命名空间隔离) |
| 最大并行分支数 | 5-10 个并发 |
| 每个智能体的工具数 | 最多 5-10 个(更多则使用动态选择) |
| 审批关卡 | 对高风险操作使用 interrupt() |
| 流模式 | 大多数 UI 使用 ["updates", "custom"] |
| 子图模式 | 隔离场景用 Invoke,共享状态场景用 Add-as-Node |
| 函数式 vs 图式 | 简单流程用函数式,复杂拓扑用图式 |
add 归约器(导致覆盖而非累积)interrupt() 包裹在 try/except 中(破坏中断机制).result()set_entry_point()(已弃用,请使用 add_edge(START, ...))查看 test-cases.json 获取所有类别的综合测试用例。
ork:agent-orchestration - 更高级别的多智能体协调、ReAct 循环模式及框架比较temporal-io - 持久化执行的替代方案ork:llm-integration - 通用 LLM 函数调用type-safety-validation - Pydantic 模型模式每周安装量
80
代码仓库
GitHub 星标数
134
首次出现
2026 年 2 月 14 日
安全审计
安装于
codex76
opencode75
gemini-cli74
github-copilot74
cursor69
kimi-cli67
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.
| 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 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 reducer |
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 |
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 |
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 |
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 |
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 |
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 |
Real-time updates and progress tracking for workflows. LangGraph 1.1 introducesversion="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 |
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 |
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 |
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 |
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()
version="v2" for type-safe streaming — fully typed stream() and astream() returns. Default remains "v1" for backwards compat.Command(update=..., goto=...) when updating state AND routing togetherInMemoryCacheinterrupt_before for conditional cases)| 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 |
add reducer (overwrites instead of accumulates)interrupt() in try/except (breaks the mechanism).result() on Functional API tasksset_entry_point() (deprecated, use add_edge(START, ...))See test-cases.json for consolidated test cases across all categories.
ork:agent-orchestration - Higher-level multi-agent coordination, ReAct loop patterns, and framework comparisonstemporal-io - Durable execution alternativeork:llm-integration - General LLM function callingtype-safety-validation - Pydantic model patternsWeekly Installs
80
Repository
GitHub Stars
134
First Seen
Feb 14, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
codex76
opencode75
gemini-cli74
github-copilot74
cursor69
kimi-cli67
AI Elements:基于shadcn/ui的AI原生应用组件库,快速构建对话界面
69,600 周安装
AI提示词查找与优化工具 - 搜索、获取、改进ChatGPT提示词模板
1,100 周安装
本地营销专家指南:Google商家优化、本地SEO与地理定位广告实战策略
80 周安装
Claude 代码插件技能开发指南 - 创建模块化AI技能扩展Claude能力
1,100 周安装
日历自动化:Google Calendar与Outlook会议管理、时间块划分、每日摘要同步工作流
1,200 周安装
agent-memory 技能 - AI 助手记忆管理工具 | 提升开发效率与代码协作
1,100 周安装
Claude智能体开发指南:创建自主AI助手,掌握agent-development核心技巧
1,100 周安装
add_messages| Custom Reducers | rules/state-reducers.md | Annotated[T, reducer_fn] for merge/overwrite |
Command(graph=Command.PARENT) for parent/sibling routing |
rules/tools-interrupts.md |
interrupt() for approval gates on tools |
Store for long-term memory across threads |
version="v2" for typed streaming (LG 1.1+) |
set_entry_point() (deprecated)| 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 |