Coding Agents 实战指南

Coding Agents 的三层次

层次 特征 示例工具
In the Editor Inline completion、chat panels、whole-codebase awareness GitHub Copilot、Cursor、Windsurf、JetBrains AI Assistant
In the Terminal 命令行启动、plain language goal、全文件系统访问、多文件编辑、运行工具和测试 Antigravity CLI、Claude Code、Codex CLI、Open Code、Cline
In the Background Cloud-hosted sandboxes、异步运行数小时、产生 PR 输出 Google Jules、Copilot agent mode、Cursor background agents、AlphaEvolve

如何选择合适的层次

工作类型 合适的 Agent 层次 原因
编写代码时需要建议、快速编辑、解释(不离开 flow) Editor Agent 保持流状态,最小中断
多文件工作、探索不熟悉代码库、Agent 需运行代码并反应观察 Terminal Agent 全文件系统访问、可运行代码、反应观察
一段话可描述的明确定义任务、可离开(如修复已知 bug、生成测试套件、框架迁移) Background Agent 异步运行数小时,产生 PR 输出

白皮书强调

“The same developer often uses all three in a single day.”

翻译:同一开发者经常在一天内使用所有三种。

“The right starting point depends on the task, not on which category sits highest on some autonomy ladder.”

翻译:正确起点取决于任务,不是哪个类别在自主梯子上最高。

Google Agents CLI:构建 Production-ready Agents

核心理念: - 小命令行工具 - 捆绑一套 skills 在 Google Cloud 上构建 agents - 与任何 coding agent 工作(Claude Code、Codex 等)

一次安装后,coding agent 获得 7 个新 skills,覆盖完整 ADK lifecycle: - scaffold 项目 - 写 agent 代码 - 评估 - 部署到 Agent Runtime - 连接 observability

示例工作流

# One-time setup
uvx google-agents-cli setup

# Then in your coding agent:
> Build a support agent that answers questions from our docs.
> evaluate it on the FAQ dataset
> Deploy it to Agent Engine

Production Agents 的关键要求

对于一次性脚本或个人自动化,常规 coding agent 足够。对于服务真实用户规模的 Agent,Agent 是产品,需要底层 substrate。

要求 说明
Persistent memory across sessions 跨会话持久记忆
Scoped permissions on tools and data 工具和数据上的范围权限
Eval coverage that catches regressions before they ship 发布前捕获回归的 eval 覆盖
Observability that traces what the agent actually did 追踪 Agent 实际行为的 observability

Multi-Agent 系统

协调机制

协调方式 适用场景
Shared session state 简单情况
Model Context Protocol (MCP) 工具访问
Agent2Agent (A2A) protocol 跨 Agent 委托

案例:Anthropic 工程团队 2026 年初实验: - Agent 团队在两周内构建了工作 Rust C 编译器 - 人类设定方向和审查输出,但不写实现 - 瓶颈从写代码转移到定义应该做什么验证 Agent 做了什么