Token导航 LogoToken导航

Agent Skill · 研究检索

langgraph-agent-patterns(langgraph Agent 模式)

langgraph-agent-patterns 用于查找、检索和筛选相关信息,适合在 Codex、Claude、Cursor、Gemini CLI 中需要根据关键词、任务场景或来源线索快速定位候选结果时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

langgraph-agent-patterns 是研究检索类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为操作浏览器;许可证信息还不明确,第三方扫描有提醒项,按安装量在研究检索类的 73,675 个 Skill 里排第 43,703。

总安装 964周安装 39GitHub Stars 94下载 303核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:langgraph-agent-patterns(langgraph Agent 模式)
来源仓库:https://github.com/lubu-labs/langchain-agent-skills
仓库路径:skills/langgraph-agent-patterns
安装命令:
npx skills add https://github.com/lubu-labs/langchain-agent-skills --skill langgraph-agent-patterns
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/lubu-labs/langchain-agent-skills --skill langgraph-agent-patterns

这个 Skill 是做什么的

研究检索类 Skill 主要解决「找资料、核对事实、把来源整理清楚」的问题,通常会让助手先检索再总结。

用于查找、检索和筛选相关信息,支持关键词和任务场景快速定位结果。适合在需要围绕仓库状态、代码变更或协作事项进行整理时使用。可结合来源仓库和原始 README 核验具体用法。

安装命令:npx skills add https://github.com/lubu-labs/langchain-agent-skills --skill langgraph-agent-patterns。安装前建议确认权限范围和维护状态,避免触发不必要操作。

来源仓库内路径:skills/langgraph-agent-patterns

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/lubu-labs/langchain-agent-skills --skill langg…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要操作浏览器,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

langgraph-agent-patterns 怎么安装?

在终端执行 npx skills add https://github.com/lubu-labs/langchain-agent-skills --skill langgraph-agent…。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

langgraph-agent-patterns 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

langgraph-agent-patterns 需要什么权限?

权限级别是操作浏览器。该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

langgraph-agent-patterns 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

langgraph-agent-patterns 用的人多吗?

公开数据是累计安装 964 次,近一周安装 39 次,下载 303 次,GitHub 94 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

langgraph-agent-patterns 安全吗?

第三方扫描有提醒项,说明存在需要人工确认的行为。安装前请打开源码看清它读了什么、联网到哪里。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方扫描存在提醒项或未通过项,需要人工逐条确认。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理研究检索类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

研究检索类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
find-skills

寻找技能 · Codex、Claude

31,199,81316,486操作浏览器MIT有提醒
self-improving-agent

自我改进 Agent · OpenClaw

16,464,0023,396接触敏感数据MIT-0通过
soultrace

灵魂追踪 · Codex、Claude

7,588,94412需要联网未明确有提醒
self-improving

自我完善 · OpenClaw

6,829,2841,046需要联网MIT-0通过
microsoft-foundry

微软代工厂 · Codex、Claude

6,614,144764调用外部服务未明确有提醒
langgraph-agent-patterns

langgraph Agent 模式 · 本页

96494操作浏览器未明确有提醒

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

LangGraph Agent Patterns

Implement and configure multi-agent coordination patterns for LangGraph applications.

Pattern Selection

Choose the right pattern based on your coordination needs:

PatternBest ForWhen to Use
SupervisorComplex workflows, dynamic routingAgents need to collaborate, routing is context-dependent
RouterSimple categorization, independent tasksOne-time routing, deterministic decisions
Orchestrator-WorkerParallel execution, high throughputIndependent subtasks, results need aggregation
HandoffsSequential workflows, context preservationClear sequence, each agent builds on previous

Quick Decision:

  • Dynamic routing needed? → Supervisor
  • Tasks can run in parallel? → Orchestrator-Worker
  • Simple categorization? → Router
  • Linear sequence? → Handoffs

For detailed comparison: See references/pattern-comparison.md

Pattern Implementation Guides

Supervisor-Subagent Pattern

Overview: Central coordinator delegates to specialized subagents based on context.

Quick Start:

# Generate supervisor graph boilerplate
uv run scripts/generate_supervisor_graph.py my-team \
  --subagents "researcher,writer,reviewer"

# TypeScript
uv run scripts/generate_supervisor_graph.py my-team \
  --subagents "researcher,writer,reviewer" \
  --typescript

Key Components:

  1. State with routing: next field for routing decisions
  2. Supervisor node: Makes routing decisions based on context
  3. Subagent nodes: Specialized agents with distinct capabilities
  4. Conditional edges: Route from supervisor to subagents

Example Flow:

User Request → Supervisor → Researcher → Supervisor → Writer → Supervisor → FINISH

For complete implementation: See references/supervisor-subagent.md

Router Pattern

Overview: One-time routing to specialized agents based on initial request.

Key Components:

  1. State with route: Single routing decision field
  2. Router node: Categorizes request (keyword, LLM, or semantic)
  3. Specialized agents: Independent agents for each category
  4. Conditional routing: Route to agent, then END

Example Flow:

User Request → Router → Sales Agent → END
                   ├→ Support Agent → END
                   └→ Billing Agent → END

Routing Strategies:

  • Keyword-based: Fast, simple string matching
  • LLM-based: Semantic understanding, flexible
  • Embedding-based: Similarity matching
  • Model-based: Fine-tuned classifier

For complete implementation: See references/router-pattern.md

Orchestrator-Worker Pattern

Overview: Decompose task into parallel subtasks, aggregate results.

Key Components:

  1. State with subtasks: Task decomposition and results accumulation
  2. Orchestrator node: Splits task into independent subtasks
  3. Worker nodes: Process subtasks in parallel
  4. Aggregator node: Synthesizes results
  5. Send fan-out: Return Send(...) objects from conditional edges and use a list reducer (for example Annotated[list[dict], operator.add]) so worker outputs accumulate

Example Flow:

Task → Orchestrator → Worker 1 ┐
                  → Worker 2  ├→ Aggregator → Result
                  → Worker 3 ┘

Best Practices:

  • Ensure subtasks are independent
  • Handle worker failures gracefully
  • Limit concurrent workers for resource management
  • Use LLM for result synthesis

For complete implementation: See references/orchestrator-worker.md

Handoffs Pattern

Overview: Sequential agent handoffs with context preservation.

Key Components:

  1. State with context: Shared context across handoffs
  2. Agent nodes: Each agent hands off to next
  3. Handoff logic: Explicit or conditional handoffs
  4. Context management: Preserve and pass information

Example Flow:

Request → Researcher → Writer → Editor → FINISH
         (with context preservation)

Handoff Strategies:

  • Explicit: Agent declares next agent
  • Conditional: Based on completion criteria
  • Circular: Agents can hand back for revisions

For complete implementation: See references/handoffs.md

Examples

Runnable mini-projects (Python + JavaScript):

  • assets/examples/supervisor-example/
  • assets/examples/router-example/
  • assets/examples/orchestrator-example/
  • assets/examples/handoff-example/

State Design for Multi-Agent Patterns

Each pattern requires specific state schema design:

Supervisor Pattern:

class SupervisorState(TypedDict):
    messages: Annotated[list[BaseMessage], add_messages]
    next: Literal["agent1", "agent2", "FINISH"]
    current_agent: str

Router Pattern:

class RouterState(TypedDict):
    messages: list[BaseMessage]
    route: Literal["category1", "category2"]

Orchestrator-Worker:

import operator
class OrchestratorState(TypedDict):
    task: str
    subtasks: list[dict]
    results: Annotated[list[dict], operator.add]

Handoffs:

class HandoffState(TypedDict):
    messages: Annotated[list[BaseMessage], add_messages]
    next_agent: str
    context: dict

For detailed state patterns: See references/state-management-patterns.md

Validation and Visualization

Validate Graph Structure

# Validate agent graph for issues
uv run scripts/validate_agent_graph.py path/to/graph.py:graph

# Checks for:
# - Unreachable nodes
# - Cycles without termination
# - Dead ends
# - Invalid routing

Visualize Graph

# Generate Mermaid diagram
uv run scripts/visualize_graph.py path/to/graph.py:graph --output diagram.md

# View in browser or IDE with Mermaid support

Common Patterns and Anti-Patterns

Best Practices

1. Clear Agent Responsibilities

  • Define non-overlapping capabilities
  • Document each agent's purpose
  • Avoid agent duplication

2. Loop Prevention

  • Track iteration count in state
  • Set maximum iterations
  • Implement loop detection

3. Context Management

  • Summarize context when it grows large
  • Only pass necessary information
  • Use structured context where possible

4. Error Handling

  • Validate routing decisions
  • Handle invalid routes gracefully
  • Default to safe fallbacks

Anti-Patterns to Avoid

1. Over-Supervision

# ❌ Bad: Supervisor for simple linear flow
User → Supervisor → Agent1 → Supervisor → Agent2 → Supervisor

# ✅ Good: Use handoffs instead
User → Agent1 → Agent2 → FINISH

2. Complex Router Logic

# ❌ Bad: Complex routing rules in router
if complex_condition_A and (condition_B or condition_C):
    route = determine_complex_route()

# ✅ Good: Use supervisor with LLM
route = llm.invoke("Analyze and route: {query}")

3. Unmanaged State Growth

# ❌ Bad: Accumulating all messages forever
messages: list[BaseMessage]  # Grows unbounded

# ✅ Good: Summarize or limit
if len(messages) > 20:
    messages = summarize_context(messages)

Debugging Multi-Agent Systems

1. Trace Agent Flow

Use LangSmith to visualize agent interactions:

import os
os.environ["LANGSMITH_TRACING"] = "true"
os.environ["LANGSMITH_API_KEY"] = "<your-api-key>"
os.environ["LANGSMITH_PROJECT"] = "multi-agent-debug"

result = graph.invoke(input_state)

2. Log Routing Decisions

Add logging to routing nodes:

def supervisor_node(state: SupervisorState) -> dict:
    decision = make_routing_decision(state)

    print(f"Supervisor routing to: {decision}")
    print(f"Current state: {len(state['messages'])} messages")
    print(f"Iteration: {state.get('iteration', 0)}")

    return {"next": decision}

3. Validate Graph Structure

# Detect common issues
uv run scripts/validate_agent_graph.py my_agent/graph.py:graph

# Check for:
# - Unreachable nodes
# - Infinite loops
# - Dead ends

4. Visualize Flow

# Generate diagram
uv run scripts/visualize_graph.py my_agent/graph.py:graph -o flow.md

Performance Optimization

Latency Optimization

Supervisor Pattern:

  • Use faster models for routing (gpt-4o-mini)
  • Cache routing decisions
  • Implement early termination

Router Pattern:

  • Use keyword matching for simple cases
  • Cache routing for similar queries
  • Avoid LLM calls when possible

Orchestrator-Worker:

  • True parallelization already optimal
  • Limit worker count to avoid rate limits
  • Stream results to aggregator

Handoffs:

  • Minimize context size
  • Skip unnecessary handoffs
  • Use cheaper models where appropriate

Cost Optimization

Token Usage:

  • Summarize context regularly
  • Use structured output for reliability
  • Employ cheaper models for simple tasks

LLM Calls:

  • Cache routing decisions
  • Use deterministic logic when possible
  • Batch similar requests

Pattern Selection:

  • Router < Handoffs < Orchestrator < Supervisor (cost)

Testing Multi-Agent Patterns

Unit Test Routing Logic

def test_supervisor_routing():
    """Test supervisor routes correctly."""
    state = {
        "messages": [HumanMessage(content="Need research")],
        "next": "",
        "current_agent": ""
    }

    result = supervisor_node(state)
    assert result["next"] == "researcher"

Integration Testing

def test_full_workflow():
    """Test complete multi-agent workflow."""
    graph = create_supervisor_graph()

    result = graph.invoke({
        "messages": [HumanMessage(content="Write article about AI")]
    })

    # Verify agents were called in correct order
    assert "researcher" in result["agent_history"]
    assert "writer" in result["agent_history"]

Test Graph Structure

# Validate before deployment
python3 scripts/validate_agent_graph.py graph.py:graph

Migration Between Patterns

Router to Supervisor

When routing logic becomes complex:

# Before: Complex router
def route(query):
    if complex_rules(query):
        return category

# After: Supervisor with LLM
def supervisor(state):
    return llm_routing_decision(state)

Handoffs to Supervisor

When need dynamic routing:

# Before: Fixed sequence
Agent1 → Agent2 → Agent3

# After: Dynamic routing
Supervisor ⇄ Agent1/Agent2/Agent3

Sequential to Parallel

When tasks become independent:

# Before: Sequential
Agent1 → Agent2 → Agent3

# After: Parallel
Orchestrator → [Agent1, Agent2, Agent3] → Aggregator

Common Use Cases

Customer Support System

Pattern: Router + Supervisor

Router → Sales Supervisor → Sales Agents
     ↓
     Support Supervisor → Support Agents

Research & Writing Pipeline

Pattern: Supervisor or Handoffs

Supervisor ⇄ Researcher
         ⇄ Writer
         ⇄ Editor

Data Analysis Pipeline

Pattern: Orchestrator-Worker

Orchestrator → Data Collectors → Aggregator

Document Processing

Pattern: Orchestrator-Worker + Supervisor

Router → PDF Orchestrator → Workers → Aggregator
     ↓
     DOCX Orchestrator → Workers → Aggregator

Scripts Reference

generate_supervisor_graph.py

Generate supervisor-subagent boilerplate:

uv run scripts/generate_supervisor_graph.py <name> [options]

Options:
  --subagents AGENTS    Comma-separated list (default: researcher,writer,reviewer)
  --output DIR          Output directory (default: current directory)
  --typescript          Generate TypeScript instead of Python

validate_agent_graph.py

Validate graph structure:

uv run scripts/validate_agent_graph.py <module_path>

Format: path/to/module.py:graph_name

Checks:
  - Unreachable nodes
  - Cycles
  - Dead ends
  - Invalid routing

visualize_graph.py

Generate Mermaid diagrams:

uv run scripts/visualize_graph.py <module_path> [options]

Options:
  --output FILE         Output file (default: stdout)
  --diagram-only        Skip documentation, output diagram only

Troubleshooting

"Agents not coordinating correctly"

Check:

  1. State schema supports your pattern (see state-management-patterns.md)
  2. Routing logic validates correctly
  3. Context is preserved across agents

"Infinite loops detected"

Solutions:

  1. Add iteration counter to state
  2. Implement max iteration limit
  3. Add loop detection logic
  4. Validate with validate_agent_graph.py

"Poor routing decisions"

Solutions:

  1. Improve supervisor prompt with clear agent descriptions
  2. Use structured output for reliability
  3. Add examples to routing prompt
  4. Use better model for routing decisions

"High latency"

Solutions:

  1. Consider router pattern for simple cases
  2. Use faster models for routing
  3. Implement parallel execution where possible
  4. Cache routing decisions

"High token usage"

Solutions:

  1. Summarize context regularly
  2. Use cheaper models for simple tasks
  3. Implement context windowing
  4. Choose more efficient pattern

Additional Resources

  • Pattern Details:

- Supervisor: references/supervisor-subagent.md - Router: references/router-pattern.md - Orchestrator-Worker: references/orchestrator-worker.md - Handoffs: references/handoffs.md

  • State Management: references/state-management-patterns.md
  • Pattern Comparison: references/pattern-comparison.md
  • Working Examples: assets/examples/
  • LangGraph Documentation:

- Multi-Agent Patterns: https://docs.langchain.com/oss/python/langchain/multi-agent/subagents-personal-assistant; https://docs.langchain.com/oss/python/langchain/multi-agent/handoffs-customer-support; https://docs.langchain.com/oss/python/langchain/multi-agent/router-knowledge-base - Conditional Edges: https://docs.langchain.com/oss/python/langgraph/graph-api - Map-Reduce: https://docs.langchain.com/oss/python/langgraph/graph-api#map-reduce-and-the-send-api

平台分布

Codex

34.74%
按下载量换算105

Claude

30.62%
按下载量换算93

Cursor

20.01%
按下载量换算61

Gemini CLI

10.63%
按下载量换算32

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在提醒或未通过项,安装前请自行复核。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills