Google分享构建Agent插件的四大评估工程经验
Four evaluation engineering lessons learned from building agent plugins
Agent开发者必读,这篇来自Google的一手实践复盘给出了非常具体的评估方法论,特别是关于轨迹评估和双轨测试的思路,直接解决Agent落地中的黑盒难题。
The real challenge of building an agentic system isn't the construction, it's the measurement.
构建智能体系统的真正挑战不在于构建本身,而在于评估。
Evaluation engineering is a critical foundation for building reliable AI systems. Setting up systematic, repeatable tests to measure your agent’s true behavior can be the difference between shipping a tool you can trust and one that silently breaks, fails to call APIs, or makes mistakes.
评估工程是构建可靠 AI 系统的关键基础。建立系统化、可重复的测试来衡量智能体的真实行为,可能是决定你发布的是一个值得信赖的工具,还是一个会 silently breaks(静默失效)、无法调用 API 或犯错的工具之间的关键差异。
I’ve run evaluation engineering initiatives for years at Google and developing the newly released Google Cloud Developer plugin served as a live testbed to stress-test these key principles across real-world developer workflows.
我在 Google 多年负责评估工程相关工作,而开发新发布的 Google Cloud Developer 插件则作为一个实时测试床,用于在实际开发者工作流中压力测试这些核心原则。
Here are four eval lessons we learned from building the new plugin that you can apply to your own builds.
以下是我们从构建新插件中学到的四条评估经验教训,你可以将其应用到自己的构建中。
1. Grade the execution steps instead of the summary
1. 对执行步骤进行评分,而不是对总结进行评分
When we first evaluated agents, we set up an LLM-as-judge to inspect the agent’s final text reply and scored it against a checklist. However, we quickly realized it’s fundamentally flawed because the grader only sees what the agent wrote, not what it actually did. When we ran our initial 11-prompt evaluation suite for the Google Cloud Developer plugin, the automated grader marked it as failing three prompts. But when we opened the raw tool-call logs and read the transcripts, the plugin had actually passed all three. On a Cloud Run cleanup prompt, for instance, our rubric required checking command syntax before running anything. The agent ran gcloud help run services list as its very first step. It did the work, but its final message was focused on warning the user about permanent data loss rather than reciting that it had checked the help docs.
当我们最初评估智能体时,我们设置了一个“LLM-as-judge”(大语言模型裁判)来检查智能体的最终文本回复,并根据检查表对其进行打分。然而,我们很快意识到这存在根本性缺陷,因为评分者只能看到智能体写了什么,而无法看到它实际做了什么。当我们为 Google Cloud Developer 插件运行初始的 11 个提示词评估套件时,自动评分器标记其未能通过三个提示词。但当我们打开原始的工具调用日志并阅读转录内容时,发现该插件实际上通过了所有三个测试。例如,在一个 Cloud Run 清理提示词中,我们的评分标准要求在运行任何操作前检查命令语法。智能体在其第一步就运行了 `gcloud help run services list`。它确实完成了工作,但其最终消息侧重于警告用户关于永久数据丢失的风险,而不是陈述它已经查阅了帮助文档。
The grader penalized the agent for doing the right thing simply because it didn’t brag about it in the summary. If your rubric line says "did it run X?", a LLM judge is guessing unless you evaluate the actual tool-call trajectory.
评分者仅仅因为智能体没有在总结中炫耀它的正确做法而对其进行了惩罚。如果你的评分标准条目写着“是否运行了 X?”,除非你评估实际的工具调用轨迹,否则 LLM 裁判只是在猜测。
Takeaway: Don't grade an agent on its closing pitch. Score the raw execution trajectory to verify what commands were actually executed, validated, and scoped.
要点:不要根据智能体的结尾陈述来评分。应对原始的执行轨迹进行评分,以验证实际执行、验证和限定范围了哪些命令。
2. Design evals for asynchronous operations
2. 为异步操作设计评估
When you start reading tool-call trajectories, how you extract that telemetry matters just as much as what you're reading. Extracting agent telemetry into a flattened, sequential list of events obscures concurrent tool dispatch, which is one of the critical causes of behavioral failure. Modern agent harnesses often batch multiple tool invocations into a single assistant turn using an array of calls.
当你开始阅读工具调用轨迹时,你如何提取这些遥测数据与你读取的内容同样重要。将智能体遥测数据提取为扁平化的顺序事件列表,会掩盖并发工具调度,这是导致行为失败的关键原因之一。现代智能体框架通常使用调用数组将多个工具调用批处理到单个助手轮次中。
In our evaluations, when an agent was asked to inspect an environment and look up documentation, the harness dispatched the skill-loading call and two documentation searches simultaneously within a single tool_calls payload. Because activating a skill is a multi-stage process, where the initial call returns a short launch stub and the subsequent turn injects the full instruction body, the instructions meant to govern the search arrived in the prompt context after the system had already executed the searches.
在我们的评估中,当要求智能体检查环境并查阅文档时,工具集会在单个 tool_calls 载荷中同时派发技能加载调用和两次文档搜索。由于激活技能是一个多阶段过程,初始调用返回一个简短的启动存根,后续轮次注入完整的指令正文,因此旨在指导搜索的指令在系统已执行搜索后才进入提示上下文。
The system never gave the skill a dedicated turn to let its guidance influence the agent's actions. If telemetry pipelines strip out turn structures and merge calls into a flat timeline, engineers will waste days wondering why an agent disregarded unambiguous instructions that a developer embedded in a skill.
系统从未给技能分配专门的轮次以让其指导影响智能体的行为。如果遥测管道剥离了轮次结构并将调用合并为扁平时间线,工程师将浪费数天时间困惑于为何智能体无视开发者嵌入技能中的明确指令。
Takeaway: Preserve turn structure in telemetry extractors so you can identify when client-side parallel dispatch issues tool calls before injected guidance enters the context window.
要点:在遥测提取器中保留轮次结构,以便识别客户端并行派发工具调用何时发生在注入的指导进入上下文窗口之前。
3. Test live runs and "dry runs" side-by-side
3. 并列测试实时运行和“试运行”
You need to inspect real API calls to catch harness quirks, like parallel dispatch. But if you only test your agent in one environment condition, you're flying half-blind. From day one, you need to run two conditions side-by-side: a live run and a plan-only run. In the live condition, the agent has real, sandboxed credentials and actually executes commands. This is how you see if syntax works, parameters serialize cleanly, and the agent exercises restraint before doing something destructive.
你需要检查真实的 API 调用来发现工具集的怪癖,例如并行派发。但如果你只在一种环境条件下测试智能体,那就等于半盲操作。从一开始,你就需要并列运行两种条件:实时运行和仅计划运行。在实时条件下,智能体拥有真实且沙盒化的凭据,并实际执行命令。这是你观察语法是否有效、参数是否序列化清晰、以及智能体在执行破坏性操作前是否保持克制的方法。
Live runs frequently hit an unexpected permission error on step two and abort before you ever reach the behavior you’re trying to test. That's why you need the plan-only condition, where you strip credentials and tell the agent to explain what it would do without running anything. This strips out permission roadblocks and shows you the model’s pure reasoning and routing intent. Roughly half our most important findings came from the delta between the two.
实时运行经常在第二步遇到意外的权限错误并在你到达要测试的行为之前中止。这就是为什么你需要仅计划条件,在该条件下你移除凭据并指示智能体解释它将做什么而不运行任何内容。这消除了权限障碍,并向你展示模型纯粹的推理和路由意图。我们最重要的发现中约有半数来自这两种条件的差异。
For example, on one of our onboarding prompts, a live run was blocked immediately on a project list call. The plan-only run sailed right through and produced an 8,000-character plan that completely ignored organization policies, admin approvals, and governance. The live run masked a major cognitive flaw that the plan-only run exposed in seconds.
例如,在我们其中一个入职提示中,实时运行在项目列表调用上立即被阻止。仅计划运行则顺利通过,生成了一个长达 8000 字符的计划,完全忽略了组织策略、管理员审批和治理规定。实时运行掩盖了一个重大认知缺陷,而仅计划运行在几秒钟内就暴露了该缺陷。
Takeaway: Run live and plan-only evaluations side by side. Live runs test actual execution and safety restraint; plan-only runs expose the model's raw reasoning and routing without getting tripped up by permission errors.
要点:并行运行实时评估和仅计划评估。实时运行测试实际执行和安全限制;仅计划运行暴露模型的原始推理和路由,而不受权限错误的干扰。
4. Use “golden sets” as durable baselines
4. 使用“黄金集”作为持久基线
Frontier model architectures change every few months, agent harnesses improve, and plugin manifest standards will inevitably evolve. When building the Google Cloud Developer plugin, we treated evaluations as continuous integration testing for these non-deterministic environments. That means we stress-tested the composite stack, including the harness, the live model, and the tools running together on realistic tasks.
前沿模型架构每隔几个月就会变化,智能体框架不断改进,插件清单标准也必将演进。在构建 Google Cloud Developer 插件时,我们将评估视为这些非确定性环境的持续集成测试。这意味着我们对复合堆栈进行了压力测试,包括框架、实时模型以及在真实任务中协同运行的工具。
Instead of guessing from the final text output, this approach captures the whole trajectory: what the agent thought, what commands it actually ran, and whether it solved the problem without breaking anything. Then you score that run against golden sets curated by real human experts who know what the ideal path looks like.
这种方法不是从最终文本输出中猜测,而是捕获整个轨迹:智能体思考了什么、实际运行了哪些命令,以及是否在未破坏任何内容的情况下解决了问题。然后,你将该运行结果与由了解理想路径的真实人类专家策划的黄金集进行评分对比。
Takeaway: Build golden sets based on what the entire system should actually do in the wild, including your harness, model, and plugins. Models change, but those baseline runs are your safety net.
要点:基于系统在野外实际应执行的操作构建黄金集,包括你的框架、模型和插件。模型会变化,但这些基线运行是你的安全网。
Reminder: Use evaluation suites over “one-shot” demos
提醒:使用评估套件而非“一次性”演示
A common mistake I see among engineers is what I like to call the one-shot demo. This is when someone feeds a prompt into a LLM, watches it build a complete 3D game or solves a Rubik’s cube in a single pass and calls it an eval. But in reality, this is just a vanity metric.
我在工程师中常见的一种错误是我称之为“一次性演示”。这是指有人将提示词输入到 LLM 中,看着它在单次传递中构建出一个完整的 3D 游戏或解开魔方,并称之为评估。但实际上,这只是一个虚荣指标。
To do quality work with AI, I truly believe that you need evaluation suites. Without evaluations, teams are like literally running into a dark cave blind. Engineering an enterprise-grade agent means testing the system's ability to handle multi-step interactions, manage permissions, and avoid destructive outcomes like accidentally deleting a project because you asked it to "find opportunities to save costs."
为了用 AI 做好工作,我真心认为你需要评估套件。没有评估,团队就像是在黑暗中盲目地跑进一个洞穴。工程化企业级智能体意味着测试系统处理多步交互、管理权限以及避免破坏性结果的能力,例如因为你要求它“寻找节省成本的机会”而意外删除项目。
Where to go from here
后续步骤
Building an agent plugin or MCP server is the beginning. Shipping something you can actually trust with real cloud infrastructure requires significantly more work in evaluations to ensure it’s doing what you expect it to do. At the end of the day, the only thing that outlasts model churn is a stress-tested eval suite. Check out the Google Cloud Developer plugin documentation or explore this codelab to get started with the plugin in Antigravity.
构建智能体插件或 MCP 服务器只是开始。交付一个你真正可以信任用于实际云基础设施的东西,需要在评估方面投入更多工作,以确保它按预期行事。归根结底,唯一能抵御模型更迭的是经过压力测试的评估套件。查看 Google Cloud Developer 插件文档或探索此 codelab,以开始在 Antigravity 中使用该插件。
更进一步:量化金融体系
看懂新闻只是起点——沿量化金融路径,把它变成能交付的工程能力