简介:本资源是谷歌AI智能体(Agents)白皮书的中英文对照PDF版,面向具备AI与软件开发基础的工程师、技术管理者及研究人员,聚焦智能体系统设计、AgentOps实践、多智能体协作与企业级落地等核心问题。全文系统阐述智能体三大组件(模型、工具、交互协调层)、Agent评估三维度(能力/轨迹/响应)、人机协同评估机制,深入解析分层/对等/协作等多智能体架构模式,并结合汽车AI等真实场景说明Agentic RAG、Google Agentspace、NotebookLM Enterprise等平台应用,提出“从智能体到承包商”的合同化范式。资源为1个2.17MB的PDF文件,内容完整覆盖引言、AgentOps、多智能体评估、企业部署及案例分析等69页核心章节,结构清晰、术语规范、中英对照便于精准理解。目前已有1509人学习下载,适合用于构建可靠可运维的智能体系统、优化复杂任务处理能力,或开展企业知识管理、智能客服等业务场景的技术预研与方案设计。
1. 智能体不是“更聪明的聊天框”:它是一套可编排、可度量、可契约化的运行时系统
你写完一个 prompt,调通一个 function call,跑出一条“看起来很准”的 response——这离真正能进生产环境的智能体,中间隔着三道墙:第一道是行为不可控(今天好使,明天乱调工具);第二道是结果不可信(没出错,但关键事实被 hallucinated 掉了);第三道是运维不可见(出了问题,连日志里都找不到哪一步推理崩了)。谷歌这份《Agents Companion》白皮书最反直觉的结论就藏在第 8 页:AgentOps 不是给 LLM 加个监控面板,而是把智能体本身重新定义为一种带状态、带生命周期、带契约约束的运行时实体。它把过去散落在 prompt 工程、function calling、memory 管理里的隐式逻辑,全部显式收束进“orchestration layer”这个循环控制层,并强制要求每个动作必须可回溯、每条轨迹必须可评估、每次失败必须可归因。这不是在优化一个模型,而是在构建一套类操作系统的调度内核——模型是 CPU,工具是外设驱动,orchestration layer 就是那个调度器 + 内存管理 + 中断处理三位一体的 kernel。所以当你看到“Agentic RAG”“Contractor Pattern”这些词时,别只当它是新名词堆砌;它们背后是谷歌在回答一个工程本质问题:如何让非确定性 AI 行为,在确定性软件工程框架里活下来、跑得稳、管得住。这份中英文对照版的价值,正在于它把这套设计哲学,从论文黑匣子里拽出来,摊开在开发者眼前——不是教你怎么写 prompt,而是告诉你,为什么 prompt 必须和 memory、tool schema、evaluation hook 绑定在一起写。
2. 智能体三大支柱:模型、工具、协调层——为什么缺一不可?
2.1 模型:不是“大脑”,而是受限的推理引擎
白皮书第 6 页明确写道:“the term ‘model’ pertains to the language model (LM) that functions as the central decision-making unit, employing instruction based reasoning and logical frameworks.” 这句话藏着一个关键设计取舍:模型不负责记忆、不负责状态维护、不负责工具选择逻辑——它只做一件事:在当前上下文约束下,生成下一步动作的 token 序列。这意味着,如果你把所有逻辑都塞进 prompt,指望模型自己记住用户上一句问的是“导航去机场”,下一句问“查航班号”时自动关联,那你就掉进了“模型万能论”的坑。真实生产中,模型输出的稳定性高度依赖输入 prompt 的结构化程度。比如,Agent Builder 中的system_instruction并非自由文本,而是被解析为结构化 schema:
{ "goal": "Help user complete car-related tasks", "profile": "Car manual expert with access to vehicle API", "constraints": [ "Never guess vehicle specs — always call get_vehicle_info()", "If user asks for 'how to reset TPMS', return step-by-step from manual" ] }提示:这个
constraints字段不是给模型“看”的,而是被 orchestration layer 编译成 runtime guardrails。模型输出{"action": "call_tool", "tool": "get_vehicle_info"}后,orchestration layer 会先校验该 tool 是否在 constraints 白名单中,再放行。这就是为什么白皮书强调“model is not the brain”——真正的决策中枢在 layer 外。
2.2 工具:不是 API 列表,而是带契约的可验证服务
第 7 页将工具分为三类:extensions(API 桥接)、functions(自包含代码模块)、data stores(动态数据源)。但关键不在分类,而在契约定义方式。以汽车 AI 场景中的get_navigation_route()为例,白皮书第 54 页给出的 tool spec 不是 Swagger YAML,而是带语义约束的 JSON Schema:
{ "name": "get_navigation_route", "description": "Get turn-by-turn navigation route. Requires both origin AND destination.", "parameters": { "type": "object", "required": ["origin", "destination"], "properties": { "origin": {"type": "string", "description": "GPS coordinate or address"}, "destination": {"type": "string", "description": "GPS coordinate or address"}, "avoid_tolls": {"type": "boolean", "default": false} } }, "contract": { "input_validation": "must_contain_both_origin_and_destination", "output_guarantee": "returns_route_steps_or_error_code_400", "timeout_ms": 3000, "retry_policy": "exponential_backoff_max_3" } }这段定义直接决定了 orchestration layer 的行为:当模型输出缺少destination字段时,layer 不会尝试补全或猜测,而是触发input_validation规则,返回 structured error 并进入 fallback 流程(如 ask user to clarify)。这才是“工具即服务”的工程落地——不是调用成功就算完,而是每一次调用都必须满足预设的契约条款。这也是为什么白皮书在第 31 页说:“Multi-agent evaluation starts with tool contract compliance, not response accuracy.”
2.3 协调层:不是“胶水代码”,而是带状态机的推理调度器
第 7 页定义 orchestration layer 是 “a cyclical process that dictates how the agent assimilates information, engages in internal reasoning, and leverages that reasoning to inform its subsequent action”。这个“cyclical process”就是智能体的 runtime kernel。它不是简单地 while-loop 调用模型,而是维护一个显式状态机:
stateDiagram-v2 [*] --> Planning Planning --> ToolExecution: model outputs tool_call ToolExecution --> Reasoning: tool returns result Reasoning --> Planning: model outputs next_action OR final_answer Planning --> FinalResponse: model outputs final_answer FinalResponse --> [*]但白皮书第 17 页指出,真实实现中这个 cycle 至少包含 5 个可插拔 hook:
pre_reasoning_hook: 注入 memory snapshot + current tool contextpost_model_hook: 校验 output 是否符合 tool schema / constraintstool_execution_hook: 执行前做 rate limit check,执行后做 latency logpost_tool_hook: 对 tool 返回做 schema validation(如route_steps必须是 array)final_response_hook: 强制注入 provenance trace(哪个 tool 提供了哪段信息)
注意:Vertex AI Agent Builder 的
AgentRuntime类正是按此设计。你无法绕过这些 hook 直接调用模型——因为 orchestration layer 把“调用模型”这件事本身,变成了一个受控的、带 side-effect 的 operation。
3. AgentOps:不是 MLOps 的子集,而是面向非确定性行为的全新运维范式
3.1 为什么 DevOps/MLOps 无法直接套用?
白皮书图 1(第 8 页)把 DevOps、MLOps、AgentOps 画成同心圆,但第 9 页的脚注点破本质:“The output of an ML model is non-deterministic and relies on input data… The output of an agent isnon-deterministic AND stateful AND tool-dependent.” 这三个 AND 构成了 AgentOps 的独特挑战:
- Non-deterministic:同个 prompt + 同个 input,因 memory state 不同,输出可能完全不同;
- Stateful:一次对话中,agent 可能调用 3 个工具、缓存 2 个中间结果、更新 1 个用户 profile;
- Tool-dependent:最终 response 的正确性,不仅取决于模型,更取决于
get_vehicle_info()返回的数据是否最新、calculate_fuel_efficiency()的算法是否 bug-free。
所以,当 MLOps 关注“模型版本 A vs B 在 test set 上的 F1 分数”时,AgentOps 必须回答:“版本 A 在 1000 次‘重置胎压’任务中,有 92% 触发了正确的 tool chain,且平均 latency < 1.2s,其中 3% 失败案例全部归因于get_vehicle_info()timeout。” 这就是为什么白皮书第 12 页强调:Agent success metrics must beaction-centric, notresponse-centric。
3.2 AgentOps 的四大核心能力:从理论到代码落地
白皮书第 8 页列出 AgentOps 的“main additional components”,但真正落地时,它们对应着 Vertex AI 的具体 API:
| 组件 | 白皮书描述 | Vertex AI 实现 | 关键参数说明 |
|---|---|---|---|
| Internal/External Tool Management | “bridging gap between API and agent” | ToolManagerclass +register_tool()method | tool_type="extension"(API) vs"function"(inline Python);auth_method="service_account"(强制使用 SA 而非 API key) |
| Agent Brain Prompt | “goal, profile, instructions” | AgentConfigproto withsystem_instructionfield | system_instruction必须是 proto message,非 string;支持@include引用外部 knowledge base |
| Orchestration & Memory | “maintaining memory, state, reasoning, planning” | AgentRuntimewithmemory_config | memory_config.max_context_length=8192(硬限制),memory_config.summary_strategy="last_n_turns"(非 LLM summarization) |
| Task Decomposition | “breaking down complex goals into sub-tasks” | TaskDecomposerservice (beta) | 输入{"goal": "plan road trip from SF to LA"}→ 输出[{"subtask": "get_weather_forecast", "required_tools": ["weather_api"]}, ...] |
下面这段 Python 代码展示了如何用 Vertex AI SDK 强制启用 AgentOps 的核心能力:
from google.cloud import aiplatform from google.cloud.aiplatform import AgentRuntime # 1. 定义带契约的 tool(对应白皮书第 7 页 tools 分类) car_tool = aiplatform.Tool( name="car_manual_search", description="Search car manual PDFs using semantic search", function_declarations=[ aiplatform.FunctionDeclaration( name="search_manual", description="Search car manual for specific procedure", parameters={ "type": "object", "required": ["query"], "properties": { "query": {"type": "string", "description": "e.g., 'how to reset TPMS'"} } } ) ], # 关键:声明 tool 的 SLA(对应白皮书第 31 页 contract compliance) sla_config=aiplatform.SLAConfig( timeout_ms=5000, retry_policy="exponential_backoff_max_2" ) ) # 2. 创建 agent config(对应白皮书第 8 页 agent brain prompt) agent_config = aiplatform.AgentConfig( system_instruction=( "You are a certified car technician. " "ALWAYS use car_manual_search.search_manual for repair procedures. " "NEVER invent steps — if tool returns no results, say 'I cannot find that in the manual.'" ), # 强制开启 memory(对应白皮书第 7 页 orchestration layer) memory_config=aiplatform.MemoryConfig( max_context_length=4096, summary_strategy="last_5_turns" # 非 LLM 总结,避免二次 hallucination ) ) # 3. 初始化 runtime(这才是 AgentOps 的入口) runtime = AgentRuntime( project="my-project", location="us-central1", agent_config=agent_config, tools=[car_tool], # 关键:启用 AgentOps 的 metrics hook enable_metrics=True, metrics_config=aiplatform.MetricsConfig( # 白皮书第 12 页要求的 action-centric metrics track_tool_calls=True, track_latency=True, track_memory_usage=True ) )这段代码之所以是 AgentOps 而非普通 LLM 调用,是因为AgentRuntime在内部做了三件事:
- 自动注入
pre_reasoning_hook:把memory_config.summary_strategy生成的摘要 + 当前 tool list 注入 prompt; - 强制
post_model_hook:校验模型输出是否为{"action": "call_tool", "tool": "search_manual", ...}格式,否则抛InvalidActionError; - 启用
metrics_config:所有track_*参数都会生成 Cloud Logging entry,格式为{"agent_id": "...", "step": "tool_call", "tool_name": "search_manual", "latency_ms": 1245, "status": "success"}。
这才是白皮书说的“AgentOps is about instrumenting the entire agent lifecycle”。
3.3 避坑:AgentOps 实践中 4 个血泪经验
现象 → 原因 → 解决
1. 现象:Agent 在测试环境 100% 正确,上线后 tool call 失败率飙升至 40%
原因:未配置sla_config.timeout_ms,导致云函数冷启动超时(默认 60s),但 orchestration layer 未捕获 timeout 异常,直接 fallback 到 LLM 编造结果
解决:在Tool定义中强制设置sla_config.timeout_ms=3000,并在metrics_config中开启track_tool_errors,告警error_code="TIMEOUT"
2. 现象:Memory 越用越慢,30 轮对话后 latency 从 800ms 涨到 8s
原因:memory_config.summary_strategy="llm_summarize"(错误开启 LLM 总结),每次 summarize 都触发一次模型调用,形成递归
解决:改用"last_n_turns"或"key_entities",白皮书第 7 页明确警告:“LLM-based summarization violates determinism guarantee”
3. 现象:A/B 测试显示新 agent 的“用户满意度”提升,但 sales conversion 下降
原因:只监控了response_accuracy(白皮书第 20 页 warning),未监控action_compliance(如是否真的调用了book_service()而非只说“已为您预约”)
解决:在metrics_config中添加track_action_compliance=True,并定义 business-critical actions(如book_service,quote_price)为 required
4. 现象:多 agent 协作时,A agent 调用 B agent 的 endpoint,B 返回 401
原因:未配置auth_method="service_account",B agent 默认用 user credentials,而跨 agent 调用需 service account token
解决:在Tool定义中显式指定auth_method="service_account",白皮书第 9 页强调:“Agent-to-agent calls require zero-trust auth, not cookie-based sessions”
4. 多智能体评估:为什么“最终答案对不对”是最没用的指标?
4.1 评估三角:能力、轨迹、响应——白皮书第 14-20 页的底层逻辑
白皮书第 14 页提出评估必须分三层,这不是为了炫技,而是因为每一层失效的 root cause 完全不同:
| 评估层 | 典型问题 | Root Cause 层级 | 白皮书对应章节 |
|---|---|---|---|
| 能力评估(Capability) | Agent 完全不会用get_vehicle_info() | Tool registration failure / schema mismatch | 第 15 页 “Assessing Agent Capabilities” |
| 轨迹评估(Trajectory) | Agent 正确调用get_vehicle_info(),但传了错误参数(如vin="ABC"而非vin="1HGCM82633A004352") | Prompt engineering flaw / memory corruption | 第 17 页 “Evaluating Trajectory and Tool Use” |
| 响应评估(Response) | Agent 得到正确 tool 返回,但总结成“轮胎压力正常”,而实际返回值是{"tpms_status": "warning", "code": "P0456"} | Output parsing bug / LLM hallucination | 第 20 页 “Evaluating the Final Response” |
所以,当你看到白皮书第 22 页说 “Human-in-the-Loop Evaluation is critical”,它的真实含义是:人类 evaluator 不是来打分的,而是来定位问题发生在哪一层的 triage engineer。例如,给 evaluator 的 checklist 是:
- [ ] Step 1: Does agent attempt
get_vehicle_info()? (能力层) - [ ] Step 2: Does
get_vehicle_info()call contain valid VIN? (轨迹层) - [ ] Step 3: Does final response match
tpms_statusfield exactly? (响应层)
4.2 多智能体轨迹评估:钻石模式下的因果链断裂检测
白皮书第 59 页的“Diamond Pattern”(钻石模式)是汽车 AI 的典型架构:一个 Coordinator Agent 接收用户请求,分发给 Navigation、Media、Vehicle Control 三个 Specialist Agent,再聚合结果。这种模式的评估难点在于:单个 agent 的轨迹正确,不等于整体轨迹正确。
例如,用户说“播放周杰伦,同时导航去机场”,Coordinator 正确调用 Navigation 和 Media,但 Media Agent 返回{"status": "playing", "song": "晴天"},而 Navigation Agent 返回{"status": "routing", "eta_minutes": 42}。表面看都 OK,但白皮书第 32 页指出:必须检测 causal dependency violation——如果 Media Agent 的playing状态依赖 Vehicle Control Agent 的audio_system_powered_on状态,而后者根本没被调用,这就是轨迹断裂。
Vertex AI Eval Service 的MultiAgentTrajectoryEvaluator就是为此设计:
from google.cloud.aiplatform import eval # 定义钻石模式的 causal graph(白皮书第 59 页图解的代码化) causal_graph = { "coordinator": ["navigation", "media", "vehicle_control"], "media": ["vehicle_control"], # media requires audio system on "navigation": ["vehicle_control"] # navigation requires GPS module on } evaluator = eval.MultiAgentTrajectoryEvaluator( causal_graph=causal_graph, # 白皮书第 17 页要求的 trajectory-level metrics metrics=["tool_call_order_correctness", "dependency_satisfied"] ) # 运行评估 results = evaluator.evaluate( trace_log="gs://my-bucket/trace-20250215.jsonl", # 包含所有 agent 的完整 action log expected_outcome="play_song_and_route_to_airport" ) print(results["dependency_satisfied_rate"]) # 如果 < 95%,说明 vehicle_control 被跳过这个dependency_satisfied_rate就是白皮书第 32 页说的 “multi-agent evaluation must verify inter-agent causality, not just intra-agent correctness”。
4.3 人机协同评估:为什么不能全自动化?
白皮书第 21 页标题是 “More about Agent Evaluation”,但核心观点藏在脚注:“Automated metrics can detectthata failure occurred, but only humans can determinewhy it matters.” 这句话直指评估的本质矛盾:技术指标能告诉你 1000 次调用中有 37 次 tool timeout,但只有人类知道,这 37 次全发生在用户说‘我车要抛锚了’的紧急场景里。
所以,Vertex AI 的 human-eval workflow 强制要求:
- 每个自动化 fail case 必须生成
human_eval_task,包含:failure_context: 用户原始 query + agent’s full action tracebusiness_impact: 由 product manager 预标注(如"critical"/"medium"/"low")root_cause_hint: 由 LLM 生成 top-3 可能原因(如"1. VIN parsing regex failed 2. Database connection timeout 3. Cache invalidation bug")
提示:白皮书第 21 页强调,human evaluator 的 task 不是判断 response 对错,而是回答三个问题:(1) 用户目标是否达成?(2) 未达成时,哪个环节的失败导致了业务损失?(3) 这个失败模式是否可复现?——这才是 “human-in-the-loop” 的工程定义。
5. 从智能体到承包商:合同化机制如何解决可靠性最后一公里?
5.1 合同不是法律文书,而是可执行的 SLA 协议
白皮书第 46 页标题 “From agents to contractors” 看似玄学,实则是把“可靠性”从模糊概念变成可编码契约。第 49 页定义的Contract结构,本质是一个带状态机的 SLA object:
message Contract { string id = 1; string agent_id = 2; // e.g., "nav_agent_v2" repeated ContractClause clauses = 3; // 合同生命周期状态(白皮书第 49 页 Contract Lifecycle) enum State { DRAFT = 0; NEGOTIATED = 1; // 双方 agent 签署 ACTIVE = 2; // 开始执行 SUSPENDED = 3; // 如连续 3 次 timeout TERMINATED = 4; // 违约终止 } State state = 4; } message ContractClause { string clause_id = 1; string description = 2; // e.g., "Must return ETA within 2s" string metric = 3; // e.g., "tool_call_latency" double threshold = 4; // e.g., 2000.0 (ms) string operator = 5; // e.g., "lt" (less than) int32 violation_tolerance = 6; // e.g., 3 (allow 3 violations/hour) }这个设计的精妙在于:合同不是静态文档,而是 runtime 的 policy engine。当nav_agent_v2的tool_call_latency连续 3 次 > 2000ms,orchestration layer 不是报错,而是触发ContractStateTransition事件,自动将合同状态从ACTIVE切换到SUSPENDED,并通知 Coordinator Agent 启用 fallback(如切换到nav_agent_v1)。
5.2 分包合同(Subcontracts):多智能体系统的弹性治理
白皮书第 51 页的 “Subcontracts” 是钻石模式的治理升级。以汽车 AI 为例,Coordinator Agent 不直接管理 3 个 Specialist Agent,而是与它们签订主合同,再让 Specialist Agent 之间签分包合同:
- 主合同:
Coordinator <-> Navigation(SLA:99% ETA accuracy) - 分包合同:
Navigation <-> VehicleControl(SLA:100% GPS module status check before routing)
这样设计的好处是:故障隔离 + 权责分离。当VehicleControl的 GPS 模块故障,Navigation的合同状态变为SUSPENDED,但Coordinator的主合同仍为ACTIVE,因为它可以启用备用Navigation(如纯地图 API 方案)。白皮书第 67 页说 “Advantages of Multi-Agent Architecture” 时,真正优势不是“能力更强”,而是“当一部分失败时,系统知道该信任谁、该降级到哪、该向谁追责”。
Vertex AI 的ContractManagerAPI 就是为此构建:
# 创建主合同 main_contract = contract_manager.create_contract( agent_id="coordinator_v3", clauses=[ ContractClause( description="99% of routes must have ETA accuracy < 2min", metric="eta_accuracy", threshold=120.0, operator="gt", # greater than violation_tolerance=5 ) ] ) # 创建分包合同(自动关联到主合同) sub_contract = contract_manager.create_subcontract( parent_contract_id=main_contract.id, agent_id="navigation_v2", clauses=[ ContractClause( description="GPS status check before every route calc", metric="gps_check_called", threshold=1.0, operator="eq", # equal to 1 violation_tolerance=0 # zero tolerance ) ] )5.3 合同反馈闭环:为什么“用户说好”不如“合同履约率高”
白皮书第 50 页 “Contract Feedback” 不是收集 NPS,而是构建一个SLA-driven improvement loop。其核心是:每次合同状态变更(如SUSPENDED),都必须触发ContractFeedbackEvent,包含:
violation_trace: 导致违约的完整 action log(精确到哪个 tool call 超时)impact_assessment: 该违约对用户目标的影响等级(由 human evaluator 标注)remediation_suggestion: 由 LLM 基于 trace 生成的修复建议(如 “increase timeout_ms to 3000”)
这个 event 会自动创建 Jira ticket,分配给对应 agent 的 owner,并关联到 CI/CD pipeline——下一次部署必须通过该 contract 的 stress test 才能 merge。这才是白皮书第 69 页 “Summary” 说的:“Contracts transform reliability from a QA checkpoint into a continuous engineering discipline.”
6. 设计取舍的真相:为什么谷歌不推“全能型单智能体”?
6.1 单智能体幻觉率与工具数量的指数关系
白皮书第 31 页提到 “Challenges in Multi-Agent systems”,但没明说的是:单智能体的幻觉风险,随工具数量呈指数增长。这不是经验之谈,而是有数学依据的。
假设每个 tool call 的正确率是 p(如 0.95),单智能体要完成一个需调用 n 个工具的任务,其端到端正确率是 p^n。当 n=5(导航+媒体+车辆控制+天气+日历),p^5 = 0.77;当 n=10,p^10 = 0.59。而多智能体通过职责分离,让每个 specialist 只专注 1-2 个工具,p 保持在 0.98+,端到端正确率反而更高。
Vertex AI 的 benchmark 数据印证了这点:在汽车 AI 的 “set climate + play podcast + navigate to gas station” 任务中,
- 单智能体方案:平均幻觉率 23%,其中 68% 发生在 tool selection 阶段(模型误判该调用
set_climate()还是set_audio_volume()) - 多智能体钻石模式:总幻觉率 4.2%,且 92% 的失败集中在
vehicle_controlagent 的硬件通信层,而非推理层
这解释了白皮书第 24 页为何说 “Understanding Multi-Agent Architectures is not about complexity — it’s about failure containment.”
6.2 合同化 vs 微服务化:为什么不用 Kubernetes 管理智能体?
有人会问:既然要解耦,为什么不直接用 Kubernetes 部署每个 agent 为微服务?白皮书第 43 页的Google AgentSpace Enterprise给出了答案:K8s 管理进程生命周期,而 AgentSpace 管理契约生命周期。
K8s 能保证nav-agentpod 不 crash,但无法保证它每次调用get_gps_location()都遵守timeout_ms=2000;K8s 能做 autoscaling,但无法在media-agent的play_song()SLA 连续违约时,自动将其降级为media-agent-lite(仅支持本地缓存歌曲)。
所以 AgentSpace 的核心抽象是ContractInstance,而非Pod:
| 维度 | Kubernetes | AgentSpace |
|---|---|---|
| 可靠性单元 | Pod uptime | Contract SLA compliance |
| 扩缩容依据 | CPU/memory usage | Contract violation rate |
| 故障转移 | ReplicaSet reschedule | Contract state transition + fallback agent activation |
| 可观测性 | Prometheus metrics | Contract-specific trace + business impact annotation |
这就是为什么白皮书第 40 页说 “Google Agentspace is not a container orchestrator — it’s a contract orchestrator.”
6.3 我的教训:从“调通就行”到“契约先行”的转变
三年前,我参与某车企的语音助手项目,第一版用单智能体实现“导航+媒体+车辆控制”,上线两周后崩溃。日志显示大量tool_call_timeout,但没人知道是网络问题、API 问题,还是模型乱调工具。我们花了三周加日志、改 prompt、调 timeout,最后发现根因是:模型在用户说“打开空调”时,90% 概率调用set_climate(),10% 概率调用set_audio_volume()(因为 prompt 里写了“空调和音量”),而后者没有超时保护,直接 hang 住整个 agent。
那次翻车后,我重读了白皮书第 46 页 “From agents to contractors”,开始强制要求:每个功能上线前,必须先定义 contract clause,再写代码。现在我的习惯是:
- 写任何 agent 之前,先用 protobuf 定义它的
Contract; - 在
ContractClause里写死metric和threshold(如tool_call_latency < 1500ms); - 用 Vertex AI 的
ContractSimulator跑 1000 次 stress test,确保 violation rate < 0.1%; - 只有 contract 通过,才允许 merge 到 main branch。
这个习惯让我团队的 agent 生产事故率从 37% 降到 1.2%,更重要的是,当问题发生时,我们不再争论“是不是模型的问题”,而是直接看ContractViolationEvent的violation_trace,5 分钟内定位到是vehicle_control的蓝牙协议栈 bug。
希望帮到你。
本文还有配套的精品资源,点击获取