代理模式

Hacker News Top 论文

摘要

来自 Veso 的一份全面研究指南,详细阐述了已在主要 AI 智能体系统(Claude Code、OpenAI Codex、Gemini CLI 等)中趋同的通用架构模式,并提出了构建生产级智能体系统的 8 条基本假设。

暂无内容
查看原文
查看缓存全文

缓存时间: 2026/05/26 00:50

# 概述 — 智能体模式 — Veso Research 来源:https://veso.ai/research/agentic-patterns/ 研究 (https://veso.ai/research)智能体模式开始 所有前沿智能体系统中涌现出的通用架构。 ## 趋同 Claude Code, OpenAI Codex, Gemini CLI, LangGraph, CrewAI, Google ADK, Amazon Bedrock — 由不同公司、使用不同语言、在各自约束条件下构建。它们却汇聚到了相同的设计上。 并非因为相互抄袭,而是因为约束条件如同物理定律一般不变:有限的上下文窗口、需要协议的工具、不能依赖模型服从的安全要求、以及单个调用无法完成的复杂任务。任何持续构建的团队最终都会到达这里。 --- ## 你正在构建哪种系统? 本指南中的模式普遍适用,但其*权重*取决于你在智能体生态系统中所处的具体接缝。请按照与你问题相匹配的顺序阅读。 | 如果你正在构建... | 你最关心... | 从...开始 | | --- | --- | --- | | **领域上下文基座**(一个MCP服务器,为任意智能体提供对某个领域——如代码库、屏幕、系统——的结构化访问) | 确定性提取、固定本体、用户项目中的行为契约 | `/tool-protocols`、`/instructions`、`/anti-patterns` | | **个人AI运行时**(一个由用户拥有的智能体,在后台运行,具有长期状态) | 内存架构、压缩驻留状态、钩子、调度器门控的后台工作 | `/memory`、`/enforcement`、`/multi-agent` | | **多智能体外壳**(一个协调他人智能体的编排器,具有聊天平台覆盖范围) | 适配器模式、隔离的子智能体工具注册表、设置架构、成本控制 | `/multi-agent`、`/enforcement`、`/cost-management` | 这些分类并非绝对——许多系统会模糊其间界限。但明确哪一个是你的*承重*关切,可以避免过度应用不适合你接缝的模式。 --- ## 8条基本原则 这些不是建议,而是每个生产级智能体系统的承重墙。违反它们,你将重新发现它们存在的原因。 | # | 原则 | 该做什么 | | --- | --- | --- | | 1 | **从持久化指令文件开始** | 在编写任何智能体配置之前先创建 `CLAUDE.md`、`AGENTS.md` 或 `GEMINI.md`。涵盖约定、技术栈、测试、git 和安全。保持在200行以内。 | | 2 | **在提示词之外执行安全** | 将样式偏好放在指令文件中。将 linting 放在钩子中。将破坏性命令拦截放在权限中。永远不要依赖模型记住安全规则。 | | 3 | **预算上下文窗口** | 预留10-15%用于指令,30-40%用于对话,20-30%用于工具结果。在使用率达到70%时压缩,80%时清除。将可缓存内容与可压缩内容分离。 | | 4 | **基于MCP构建工具** | 使用 `.mcp.json` 进行工具连接。每月下载量超过9700万次,覆盖所有主要平台。如果需要在系统间进行智能体间通信,添加 A2A——但先从 MCP 开始。 | | 5 | **通过共享状态协调** | 在系统内部,智能体读取和写入共享状态——而不是相互发送消息。在系统或组织之间,使用消息协议(A2A)。默认使用状态;仅在必要时才使用消息。 | | 6 | **在到达极限前分解任务** | 智能体在长时间会话后连贯性会下降。阈值随着每代模型而移动。不要去找到极限——保持在极限之下。将工作分解为在安全区域内完成的子任务。 | | 7 | **从第一天起追踪每个任务的成本** | 为每次会话设置令牌预算。将简单工作路由到廉价模型。缓存稳定提示。在预算达到50%、75%和90%时使用警报监控。成本管理是基础设施,而不是优化。 | | 8 | **以周为单位渐进增加复杂度** | 第1周:指令文件。第2周:钩子。第3周:MCP 工具。第4周:技能。第二个月+:子智能体。如果你的团队有分布式系统经验,可以更快——但在增加下一层之前仍要验证每一层。 | --- ## 架构 %3b%7d%23mermaid-0 .cluster rect%7bfill:white%3bstroke:%23f97316%3bstroke-width:1px%3b%7d%23mermaid-0 .cluster text%7bfill:%23f97316%3b%7d%23mermaid-0 .cluster span%7bcolor:%23f97316%3b%7d%23mermaid-0 div.mermaidTooltip%7bposition:absolute%3btext-align:center%3bmax-width:200px%3bpadding:2px%3bfont-family:'Suisse Intl'%2cui-sans-serif%2csystem-ui%2c-apple-system%2csans-serif%3bfont-size:12px%3bbackground:%23fafafa%3bborder:1px solid %23f97316%3bborder-radius:2px%3bpointer-events:none%3bz-index:100%3b%7d%23mermaid-0 .flowchartTitleText%7btext-anchor:middle%3bfont-size:18px%3bfill:%230f172a%3b%7d%23mermaid-0 rect.text%7bfill:none%3bstroke-width:0%3b%7d%23mermaid-0 .icon-shape%2c%23mermaid-0 .image-shape%7bbackground-color:%23fafafa%3btext-align:center%3b%7d%23mermaid-0 .icon-shape p%2c%23mermaid-0 .image-shape p%7bbackground-color:%23fafafa%3bpadding:2px%3b%7d%23mermaid-0 .icon-shape .label rect%2c%23mermaid-0 .image-shape .label rect%7bopacity:0.5%3bbackground-color:%23fafafa%3bfill:%23fafafa%3b%7d%23mermaid-0 .label-icon%7bdisplay:inline-block%3bheight:1em%3boverflow:visible%3bvertical-align:-0.125em%3b%7d%23mermaid-0 .node .label-icon path%7bfill:currentColor%3bstroke:revert%3bstroke-width:revert%3b%7d%23mermaid-0 .node .neo-node%7bstroke:%230f172a%3b%7d%23mermaid-0 %5bdata-look='neo'%5d.node rect%2c%23mermaid-0 %5bdata-look='neo'%5d.cluster rect%2c%23mermaid-0 %5bdata-look='neo'%5d.node polygon%7bstroke:url(%23mermaid-0-gradient)%3bfilter:drop-shadow( 1px 2px 2px rgba(185%2c185%2c185%2c1))%3b%7d%23mermaid-0 %5bdata-look='neo'%5d.node path%7bstroke:url(%23mermaid-0-gradient)%3bstroke-width:1px%3b%7d%23mermaid-0 %5bdata-look='neo'%5d.node .outer-path%7bfilter:drop-shadow( 1px 2px 2px rgba(185%2c185%2c185%2c1))%3b%7d%23mermaid-0 %5bdata-look='neo'%5d.node .neo-line path%7bstroke:%230f172a%3bfilter:none%3b%7d%23mermaid-0 %5bdata-look='neo'%5d.node circle%7bstroke:url(%23mermaid-0-gradient)%3bfilter:drop-shadow( 1px 2px 2px rgba(185%2c185%2c185%2c1))%3b%7d%23mermaid-0 %5bdata-look='neo'%5d.node circle .state-start%7bfill:black%3b%7d%23mermaid-0 %5bdata-look='neo'%5d.icon-shape .icon%7bfill:url(%23mermaid-0-gradient)%3bfilter:drop-shadow( 1px 2px 2px rgba(185%2c185%2c185%2c1))%3b%7d%23mermaid-0 %5bdata-look='neo'%5d.icon-shape .icon-neo path%7bstroke:url(%23mermaid-0-gradient)%3bfilter:drop-shadow( 1px 2px 2px rgba(185%2c185%2c185%2c1))%3b%7d%23mermaid-0 .node rect%2c%23mermaid-0 .node circle%2c%23mermaid-0 .node ellipse%2c%23mermaid-0 .node polygon%2c%23mermaid-0 .node path%2c%23mermaid-0 .actor%2c%23mermaid-0 .labelBox%7bstroke-width:1px%3b%7d%23mermaid-0 .edgePath .path%2c%23mermaid-0 .flowchart-link%7bstroke-width:1.25px%3b%7d%23mermaid-0 .cluster rect%7bstroke-width:1px%3bstroke-dasharray:3%2c4%3brx:0%3bry:0%3b%7d%23mermaid-0 .cluster .nodeLabel%2c%23mermaid-0 .cluster-label .nodeLabel%7bfont-size:11px%3bfont-weight:500%3bletter-spacing:0.14em%3btext-transform:uppercase%3b%7d%23mermaid-0 .edgeLabel%7bfont-size:12px%3bfont-weight:400%3b%7d%23mermaid-0 marker path%7bfill:currentcolor%3b%7d%23mermaid-0 :root%7b--mermaid-font-family:'Suisse Intl'%2cui-sans-serif%2csystem-ui%2c-apple-system%2csans-serif%3b%7d%3c/style%3e%3cg%3e%3cmarker id='mermaid-0_flowchart-v2-pointEnd' class='marker flowchart-v2' viewBox='0 0 10 10' refX='5' refY='5' markerUnits='userSpaceOnUse' markerWidth='8' markerHeight='8' orient='auto'%3e%3cpath d='M 0 0 L 10 5 L 0 10 z' class='arrowMarkerPath' style='stroke-width: 1%3b stroke-dasharray: 1%2c 0%3b'/%3e%3c/marker%3e%3cmarker id='mermaid-0_flowchart-v2-pointStart' class='marker flowchart-v2' viewBox='0 0 10 10' refX='4.5' refY='5' markerUnits='userSpaceOnUse' markerWidth='8' markerHeight='8' orient='auto'%3e%3cpath d='M 0 5 L 10 10 L 10 0 z' class='arrowMarkerPath' style='stroke-width: 1%3b stroke-dasharray: 1%2c 0%3b'/%3e%3c/marker%3e%3cmarker id='mermaid-0_flowchart-v2-pointEnd-margin' class='marker flowchart-v2' viewBox='0 0 11.5 14' refX='11.5' refY='7' markerUnits='userSpaceOnUse' markerWidth='10.5' markerHeight='14' orient='auto'%3e%3cpath d='M 0 0 L 11.5 7 L 0 14 z' class='arrowMarkerPath' style='stroke-width: 0%3b stroke-dasharray: 1%2c 0%3b'/%3e%3c/marker%3e%3cmarker id='mermaid-0_flowchart-v2-pointStart-margin' class='marker flowchart-v2' viewBox='0 0 11.5 14' refX='1' refY='7' markerUnits='userSpaceOnUse' markerWidth='11.5' markerHeight='14' orient='auto'%3e%3cpolygon points='0%2c7 11.5%2c14 11.5%2c0' class='arrowMarkerPath' style='stroke-width: 0%3b stroke-dasharray: 1%2c 0%3b'/%3e%3c/marker%3e%3cmarker id='mermaid-0_flowchart-v2-circleEnd' class='marker flowchart-v2' viewBox='0 0 10 10' refX='11' refY='5' markerUnits='userSpaceOnUse' markerWidth='11' markerHeight='11' orient='auto'%3e%3ccircle cx='5' cy='5' r='5' class='arrowMarkerPath' style='stroke-width: 1%3b stroke-dasharray: 1%2c 0%3b'/%3e%3c/marker%3e%3cmarker id='mermaid-0_flowchart-v2-circleStart' class='marker flowchart-v2' viewBox='0 0 10 10' refX='-1' refY='5' markerUnits='userSpaceOnUse' markerWidth='11' markerHeight='11' orient='auto'%3e%3ccircle cx='5' cy='5' r='5' class='arrowMarkerPath' style='stroke-width: 1%3b stroke-dasharray: 1%2c 0%3b'/%3e%3c/marker%3e%3cmarker id='mermaid-0_flowchart-v2-circleEnd-margin' class='marker flowchart-v2' viewBox='0 0 10 10' refY='5' refX='12.25' markerUnits='userSpaceOnUse' markerWidth='14' markerHeight='14' orient='auto'%3e%3ccircle cx='5' cy='5' r='5' class='arrowMarkerPath' style='stroke-width: 0%3b stroke-dasharray: 1%2c 0%3b'/%3e%3c/marker%3e%3cmarker id='mermaid-0_flowchart-v2-circleStart-margin' class='marker flowchart-v2' viewBox='0 0 10 10' refX='-2' refY='5' markerUnits='userSpaceOnUse' markerWidth='14' markerHeight='14' orient='auto'%3e%3ccircle cx='5' cy='5' r='5' class='arrowMarkerPath' style='stroke-width: 0%3b stroke-dasharray: 1%2c 0%3b'/%3e%3c/marker%3e%3cmarker id='mermaid-0_flowchart-v2-crossEnd' class='marker cross flowchart-v2' viewBox='0 0 11 11' refX='12' refY='5.2' markerUnits='userSpaceOnUse' markerWidth='11' markerHeight='11' orient='auto'%3e%3cpath d='M 1%2c1 l 9%2c9 M 10%2c1 l -9%2c9' class='arrowMarkerPath' style='stroke-width: 2%3b stroke-dasharray: 1%2c 0%3b'/%3e%3c/marker%3e%3cmarker id='mermaid-0_flowchart-v2-crossStart' class='marker cross flowchart-v2' viewBox='0 0 11 11' refX='-1' refY='5.2' markerUnits='userSpaceOnUse' markerWidth='11' markerHeight='11' orient='auto'%3e%3cpath d='M 1%2c1 l 9%2c9 M 10%2c1 l -9%2c9' class='arrowMarkerPath' style='stroke-width: 2%3b stroke-dasharray: 1%2c 0%3b'/%3e%3c/marker%3e%3cmarker id='mermaid-0_flowchart-v2-crossEnd-margin' class='marker cross flowchart-v2' viewBox='0 0 15 15' refX='17.7' refY='7.5' markerUnits='userSpaceOnUse' markerWidth='12' markerHeight='12' orient='auto'%3e%3cpath d='M 1%2c1 L 14%2c14 M 1%2c14 L 14%2c1' class='arrowMarkerPath' style='stroke-width: 2.5%3b'/%3e%3c/marker%3e%3cmarker id='mermaid-0_flowchart-v2-crossStart-margin' class='marker cross flowchart-v2' viewBox='0 0 15 15' refX='-3.5' refY='7.5' markerUnits='userSpaceOnUse' markerWidth='12' markerHeight='12' orient='auto'%3e%3cpath d='M 1%2c1 L 14%2c14 M 1%2c14 L 14%2c1' class='arrowMarkerPath' style='stroke-width: 2.5%3b stroke-dasharray: 1%2c 0%3b'/%3e%3c/marker%3e%3cg class='root'%3e%3cg class='clusters'%3e%3cg class='cluster' id='mermaid-0-ext' data-look='classic'%3e%3crect style='' x='8' y='1581.171875' width='710.03125' height='124'/%3e%3cg class='cluster-label' transform='translate(319.734375%2c 1581.171875)'%3e%3cforeignObject width='86.5625' height='16.5'%3e%3cdiv xmlns='http://www.w3.org/1999/xhtml' style='display: table-cell%3b white-space: nowrap%3

相似文章

构建高效的智能体

Anthropic Engineering

Anthropic 发布了构建高效 AI 智能体的工程指南,倡导采用简单、可组合的模式以及直接使用 API,而非依赖复杂的框架。文章区分了工作流与自主智能体,并就何时使用每种架构提供了实用建议。