Agent Setup 是一个面向 AI Agent 工程实践的分阶段训练仓库,核心目标是把“可运行示例 + 工程化脚手架 + 多框架对照学习”落到同一工作区。 它解决了学习路径碎片化、环境复现不稳定、跨框架迁移成本高这三类常见痛点,并面向个人开发者、小团队内部培训和 PoC 原型验证场景。 当前主线已形成从单 Agent Tool Calling,到 Workflow Orchestration,再到多 Agent + MCP 集成的闭环演进链路。
- Tool Calling 闭环实现清晰:
exercises/01-langchain-basics/01_hello_agent.py中完整演示了tool_calls -> ToolMessage 回填 -> 最终回答的三段式执行链。 - Graph 路由与循环模式可观测:
exercises/02-langgraph-workflow/01_simple_graph.py覆盖顺序图、条件路由(add_conditional_edges)和 ReAct 循环(agent-tool-agent)。 - 多 Agent 分工策略对照充分:
exercises/03-crewai-multiagent/01_research_crew.py同时提供 sequential、hierarchical 与 flow/router 三种编排形态。 - MCP 工具工作台接入稳定:
exercises/04-autogen-agents/01_multi_agent_chat.py使用workbench=mcp,并通过getattr兼容消息对象差异,降低 SDK 版本漂移风险。 - 并发状态冲突处理到位:
exercises/05-advanced-patterns/01_research_pipeline.py通过Annotated + merge_dicts处理 fan-out 并行写入同一 state key 的竞争问题。
- 用户输入进入阶段脚本(
exercises/01~05)。 - 根据阶段模式触发不同执行内核:
- LangChain: 模型调用与工具回填。
- LangGraph: StateGraph 节点执行、条件边路由、循环迭代。
- CrewAI: Agent/Task/Crew 或 Flow 事件监听链。
- AutoGen: AgentChat 消息驱动与 MCP 工具桥接。
- 输出统一回落到控制台日志,便于学习者观察状态变化与调用顺序。
scripts/setup.ps1负责环境初始化(venv、pip 工具链、依赖安装、.env模板落盘)。exercises/requirements.txt提供统一依赖基线。exercises/01~05提供逐级增强的编排样例,形成横向框架对照与纵向能力递进。scripts/clone-reference-repos.ps1可选拉取projects/参考实现,用于源码级对照学习。
- 语言与运行时:Python 3.10+、PowerShell、venv、pip
- Agent 框架:LangChain、LangGraph、CrewAI、AutoGen
- 协议层:MCP(Model Context Protocol)
- 配置与数据模型:python-dotenv、Pydantic v2、TypedDict / Annotated
- 平台要求:Windows / macOS / Linux(PowerShell 脚本主要面向 Windows)
- Python 3.10+
- Git
- Node.js 18+(用于 MCP 相关示例中的
npx)
git clone https://github.com/Shizue123/agent-setup.git
cd agent-setup.\scripts\setup.ps1python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip setuptools wheel
python -m pip install -r exercises/requirements.txt
Copy-Item exercises/.env.example exercises/.env编辑 exercises/.env,补充你的 API Key(例如 OPENAI_API_KEY)。
.\.venv\Scripts\python.exe exercises/01-langchain-basics/01_hello_agent.py
.\.venv\Scripts\python.exe exercises/02-langgraph-workflow/01_simple_graph.py
.\.venv\Scripts\python.exe exercises/03-crewai-multiagent/01_research_crew.py
.\.venv\Scripts\python.exe exercises/04-autogen-agents/01_multi_agent_chat.py
.\.venv\Scripts\python.exe exercises/05-advanced-patterns/01_research_pipeline.py.\scripts\clone-reference-repos.ps1用于将 LangGraph / CrewAI 等官方仓库拉取到 projects/ 做本地对照学习。