目 录CONTENT

文章目录

Agent 框架 2026 横评:LangGraph vs CrewAI vs Google ADK vs OpenAI Agents SDK

PySuper
2026-04-18 / 0 评论 / 0 点赞 / 1 阅读 / 0 字
温馨提示:
本文最后更新于2026-05-22,若内容或图片失效,请留言反馈。 所有牛逼的人都有一段苦逼的岁月。 但是你只要像SB一样去坚持,终将牛逼!!! ✊✊✊

作者:PySuper | 来源:zhengxingtao.com

选 Agent 框架比选模型还纠结。2026 年四大主流框架各有拥趸:LangGraph 说"我最稳",CrewAI 说"我最简单",Google ADK 说"我有 A2A",OpenAI Agents SDK 说"我最轻"。到底选谁?这篇文章不站队,只做一件事:用同一个任务,四种框架各实现一遍,用代码说话。

一、2026 四大主流 Agent 框架全景

1.1 一句话定位

plaintext

LangGraph ────── 状态机驱动,精细控制,企业级首选
CrewAI ───────── 角色制编排,直觉映射团队协作,快速原型
Google ADK ───── 代码优先,A2A 原生,GCP 生态深度绑定
OpenAI Agents SDK ── 轻量多 Agent,沙箱执行,OpenAI 栈最顺滑

1.2 关键数据

表格

指标

LangGraph

CrewAI

Google ADK

OpenAI Agents SDK

GitHub Stars

24.8K

44.3K

17.8K

19K

月下载量

34.5M

5.2M

3.3M

10.3M

开源协议

MIT

MIT

Apache 2.0

Apache 2.0

首次发布

2024

2024初

2025.4

2025.3

当前版本

1.0+

1.9.3

1.0 GA

0.x

语言

Python

Python

Python/Go/Java/TS

Python

依赖

LangChain

独立

Google Cloud

OpenAI API

1.3 市场格局

plaintext

                    灵活性/控制力
                         ▲
                         │
              LangGraph  │
                ●        │
                         │
         ┌───────────────┼───────────────┐
         │               │               │
    Google│               │          OpenAI│
     ADK  │               │        Agents │
      ●   │               │          SDK  │
         │               │            ●   │
         │       CrewAI  │               │
         │         ●     │               │
         └───────────────┼───────────────┘
                         │
                         ▼
                    简单性/上手速度

二、LangGraph:状态机驱动的精密机器

2.1 核心理念

LangGraph 把 Agent 工作流建模为有向图:节点是处理步骤,边是状态转换。这给了你最细粒度的控制——但也意味着你需要"像画流程图一样思考"。

plaintext

┌──────────┐    ┌──────────┐    ┌──────────┐
│ Research │───→│ Analyze  │───→│ Report   │
│  Node    │    │  Node    │    │  Node    │
└──────────┘    └────┬─────┘    └──────────┘
                     │
                     ▼ 条件边
               ┌──────────┐
               │  Retry   │───→ 回到 Analyze
               │  Node    │
               └──────────┘

2.2 关键特性

  • 持久状态:内置 Checkpointing,支持时间旅行调试

  • Human-in-the-Loop:一等公民支持人工审批节点

  • 流式输出:逐节点 token 流式

  • LangSmith 集成:生产级可观测性

  • MCP 原生支持:通过 langchain-mcp-adapters

2.3 生产案例

表格

公司

场景

效果

Klarna

客服机器人

处理 2/3 客户咨询,节省 $60M

Uber

大规模代码迁移

单仓库跨团队 Agent 驱动

LinkedIn

SQL 助手

自然语言转 SQL 查询

Replit

编码 Agent

IDE 内代码生成

2.4 局限性

  • 学习曲线陡峭:需要图思维,不是所有人都能适应

  • 简单任务过重:对"调用一个 API 返回结果"这种场景,抽象层太多

  • LangChain 生态绑定:虽然 LangGraph 可以独立使用,但和 LangChain 配合最好

三、CrewAI:角色制的直觉映射

3.1 核心理念

CrewAI 的哲学是:像管团队一样管 Agent。每个 Agent 有角色(role)、目标(goal)、背景故事(backstory),就像给员工写 JD。

python

researcher = Agent(
    role="Senior Research Analyst",
    goal="Find comprehensive, accurate information",
    backstory="15年研究经验,擅长从噪音中提取信号"
)

这种设计对非技术人员非常友好——产品经理也能看懂你的 Agent 架构。

3.2 四层抽象

plaintext

┌─────────────────────────────────────────┐
│                Crew (团队)                │
│  ┌─────────────────────────────────────┐ │
│  │          Process (流程)              │ │
│  │  ┌───────────┐    ┌───────────┐    │ │
│  │  │  Task 1   │───→│  Task 2   │    │ │
│  │  └─────┬─────┘    └───────────┘    │ │
│  │        │                            │ │
│  │  ┌─────▼─────┐                     │ │
│  │  │  Agent    │ ← role/goal/story   │ │
│  │  └───────────┘                     │ │
│  └─────────────────────────────────────┘ │
└─────────────────────────────────────────┘

表格

概念

说明

类比

Agent

角色化的执行者

员工

Task

具体任务

任务单

Crew

Agent + Task 的容器

团队

Process

执行模式(串行/层级)

管理方式

3.3 关键特性

  • 完全独立:不依赖 LangChain 或任何其他框架

  • 极简上手:20 行代码可以跑一个多 Agent 系统

  • MIT 开源:无商业限制

  • 记忆系统:短期/长期/实体记忆三层

  • A2A 支持:1.8.0+ 原生支持 A2A 协议

3.4 局限性

  • 精细控制弱:没有图结构,条件路由不如 LangGraph

  • Check pointing 缺失:长时运行工作流缺少断点续跑

  • 生产验证不足:社区中缺少大规模生产环境的深度案例

  • 隐私争议:Trustpilot 上有用户投诉未经同意收集使用数据

四、Google ADK:代码优先的 Google 生态入口

4.1 核心理念

Google ADK(Agent Development Kit)是一个代码优先的 Python 框架,2025 年 4 月发布,2026 年达到 1.0 GA。它的差异化在于:

  1. 原生 A2A 集成:ADK Agent 可以直接通过 A2A 协议与其他框架的 Agent 通信

  2. 四语言支持:Python、Go、Java、TypeScript

  3. Vertex AI 深度绑定:Gemini 模型、Google Cloud 服务一站式

4.2 架构设计

plaintext

┌──────────────────────────────────────────┐
│             Google ADK Agent             │
│                                          │
│  ┌──────────────────────────────────┐   │
│  │         Root Agent (Supervisor)  │   │
│  │  ┌──────────┐  ┌──────────┐     │   │
│  │  │ Sub-Agent│  │ Sub-Agent│     │   │
│  │  │ (Worker) │  │ (Worker) │     │   │
│  │  └──────────┘  └──────────┘     │   │
│  └──────────────────────────────────┘   │
│                                          │
│  ┌──────────────────────────────────┐   │
│  │        A2A Protocol Layer        │   │
│  │  ←→ LangGraph Agent             │   │
│  │  ←→ CrewAI Agent                │   │
│  │  ←→ Any A2A-compatible Agent    │   │
│  └──────────────────────────────────┘   │
│                                          │
│  ┌──────────────────────────────────┐   │
│  │        Google Cloud Services     │   │
│  │  ├── Vertex AI (Gemini)          │   │
│  │  ├── Cloud Storage              │   │
│  │  ├── BigQuery                   │   │
│  │  └── Cloud Run                  │   │
│  └──────────────────────────────────┘   │
└──────────────────────────────────────────┘

4.3 关键特性

  • 层级 Agent 树:Root Agent → Sub-Agent → Sub-Sub-Agent

  • A2A 原生:ADK Agent 开箱即支持 A2A 协议

  • 多模态:Gemini 原生支持图像/音频/视频输入

  • Session State:内置会话状态管理,支持多种后端

  • 少于 100 行代码:官方宣称核心功能不超过 100 行

4.4 局限性

  • Google Cloud 绑定:Vertex AI 深度绑定,迁移成本高

  • 生态年轻:第三方教程、集成、生产案例较少

  • 学习曲线中高:需要 Google Cloud 生态知识

  • 社区规模小:相比 LangGraph 和 CrewAI,社区还在成长期

五、OpenAI Agents SDK:轻量高效的多 Agent 框架

5.1 核心理念

OpenAI Agents SDK 的哲学是:做最少的事,让模型做最多的事。它不提供图结构、不提供角色抽象,而是用最简单的 Agent + Handoff 模型实现多 Agent 协作。

python

from openai_agents import Agent, Runner

analyst = Agent(name="Analyst", instructions="...", tools=[...])
writer = Agent(name="Writer", instructions="...", handoffs=[analyst])

result = Runner.run_sync(writer, input="Research AI trends")

5.2 架构设计

plaintext

┌────────────────────────────────────────────┐
│           OpenAI Agents SDK                 │
│                                             │
│  ┌───────────┐    handoff    ┌───────────┐ │
│  │  Agent A  │──────────────→│  Agent B  │ │
│  │           │               │           │ │
│  │  tools:   │               │  tools:   │ │
│  │  [f1, f2] │               │  [f3, f4] │ │
│  └───────────┘               └───────────┘ │
│        │                           │        │
│        └───────────┬───────────────┘        │
│                    │                        │
│              ┌─────▼─────┐                  │
│              │  Runner   │                  │
│              │  (Loop)   │                  │
│              └───────────┘                  │
│                                             │
│  ┌───────────────────────────────────┐      │
│  │         Harness 架构              │      │
│  │  ├── 沙箱执行环境                │      │
│  │  ├── 内置 Tracing                │      │
│  │  ├── Guardrails                  │      │
│  │  └── 100+ 模型支持              │      │
│  └───────────────────────────────────┘      │
└────────────────────────────────────────────┘

5.3 关键特性

  • Provider-agnostic:虽然名字叫 OpenAI,但支持 100+ 模型

  • 沙箱执行:内置代码沙箱,安全执行 Agent 生成的代码

  • Guardrails:内置输入/输出护栏

  • Tracing:内置追踪,可接入 OpenAI Platform

  • MCP 支持:原生支持 MCP 工具集成

5.4 局限性

  • Handoff 模型简单:不如 LangGraph 的条件边灵活

  • 长时状态弱:默认没有 Checkpointing

  • OpenAI 栈最顺:虽然 provider-agnostic,但和 OpenAI 模型配合最好

  • 社区较小:相比 LangGraph,社区规模仍在增长

六、八维度对比

6.1 对比总表

表格

维度

LangGraph

CrewAI

Google ADK

OpenAI Agents SDK

设计哲学

图驱动的精细控制

角色直觉的团队映射

代码优先的 GCP 集成

轻量极简的 Handoff

学习曲线

高(图思维)

低(直觉映射)

中高(GCP 知识)

低(干净 API)

灵活性

★★★★★

★★★

★★★★

★★★

生产就绪

★★★★★

★★★

★★★

★★★★

生态规模

★★★★★

★★★★

★★★

★★★★

模型支持

全模型

全模型

Gemini 最优

100+ 模型

可观测性

LangSmith ★★★★★

AMP Suite ★★★

Vertex AI ★★★★

内置 Tracing ★★★★

社区

最大

活跃

成长中

增长快

6.2 逐维度分析

设计哲学

plaintext

LangGraph:   "一切皆图,边是逻辑" ── 工程师思维
CrewAI:      "Agent 是角色,Crew 是团队" ── 产品思维
Google ADK:  "代码优先,GCP 原生" ── 云原生思维
OpenAI SDK:  "最少抽象,让模型决定" ── 极简思维

学习曲线

plaintext

上手时间(实现一个简单的 2-Agent 工作流):
├── CrewAI:      30分钟  ← 最快
├── OpenAI SDK:  1小时
├── Google ADK:  2-3小时
└── LangGraph:   4-6小时  ← 最慢,但学会后最灵活

灵活性

plaintext

条件路由能力:
├── LangGraph:   任意边,条件边,循环边 ── 完全自由
├── Google ADK:  层级委派 ── 较灵活
├── OpenAI SDK:  Handoff 链 ── 简单但受限
└── CrewAI:      Sequential/Hierarchical ── 两种固定模式

七、实战对比:同一个"研究助手"任务

7.1 任务定义

实现一个"研究助手":用户输入一个主题,系统安排研究员搜索信息,然后安排写手生成报告。

7.2 LangGraph 实现

python

"""
研究助手 - LangGraph 实现
状态机驱动,精细控制
"""

from typing import TypedDict, Annotated
from langgraph.graph import StateGraph, END
from langgraph.graph.message import add_messages
from langchain_openai import ChatOpenAI
from langchain_core.messages import HumanMessage, SystemMessage


# ============================================================
# 1. 定义状态
# ============================================================

class ResearchState(TypedDict):
    """工作流状态"""
    messages: Annotated[list, add_messages]
    topic: str
    research_notes: str
    final_report: str
    iteration: int


# ============================================================
# 2. 定义节点
# ============================================================

llm = ChatOpenAI(model="gpt-4o", temperature=0)


def research_node(state: ResearchState) -> dict:
    """研究节点:搜索和分析信息"""
    system_prompt = """你是一位资深研究分析师。
    请对给定主题进行深入研究,提供关键发现、数据点和可信来源。
    输出格式:结构化的研究笔记,包含要点和来源。"""
    
    messages = [
        SystemMessage(content=system_prompt),
        HumanMessage(content=f"研究主题:{state['topic']}")
    ]
    
    response = llm.invoke(messages)
    
    return {
        "research_notes": response.content,
        "messages": [response],
        "iteration": state.get("iteration", 0) + 1
    }


def write_node(state: ResearchState) -> dict:
    """写作节点:基于研究生成报告"""
    system_prompt = """你是一位技术写作专家。
    请基于提供的研究笔记,撰写一份结构清晰、内容丰富的报告。
    报告应包含:摘要、主要发现、详细分析、结论。"""
    
    messages = [
        SystemMessage(content=system_prompt),
        HumanMessage(content=f"""
研究笔记:
{state['research_notes']}

请基于以上研究笔记,撰写关于"{state['topic']}"的报告。
""")
    ]
    
    response = llm.invoke(messages)
    
    return {
        "final_report": response.content,
        "messages": [response]
    }


def review_node(state: ResearchState) -> dict:
    """审核节点:检查报告质量"""
    system_prompt = """你是质量审核员。
    检查报告是否完整、准确、结构良好。
    如果质量合格,回复 APPROVED。
    如果需要修改,回复 NEEDS_REVISION 并说明原因。"""
    
    messages = [
        SystemMessage(content=system_prompt),
        HumanMessage(content=f"请审核以下报告:\n\n{state['final_report']}")
    ]
    
    response = llm.invoke(messages)
    
    return {"messages": [response]}


# ============================================================
# 3. 定义条件边
# ============================================================

def should_revise(state: ResearchState) -> str:
    """判断是否需要修改"""
    last_message = state["messages"][-1].content
    if "APPROVED" in last_message:
        return "end"
    return "revise"


# ============================================================
# 4. 构建图
# ============================================================

workflow = StateGraph(ResearchState)

# 添加节点
workflow.add_node("research", research_node)
workflow.add_node("write", write_node)
workflow.add_node("review", review_node)

# 添加边
workflow.set_entry_point("research")
workflow.add_edge("research", "write")
workflow.add_edge("write", "review")

# 条件边:审核通过则结束,否则回到写作
workflow.add_conditional_edges(
    "review",
    should_revise,
    {
        "end": END,
        "revise": "write"
    }
)

# 编译
app = workflow.compile()


# ============================================================
# 5. 运行
# ============================================================

if __name__ == "__main__":
    result = app.invoke({
        "topic": "2026年AI Agent框架的发展趋势",
        "messages": [],
        "research_notes": "",
        "final_report": "",
        "iteration": 0
    })
    
    print("=" * 60)
    print("最终报告:")
    print(result["final_report"])

7.3 CrewAI 实现

python

"""
研究助手 - CrewAI 实现
角色制编排,直觉映射
"""

import os
from crewai import Agent, Task, Crew, Process, LLM


# ============================================================
# 1. 配置 LLM
# ============================================================

llm = LLM(model="gpt-4o", temperature=0)


# ============================================================
# 2. 定义 Agent(角色)
# ============================================================

researcher = Agent(
    role="Senior Research Analyst",
    goal="Conduct thorough research on the given topic and provide comprehensive findings",
    backstory="""You are a veteran research analyst with 15 years of experience.
    You excel at finding accurate information from credible sources.
    You never fabricate information — if you cannot verify a claim, you flag it.""",
    llm=llm,
    verbose=True,
    allow_delegation=False,
    max_iter=25
)

writer = Agent(
    role="Technical Content Strategist",
    goal="Transform research findings into a well-structured, insightful report",
    backstory="""You are a skilled technical writer who translates complex research
    into clear, compelling reports. You use short paragraphs, concrete examples,
    and avoid jargon unless defined first.""",
    llm=llm,
    verbose=True,
    allow_delegation=False,
    max_iter=20
)

reviewer = Agent(
    role="Quality Assurance Editor",
    goal="Ensure the report meets quality standards for accuracy and clarity",
    backstory="""You are a meticulous editor with an eye for detail.
    You check facts, structure, and readability.
    You provide specific, actionable feedback for improvement.""",
    llm=llm,
    verbose=True,
    allow_delegation=False,
    max_iter=15
)


# ============================================================
# 3. 定义 Task(任务)
# ============================================================

research_task = Task(
    description="""Research the topic: {topic}
    
    Focus on:
    1. Key trends and developments in 2025-2026
    2. Major players and their strategies
    3. Technical innovations and breakthroughs
    4. Market data and projections
    5. Challenges and opportunities
    
    Provide a structured research brief with at least 10 key findings,
    each with its source or basis.""",
    expected_output="A structured research brief with key findings, data points, and sources",
    agent=researcher
)

write_task = Task(
    description="""Based on the research findings, write a comprehensive report on: {topic}
    
    The report should include:
    1. Executive Summary
    2. Key Findings
    3. Detailed Analysis
    4. Future Outlook
    5. Conclusion
    
    Use the research notes provided by the research analyst.
    Write in a professional yet accessible tone.""",
    expected_output="A well-structured Markdown report suitable for a technical audience",
    agent=writer,
    context=[research_task]  # 接收研究任务的输出
)

review_task = Task(
    description="""Review the report on: {topic}
    
    Check for:
    1. Accuracy and completeness of information
    2. Logical structure and flow
    3. Clarity and readability
    4. Proper attribution of sources
    
    If the report meets quality standards, approve it.
    If not, provide specific feedback for revision.""",
    expected_output="An approved final report or specific revision feedback",
    agent=reviewer,
    context=[write_task]  # 接收写作任务的输出
)


# ============================================================
# 4. 组装 Crew(团队)
# ============================================================

research_crew = Crew(
    agents=[researcher, writer, reviewer],
    tasks=[research_task, write_task, review_task],
    process=Process.sequential,  # 串行执行
    verbose=True
)


# ============================================================
# 5. 运行
# ============================================================

if __name__ == "__main__":
    result = research_crew.kickoff(
        inputs={"topic": "2026年AI Agent框架的发展趋势"}
    )
    
    print("=" * 60)
    print("最终报告:")
    print(result.raw)

7.4 Google ADK 实现

python

"""
研究助手 - Google ADK 实现
代码优先,层级 Agent,A2A 原生
"""

from google.adk import Agent, Runner, SessionService
from google.adk.tools import google_search  # Google 搜索工具
from google.adk.sessions import InMemorySessionService


# ============================================================
# 1. 定义子 Agent
# ============================================================

research_agent = Agent(
    name="research_agent",
    model="gemini-2.0-flash",
    instruction="""You are a senior research analyst.
    Conduct thorough research on the given topic.
    Use the search tool to find the latest information.
    Provide structured findings with sources.""",
    tools=[google_search]
)

write_agent = Agent(
    name="write_agent",
    model="gemini-2.0-flash",
    instruction="""You are a technical content strategist.
    Based on the research findings provided, write a comprehensive report.
    Include: Executive Summary, Key Findings, Analysis, Future Outlook, Conclusion."""
)

review_agent = Agent(
    name="review_agent",
    model="gemini-2.0-flash",
    instruction="""You are a quality assurance editor.
    Review the report for accuracy, completeness, and clarity.
    Approve if it meets standards, or provide revision feedback."""
)


# ============================================================
# 2. 定义 Root Agent(编排者)
# ============================================================

root_agent = Agent(
    name="research_orchestrator",
    model="gemini-2.0-flash",
    instruction="""You are an orchestrator for research tasks.
    When given a topic:
    1. Delegate to research_agent to gather information
    2. Pass research results to write_agent to create report
    3. Have review_agent check the quality
    4. Return the final approved report
    
    Coordinate the workflow and ensure quality delivery.""",
    sub_agents=[research_agent, write_agent, review_agent]
)


# ============================================================
# 3. 运行
# ============================================================

if __name__ == "__main__":
    session_service = InMemorySessionService()
    runner = Runner(
        agent=root_agent,
        session_service=session_service,
        app_name="research-assistant"
    )
    
    result = runner.run(
        user_id="user-001",
        session_id="session-001",
        message="研究主题:2026年AI Agent框架的发展趋势"
    )
    
    print("=" * 60)
    print("最终报告:")
    print(result.text)

7.5 OpenAI Agents SDK 实现

python

"""
研究助手 - OpenAI Agents SDK 实现
轻量 Handoff,极简代码
"""

import asyncio
from openai import OpenAI
from agents import Agent, Runner, function_tool, handoff


# ============================================================
# 1. 定义工具
# ============================================================

@function_tool
def search_web(query: str) -> str:
    """Search the web for information on a topic."""
    # 实际实现中调用搜索 API
    return f"Search results for: {query}"


@function_tool
def save_report(content: str, filename: str) -> str:
    """Save the report to a file."""
    with open(filename, "w") as f:
        f.write(content)
    return f"Report saved to {filename}"


# ============================================================
# 2. 定义 Agent
# ============================================================

research_agent = Agent(
    name="Research Analyst",
    instructions="""You are a senior research analyst.
    Use the search tool to find comprehensive information on the given topic.
    Provide structured findings with key points and sources.
    When research is complete, hand off to the writer agent.""",
    tools=[search_web],
    model="gpt-4o"
)

review_agent = Agent(
    name="Quality Reviewer",
    instructions="""You are a quality assurance editor.
    Review the report for accuracy, completeness, and clarity.
    If it meets standards, approve it.
    If not, provide specific feedback and hand off back to the writer.""",
    model="gpt-4o"
)

writer_agent = Agent(
    name="Technical Writer",
    instructions="""You are a technical content strategist.
    Based on the research findings, write a comprehensive report.
    Include: Executive Summary, Key Findings, Analysis, Future Outlook.
    After writing, hand off to the reviewer for quality check.""",
    tools=[save_report],
    handoffs=[review_agent],
    model="gpt-4o"
)

# 设置 handoff 链
research_agent.handoffs = [writer_agent]
review_agent.handoffs = [writer_agent]  # 如果需要修改,交回写手


# ============================================================
# 3. 运行
# ============================================================

async def main():
    result = await Runner.run(
        starting_agent=research_agent,
        input="研究主题:2026年AI Agent框架的发展趋势"
    )
    
    print("=" * 60)
    print("最终报告:")
    print(result.final_output)


if __name__ == "__main__":
    asyncio.run(main())

7.6 四种实现对比

表格

维度

LangGraph

CrewAI

Google ADK

OpenAI SDK

代码行数

~120 行

~80 行

~60 行

~70 行

学习成本

条件路由

★★★★★

★★

★★★

★★

可观测性

LangSmith

AMP

Vertex AI

内置

模型自由度

全模型

全模型

Gemini 最优

100+ 模型

部署复杂度

中高(GCP)

八、选型指南

8.1 决策矩阵

plaintext

你是什么团队?
│
├── 小团队 / 个人开发者
│   ├── 快速验证想法 → CrewAI ✅
│   ├── OpenAI 栈用户 → OpenAI Agents SDK ✅
│   └── 需要精细控制 → LangGraph ✅
│
├── 中型技术团队
│   ├── 已有 LangChain 生态 → LangGraph ✅
│   ├── 需要 GCP 集成 → Google ADK ✅
│   └── 重视开发体验 → CrewAI ✅
│
└── 大型企业
    ├── 金融/医疗/合规 → LangGraph ✅(审计+状态管理)
    ├── Google Cloud 用户 → Google ADK ✅
    ├── OpenAI 企业客户 → OpenAI Agents SDK ✅
    └── 多框架协作 → Google ADK(A2A) ✅

8.2 什么场景选什么

表格

场景

推荐

理由

快速 PoC / Demo

CrewAI

20 行代码跑通多 Agent

复杂工作流 / 条件路由

LangGraph

图结构天然支持

金融/合规/审计

LangGraph

Checkpointing + LangSmith

Google Cloud 生态

Google ADK

Vertex AI + A2A

OpenAI 模型为主

OpenAI Agents SDK

最顺滑的集成

跨框架 Agent 协作

Google ADK + A2A

唯一原生 A2A 支持

内容生产流水线

CrewAI

角色映射最直觉

编码 Agent / 沙箱执行

OpenAI Agents SDK

内置沙箱

大规模生产部署

LangGraph

最成熟的可观测性

8.3 什么阶段选什么

plaintext

阶段1: 探索期(0-3个月)
├── 用 CrewAI 快速验证
└── 或 OpenAI Agents SDK 极简起步

阶段2: 验证期(3-6个月)
├── 核心工作流迁移到 LangGraph
└── 或 Google ADK(如果是 GCP 用户)

阶段3: 生产期(6个月+)
├── LangGraph + LangSmith(可观测性)
├── 可能引入 ADK 做 A2A 协作
└── 保留 CrewAI 做快速原型

九、踩坑记录

坑1:LangGraph 的无限循环

plaintext

场景: 条件边配置不当,Agent 在两个节点间无限循环
现象: 研究节点 → 写作节点 → 审核节点 → 写作节点 → 审核节点 → ...
修复: 设置 recursion_limit,并在审核节点增加最大迭代计数
教训: LangGraph 的循环能力是双刃剑,务必设上限

python

# 修复:设置递归限制
app = workflow.compile(
    checkpointer=memory_checkpointer,
    interrupt_before=["review"],  # 关键步骤前暂停
)

# 运行时限制
config = {"recursion_limit": 10}  # 最多 10 步
result = app.invoke(initial_state, config=config)

坑2:CrewAI 的无限委派循环

plaintext

场景: 允许委派的 Agent 互相踢皮球
现象: [Manager] → delegates to [Researcher]
      [Researcher] → delegates back to [Manager]
      [Manager] → delegates to [Researcher]
修复: 设置 allow_delegation=False,或限制委派次数
教训: CrewAI 的委派是"委托"不是"甩锅",要设边界

坑3:Google ADK 的 Vertex AI 冷启动

plaintext

场景: ADK Agent 首次调用 Vertex AI 端点
现象: 冷启动延迟高达 30-60 秒,用户以为系统挂了
修复: 预热端点,使用 Cloud Run min_instances=1
教训: GCP 的 Serverless 不等于即时响应,生产环境要预热

坑4:OpenAI Agents SDK 的模型绑定

plaintext

场景: 团队想用 Claude 替代 GPT-4o
问题: 虽然声称 provider-agnostic,但 Handoff 和 Guardrails 对 OpenAI 模型优化最好
表现: 用 Claude 做 Handoff 时,指令遵循度下降约 20%
修复: 如果用非 OpenAI 模型,增加更详细的 instructions
教训: "支持"和"优化"是两回事,非 OpenAI 模型需要更多调教

坑5:CrewAI 的记忆系统不可控

plaintext

场景: 长期记忆积累了过时信息,影响新任务执行
问题: CrewAI 的长期记忆默认永久保存,没有 TTL
修复: 定期清理长期记忆,或在 Task 级别控制 memory=True/False
教训: 记忆不是越多越好,过时记忆比没有记忆更糟

坑6:框架混用时的状态传递

plaintext

场景: LangGraph 编排 + CrewAI 子团队 + ADK A2A 通信
问题: 三种框架的状态格式不兼容
修复: 定义统一的 JSON 状态 schema,各框架各自适配
教训: 混用框架时,状态格式统一比框架选择更重要

十、我的判断

10.1 没有银弹

每个框架都在特定场景下最优:

plaintext

CrewAI     → 快速原型,内容生产,小团队
LangGraph  → 复杂工作流,企业级生产,合规场景
Google ADK → GCP 生态,A2A 协作,多模态
OpenAI SDK → OpenAI 栈,轻量场景,编码 Agent

10.2 2026 下半年的趋势

  1. LangGraph 继续是企业首选:Klarna/Uber/LinkedIn 等大厂背书 + LangSmith 可观测性

  2. CrewAI 在快速迭代:A2A 支持、Flows 架构、AMP 企业套件密集落地

  3. Google ADK 的 A2A 优势会放大:跨框架协作是刚需,ADK 目前唯一原生支持

  4. OpenAI Agents SDK 会继续增长:OpenAI 品牌效应 + 简单 API

10.3 实际建议

如果你是新手:从 CrewAI 开始,20 分钟跑通第一个多 Agent 系统。

如果你在做生产系统:认真评估 LangGraph,它的 Checkpointing、Time Travel、LangSmith 可观测性是其他框架目前比不了的。

如果你在 GCP 生态:Google ADK 是最自然的选择,A2A 原生支持是杀手锏。

如果你是 OpenAI 重度用户:OpenAI Agents SDK 最顺滑,但要注意模型绑定风险。

本文由 PySuper 撰写,首发于 zhengxingtao.com

参考来源:

  • 据《The best open source frameworks for building AI agents in 2026》(Firecrawl, 2026-05-18)

  • 据《Agentic AI Frameworks in 2026: The Production Comparison》(Uvik, 2026-04-23)

  • 据《AI Agent开发框架深度调研报告》(CSDN, 2026-05-16)

  • 据《Best Multi-Agent Frameworks in 2026》(Gurusup, 2026-05-02)

0
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区