跳转到内容

Agent 开发

Agent 开发 是一个面向实践的主题页,用来回答“真正开始做 agent 系统时,最该先注意什么”。它不把重点放在某个模型或某个框架,而是聚焦六类更决定成败的工程问题:架构边界、上下文管理、工具设计、安全边界、验证闭环,以及多智能体是否真的值得。

  • 第一件事不是“先把系统做得更 autonomous”,而是先判断这个任务到底该做成 Workflows vs agents 里的哪一类。步骤稳定、结果容易验证的任务,通常先用 workflow 更稳;只有当路径依赖环境反馈、步骤无法预写死时,agent 才真正有优势。
  • agent 时代最容易被低估的不是 prompt,而是 Context engineering。你需要明确哪些规则应常驻、哪些信息应按需检索、哪些状态应写到上下文外部,否则系统会很快被历史噪声、冗余工具输出和过期意图拖垮。
  • 如果任务会跨多个 session,必须把关键信息沉淀成可交接 artifact,而不是指望压缩历史永远够用。常见载体包括 spec、progress notes、feature list、测试结果和关键决策记录,这本质上对应 Multi-context window workflowsSpec-driven development 的实践。
  • 我们如何使用 Codex 在 28 天内构建 Android 版 Sora》补了一个很实操的做法:把团队规范写进 AGENTS.md,先让 agent 总结系统和制定微型设计文档,再开始逐步实现。这样能显著降低“代码虽然能编译,但偏离架构和产品意图”的问题。
  • 很多 agent 失败并不是因为模型不会做,而是因为 Tool ergonomics for agents 太差。工具名称、参数边界、返回格式、错误提示、examples 和 token 开销,都会直接改变 agent 的选择质量和调用稳定性。
  • 工具数量多时,不要默认把所有 schema 一次性塞进上下文。更稳的做法往往是让 agent 按需发现工具、程序化组合工具,或把复杂控制流下沉到执行环境里;这正是 Programmatic tool callingModel Context Protocol (MCP) 想解决的问题。
  • 真正可用的 agent 系统必须把“证明它有效”放进默认工作流,而不是交给事后 review。对 coding agent 来说,最低要求通常是可重复的测试、脚本化验证和明确的成功标准;对 research 或 computer use agent,则要优先做 outcome-based judging,而不是把过程路径写死。这对应 Evaluation harness 和 “prove it works” 这条工程纪律。
  • 安全边界不应主要依赖“每一步都弹窗问人”。当 agent 开始高频调用真实工具时,更可靠的做法通常是先用 Sandboxing for agents 限定文件系统、网络和 credential 能力,再用 Permission delegation for agents 处理高频低风险动作,把人工注意力留给跨边界或不可逆操作。
  • 多智能体不是默认答案。Agent teamsMulti-agent research systems 的价值建立在任务天然可拆分、上下文隔离有收益、以及验证成本能覆盖额外 token 与协调开销的前提上。若任务本身串行、共享状态重、验证弱,多开 agent 往往只会放大冲突和幻觉。
  • 这篇 OpenAI 案例也提醒了另一个现实问题:多个 agent / session 可以显著提高吞吐,但瓶颈很快会转移到人的审查、反馈和集成上,所以并行度本身也需要管理。
  • agent 开发里最有复利的投入,往往不是再堆一层 orchestration,而是先把 repo、测试、文档、命令行入口和环境约束整理干净。强模型会放大好模板,也会放大坏模板。
  • 最后要保留一个很硬的判断:agent 会放大人的判断力,不会替你生成判断力。系统设计、任务切分、依赖选择、风险接受度和交付标准,仍然是人的职责。

ℹ️ Conflict:

  • 更强的模型确实会减少部分繁重 harness 的必要性,但这不等于工程 discipline 变得不重要;很多复杂度只是从“怎么生成”转移到了“怎么约束、验证和接管”。
  • 更详细的 spec 通常有助于高风险、跨上下文任务,但对小修、小步探索和快速试错,过重 spec 也可能比 bug 本身更贵。
  • 多个会话并行推进在强上下文、强 review 的团队里很有效,但如果没有清晰负责人和稳定交接,它也可能只会更快地产生待审核堆积和冲突修改。
  • 更高层、更 ergonomic 的工具通常能提效,但它们也会把业务假设固化进接口;如果没有 eval 持续验证,系统很容易变成“只擅长走一条预设好路”的脆弱 agent。
  • 多智能体在开放式研究和可并行工程里常有收益,但在强共享状态任务中,它未必比单 agent 更优,成本却几乎一定更高。
  • Anthropic, “Building effective agents”, 2024-12-19.
  • 原文摘录:[llm-wiki/raw/anthropic/Building effective agents](/raw/anthropic/Building effective agents.md)
  • Anthropic, “Best Practices for Claude Code”.
  • 原文摘录:[llm-wiki/raw/anthropic/Best Practices for Claude Code](/raw/anthropic/Best Practices for Claude Code.md)
  • Anthropic, “Effective context engineering for AI agents”, 2025-09-29.
  • 原文摘录:[llm-wiki/raw/anthropic/Effective context engineering for AI agents](/raw/anthropic/Effective context engineering for AI agents.md)
  • Anthropic, “Writing effective tools for agents — with agents”, 2025-09-11: https://www.anthropic.com/engineering/writing-effective-tools-for-agents-with-agents
  • 原文摘录:[llm-wiki/raw/anthropic/Writing effective tools for agents — with agents](/raw/anthropic/Writing effective tools for agents — with agents.md)
  • Anthropic, “Introducing advanced tool use on the Claude Developer Platform”, 2025-11-24: https://www.anthropic.com/engineering/introducing-advanced-tool-use-on-the-claude-developer-platform
  • 原文摘录:[llm-wiki/raw/anthropic/Introducing advanced tool use on the Claude Developer Platform](/raw/anthropic/Introducing advanced tool use on the Claude Developer Platform.md)
  • Anthropic, “Demystifying evals for AI agents”, 2026-01-09: https://www.anthropic.com/engineering/demystifying-evals-for-ai-agents
  • 原文摘录:[llm-wiki/raw/anthropic/Demystifying evals for AI agents](/raw/anthropic/Demystifying evals for AI agents.md)
  • Anthropic, “Beyond permission prompts- making Claude Code more secure and autonomous”, 2025-10-20.
  • 原文摘录:[llm-wiki/raw/anthropic/Beyond permission prompts- making Claude Code more secure and autonomous](/raw/anthropic/Beyond permission prompts- making Claude Code more secure and autonomous.md)
  • Anthropic, “How we built our multi-agent research system”, 2025-06-13.
  • 原文摘录:[llm-wiki/raw/anthropic/How we built our multi-agent research system](/raw/anthropic/How we built our multi-agent research system.md)
  • Simon Willison, “My fireside chat about agentic engineering at the Pragmatic Summit”.
  • 原文摘录:[llm-wiki/raw/01_AI/My fireside chat about agentic engineering at the Pragmatic Summit](/raw/01_AI/My fireside chat about agentic engineering at the Pragmatic Summit.md)
  • Simon Willison, “Your job is to deliver code you have proven to work”, 2025-12-18.
  • 原文摘录:[llm-wiki/raw/01_AI/Your job is to deliver code you have proven to work](/raw/01_AI/Your job is to deliver code you have proven to work.md)
  • Matt Rickard, “The Spec Layer”, 2026-03-31.
  • 原文摘录:[llm-wiki/raw/02_AI编程/The Spec Layer](/raw/02_AI编程/The Spec Layer.md)
  • OpenAI, “我们如何使用 Codex 在 28 天内构建 Android 版 Sora”, 2025-12-12: https://openai.com/zh-Hans-CN/index/shipping-sora-for-android-with-codex/
  • 原文摘录:[llm-wiki/raw/openai/我们如何使用 Codex 在 28 天内构建 Android 版 Sora](/raw/openai/我们如何使用 Codex 在 28 天内构建 Android 版 Sora.md)