Agent 产品设计模式库
五族总览
| 族 | 模式构成 | 一句话心法 | 代表实现 |
|---|---|---|---|
| 族Ⅰ 工具调用反馈 | 流式工具回显 / 骨架屏占位 / 进度树 / 断流恢复NEW | 让「正在干活」可见、可料、可打断,且断线不断活 | Deep Research[4]·AI SDK resume[20] |
| 族Ⅱ 错误处理对话 | 重试征询 / 降级声明 / 归因道歉 / 快照回退NEW | 先自己兜,兜不住就交还,说清错在哪,还能撤回 | τ-bench[12]·Claude Code[18] |
| 族Ⅲ 人机权责移交 | 影子执行 / 实时接管 / 中断细化 / 双控确认 | 权责是一条连续光谱,不是全有全无 | Operator·computer use·τ²[5][6][13] |
| 族Ⅳ 多Agent协作 | 总分看板 / 产物引用 / 对话流 / 辩论呈现NEW | 子任务可见、产物落盘、总控收口、共识可追溯 | Anthropic[2]·AutoGen[14]·Debate[19] |
| 族Ⅴ 记忆与上下文治理 | 成本仪表盘NEW / 压力仪表NEW / 压缩提案NEW / 分区编辑NEW | 窗是预算、记是资产,都要让用户看得清改得动 | Letta[16]·Claude Code[21][22][23]·ChatGPT[24] |
让「正在干活」可见、可料、可打断
做法 每触发一次工具调用就向用户回显「动作+对象+中间结果」,流式追加而非完成后一次性吐出;每行带可展开的原始返回。
适用 检索/浏览器/多工具链式调用;时长 10 秒~3 分钟的任务。
做法 内容未生成前先渲染最终版式(表框/卡片/图轴),用微光占位块标记待填区域;数据到达按结构逐格填充。
适用 结构可预测的产出:表格、榜单、研报页、仪表盘刷新。
做法 任务规划成一棵步骤树,节点三态:✓完成 / ⚙进行中(带子步骤与计数)/ ○待办;支持点击展开中间产物、随时暂停。
适用 长任务(>3 分钟)、可分解为明确子步骤的研究/批处理/构建类任务。
做法 把「断线」与「取消」严格区分:客户端刷新、关页、stop() 只断开连接,不终止底层生成;重连后从断点续流,断流期间的产出保留可查,并明示「任务仍在运行」。
适用 分钟级以上的长任务 Web/App 端;移动端切后台、弱网、页面刷新是高发场景。
先自己兜,兜不住就交还,且说清错在哪
做法 瞬时故障先静默重试(≤2 次并回显「已重试 n 次」);仍失败则给出 2–3 条带代价标注的选项交用户裁决,默认项标安全动作。
适用 外部 API 抖动、超时、限流等瞬时类故障。
做法 数据源/能力缺失时不用次级数据冒充完整结果:明确标记「降级」,列出受影响范围,给出恢复后重算入口。
适用 多源聚合、跨系统取数、依赖第三方接口的报表与扫描。
做法 三段式:①说人话讲清直接原因(不是抛错误码);②声明已尝试与未尝试的边界;③把下一步选择权交还用户。不甩锅用户、不假装无事。
适用 任务级失败、不可自动恢复的错误、涉及用户资产/社交后果的操作。
做法 Agent 每次改状态前自动留快照;出错时提供「回到哪一步」的选择器,对话状态与文件状态双轨同时还原(可只回滚其一),回退前 diff 预览,回退后保留重做入口。同时如实声明快照覆盖边界:shell 命令副作用、外部系统写入、快照范围外的改动均不在回退之列,「不是版本控制的替代品」。
适用 会污染工作区的 Agent:代码编辑、文档改写、配置修改、批量文件操作。
权责是一条连续光谱,不是全有全无
做法 Agent 的动作先走「干跑/模拟」通道并留影子履历,用户核过实绩后再授权真实执行;等价于把 HAX G19「用户是最终仲裁」做成产品机制。
适用 高风险不可逆动作:交易下单、批量删除、对外发送、生产变更。
做法 Agent 执行期间保持「可观察+可打断」:实时高亮当前操作对象,一键移交回人类;接管后 Agent 退居副驾。
适用 浏览器/桌面 GUI 自动化、填写表单、代订代购。
做法 长任务任何时刻可插入自然语言修正:系统暂停、diff 式呈现计划变更、确认后续跑;保进度不从头再来。
适用 研究类、构建类、任何「跑起来才发现方向不对」的长任务。
做法 承认用户也是「有工具的操作者」:把需用户动手的步骤显式编入任务流(带说明与确认回执),而非甩一条指令完事;双方动作时间线对齐可回溯。
适用 技术支持、设备配置、医健/金融等必须用户本人操作的场景。
子任务可见、产物落盘、总控收口
做法 总控与子 Agent 各占一行/一卡:头像+职责+状态+产物链接;总控行显示汇总进度与资源消耗;每行可展开进子 Agent 的工作流水。
适用 任何「1 总控 + N 并行子任务」结构:深度研究、批量体检、多源采集。
做法 子 Agent 大产物写入外部工件区,对话流中只传轻量引用;引用可点开预览,产物永久可查,不随会话滚动丢失。
适用 产物为文件形态(表格/图片/代码/长文)的一切多 Agent 协作。
做法 Agent 间协作呈现为一条可折叠的群聊流:每条消息带发言者徽标,默认折叠只给结论,展开可审计全过程;用户可随时插话成为群成员之一。
适用 创作/评审/辩论类任务,过程质量依赖多角色制衡的场景。
做法 与 4.3 群聊流的分工:群聊流呈现流水线(写作→评审→合并),辩论视图呈现对抗。用发言者×轮次的矩阵/时间轴记录各方立场与互相反驳;收敛时明确区分「共识点」「保留分歧点」「由谁拍板」;辩论轮次设上限(如 3 轮或收敛即停)。学术依据:多实例「propose and debate their individual responses and reasoning processes over multiple rounds to arrive at a common final answer」,实证提升数学/策略推理并「improves the factual validity…reducing fallacious answers and hallucinations」[19]。
适用 高不确定性裁决:投资决策、方案取舍、事实交叉核验、内容审校争议项。
窗是预算、记是资产,都要摊在桌面上
做法 成本与额度从「月底才知道」变成随手可查的实时面板:当前任务即时消耗(输入/输出分列+缓存收益)、周期额度占比+重置倒计时、按日/按任务/按模型的消耗分布。大厂实现即「/usage」——"Show session cost, plan usage limits, and activity stats."[22],订阅计划下"also shows a breakdown of what counts against your plan limits"、可按归因(技能/子Agent/MCP)拆分[21],并附一套降载建议(主动管理上下文、按需选模型、削减工具定义开销)。
适用 一切计费/有额度墙的产品:API 工具、订阅制 Agent、团队共享池。对免费自托管场景同样适用——token 吞吐本身就是产能指标。
做法 一屏堆叠条形图把窗口逐类拆开:系统提示/记忆/工具定义/对话历史/剩余各占多少,一眼定位大头;跨过水位线(如 80%)主动告警并提示处置。产品语义:「When the conversation gets long, /context shows what's filling the window and /compact summarizes it to free space.」[22]「Visualize current context usage as a colored grid. Shows optimization suggestions for context-heavy tools, memory bloat, and capacity warnings.」[22]
适用 长会话 Agent(编码助手、研究助手、私人管家);凡是「越聊越笨」会被用户归因为模型退化的产品。
做法 在逼近窗口极限前先提案后执行:给出压缩预估(前后 token 数)、可预览的摘要草稿、明确的丢弃清单;用户可改可拒,也可一次授权让后续自动执行。压缩不重写「事实」,只重写「表述」。
适用 以小时/天计的长会话、多日任务接力;配合 5.2 的压力水位线触发。
做法 把进入上下文的材料按生命周期分区(长期记忆 / 项目规程 / 会话临时),每条可独立增删改,改动即时回显到「它如何影响后续回答」。工程形态有现成参照:索引常驻、全文按需加载——「a MEMORY.md index and one topic file per memory…one line per memory, loaded into every session」[23],验证装载用「To check which files actually loaded into the current session, run /context」[23]。消费者端参照:记忆的查看/删除/清空做成用户可及的设置项——「view and delete specific memories or clear all memories in settings」,并如实告知作用域「memories evolve…aren't linked to specific conversations; deleting a chat doesn't erase its memories」[24]。
适用 任何带跨会话记忆的 Agent:私人助理、长期项目伙伴、多用户团队。
按触发信号对号入座
| 设计情境(触发信号) | 首选模式 | 组合用法 | 禁忌 |
|---|---|---|---|
| 任务 > 20 秒,用户开始疑惑「死了没」 | 1.1 流式回显 | +1.3 进度树;>3 分钟再加可打断 | 静默转圈 |
| 产出结构可预测(表/榜单/卡片) | 1.2 骨架屏 | +1.1 回显每格填充进度 | 版式跳变 |
| 长任务用户会刷新/切后台/弱网 | 1.4 断流恢复 ★ | +1.1 回显断流期已产出清单 | 刷新即丢单 |
| 长任务需中途改需求 | 3.3 中断细化 | +1.3 进度树锚点,diff 后续跑 | 全量重跑 |
| 瞬时故障(超时/限流/抖动) | 2.1 重试征询 | 静默重试 ≤2 次→征询,选项带代价 | 无限静默重试 |
| 数据源缺失但仍要交付 | 2.2 降级声明 | +2.1:降级项单独列出可重算 | 悄悄换源 |
| 任务级失败,不可自愈 | 2.3 归因道歉 | 三段式:原因→边界→交还选择权 | 空洞道歉 |
| Agent 已改坏用户文件/工作区 | 2.4 快照回退 ★ | +1.1 打点回显;回退前 diff 预览 | 回退万能错觉 |
| 高危不可逆动作(交易/删除/发送) | 3.1 影子执行 | +3.4 双控确认;履历可审计 | 直接真实执行 |
| Agent 操控 GUI 替用户干活 | 3.2 实时接管 | +急停热键;接管后 Agent 退副驾 | 抢焦点 |
| 1 总控 + N 子任务并行 | 4.1 总分看板 | +4.2 产物引用;折叠子流水 | 串行假象 |
| 创作/评审需多角色制衡 | 4.3 对话流 | 默认折叠到结论,展开可审计 | 过程刷屏 |
| 高风险裁决要兼听(投资/方案取舍) | 4.4 辩论呈现 ★ | +3.1 影子执行收口;轮次设上限 | 伪多元回音室 |
| API 计费/团队额度墙/免费池限速 | 5.1 成本仪表 ★ | +4.1 看板按 Agent 分账 | 账单惊吓 |
| 会话以小时/天计,出现「越聊越笨」 | 5.2 压力仪表 +5.3 压缩提案 ★ | 水位线触发提案;预览后执行 | 静默截断/破坏性压缩 |
| Agent 带跨会话个人记忆 | 5.4 分区编辑 ★ | +5.2 分区计量;敏感条目加审查位 | 记忆黑箱 |
两条普适判据
全部一手来源,逐条经原文核验
| # | 来源(一手) | 类型 / 核验日期 | 关键引文(逐字) |
|---|---|---|---|
| [1] | Building effective agents — Anthropic Engineering anthropic.com/engineering/building-effective-agents |
工程博客 · 2026-09-11 核验 | "the most successful implementations weren't using complex frameworks or specialized libraries. Instead, they were building with simple, composable patterns." |
| [2] | How we built our multi-agent research system — Anthropic anthropic.com/engineering/built-multi-agent-research-system |
工程博客 · 2026-09-11 核验 | "lead agent plans the research process…uses tools to create parallel agents that search for information simultaneously"; "implement artifact systems…then pass lightweight references back to the coordinator" |
| [3] | A practical guide to building agents — OpenAI cdn.openai.com/business-guides-and-resources/a-practical-guide-to-building-agents.pdf |
官方 PDF(34p) · 2026-09-11 核验 | "In case of failure, it can halt execution and transfer control back to the user." ; "always operating within clearly defined guardrails" |
| [4] | Introducing deep research — OpenAI openai.com/index/introducing-deep-research/ |
产品公告(2025-02-02 发布,2026-02-10 更新) · 2026-09-11 核验 | "track progress in real-time and interrupt to refine with follow-up prompts or new sources" |
| [5] | Introducing Operator — OpenAI openai.com/index/introducing-operator/ |
产品公告(2025-01-23 发布,2025-07-17 并入 agent mode) · 2026-09-11 核验 | "Using its own browser, it can look at a webpage and interact with it by typing, clicking, and scrolling." |
| [6] | Introducing computer use… — Anthropic anthropic.com/news/3-5-models-and-computer-use |
产品公告(2024-10-22 发布) · 2026-09-11 核验 | "direct Claude to use computers the way people do—by looking at a screen, moving a cursor, clicking buttons, and typing text." |
| [7] | HAX Toolkit / Guidelines for Human-AI Interaction — Microsoft microsoft.com/en-us/haxtoolkit/ |
设计指南库 · 2026-09-11 核验 | 18 条 guideline 含 G4「明了现状:时间/结果/原因+下次会怎样」、G19「user is the final arbiter of what the AI does」 |
| [8] | SWE-agent: Agent-Computer Interfaces Enable Automated Software Engineering arxiv.org/abs/2405.15793 |
论文(cs.SE,2024-05-06 提交) · 2026-09-11 核验 | "we investigate how interface design affects the performance of language model agents…custom agent-computer interface (ACI) significantly enhances an agent's ability" |
| [9] | GitHub Copilot Workspace: the Copilot-native developer environment github.blog/news-insights/product-news/github-copilot-workspace/ |
产品博客(2024-04 发布 technical preview) · 2026-09-11 核验 | "developers can now brainstorm, plan, build, test, and run code in natural language…giving developers full control over every step of the process." |
| [10] | People + AI Guidebook · Mental Models — Google PAIR pair.withgoogle.com/chapter/mental-models |
设计指南 · 2026-09-11 核验 | "Mismatched mental models can lead to unmet expectations, frustration, misuse, and product abandonment." ; "Onboard in stages…explain what it can do, what it can't do, how it may change." |
| [11] | Designing AI Agents: 4 Lessons from China's Qwen Agent — NN/g(Feifei Liu & Maria Rosala) nngroup.com/articles/designing-ai-agents/ |
UX 研究(2026-05-08) · 2026-09-11 核验 | "4 design lessons: support discoverability, reuse familiar patterns, handle personal data carefully, and protect user autonomy." |
| [12] | τ-bench: A Benchmark for Tool-Agent-User Interaction in Real-World Domains arxiv.org/abs/2406.12045 |
论文(cs.AI,2024-06-17 提交) · 2026-09-11 核验 | "even state-of-the-art function calling agents (like gpt-4o) succeed on <50% of the tasks, and are quite inconsistent (pass^8 <25% in retail)." |
| [13] | τ²-Bench: Evaluating Conversational Agents in a Dual-Control Environment arxiv.org/abs/2506.07982 |
论文(cs.AI,2025-06-09 提交) · 2026-09-11 核验 | "users need to actively participate in modifying the state of the (shared) world…both agent and user make use of tools to act in a shared, dynamic environment." |
| [14] | AutoGen: Enabling Next-Gen LLM Applications via Multi-Agent Conversation arxiv.org/abs/2308.08155 |
论文(cs.AI,2023-08-16 提交) · 2026-09-11 核验 | "allows developers to build LLM applications via multiple agents that can converse with each other to accomplish tasks." |
| [15] | Introducing Codex — OpenAI openai.com/index/introducing-codex/ |
产品公告(2025-05-16 发布) · 2026-09-11 核验 | "each task runs in its own cloud sandbox environment, preloaded with your repository." |
| [16] | Agent Memory: How to Build Agents That Learn and Remember — Letta letta.com/blog/agent-memory |
工程博客(2025-07-07,datePublished 核验) · 2026-09-11 核验 | "designing an agent's memory is essentially context engineering: determining which tokens enter the context window and how they're organized." |
| [17] | A Concrete Definition of an AI Agent — NN/g(Caleb Sponheim) nngroup.com/articles/definition-ai-agent/ |
UX 研究(2026-04-03) · 2026-09-11 核验 | "An AI agent is a system that pursues a goal by iteratively taking actions, evaluating progress, and deciding its own next steps." |
| [18] | Checkpointing — Claude Code Docs code.claude.com/docs/en/checkpointing |
官方文档(dateModified 2026-09-11) · 2026-09-12 核验 | "Track, rewind, and summarize Claude's edits and conversation to manage session state."; Limitations 章:"Bash command changes not tracked…External changes not tracked…Not a replacement for version control" |
| [19] | Improving Factuality and Reasoning in Language Models through Multiagent Debate — Du, Li, Torralba, Tenenbaum, Mordatch(MIT & Google Brain) arxiv.org/abs/2305.14325 |
论文(cs.CL,2023-05-23 提交) · 2026-09-12 核验 | "multiple language model instances propose and debate their individual responses and reasoning processes over multiple rounds to arrive at a common final answer" ; "improves the factual validity of generated content, reducing fallacious answers and hallucinations" |
| [20] | AI SDK UI: Chatbot Resume Streams — Vercel ai-sdk.dev/docs/ai-sdk-ui/chatbot-resume-streams |
官方文档(v7) · 2026-09-12 核验 | "useChat supports resuming ongoing streams after page reloads…In a resumable stream setup, client-side aborts are treated as disconnects. Closing a tab, refreshing the page, or calling stop() only closes the current HTTP connection and should not cancel the underlying generation." ; "add a dedicated stop endpoint that persists the partial response" |
| [21] | Manage costs effectively — Claude Code Docs code.claude.com/docs/en/costs |
官方文档 · 2026-09-12 核验 | 页内导航:"Track your costs / Using the /usage command / Prompt cache statistics / Plan usage breakdown / Check your usage-credits spend / Analyze your usage patterns";"On a Pro, Max, Team, or Enterprise plan, /usage also shows a breakdown of what counts against your plan limits: Attribution: recent usage attributed to skills, subagents, plugins, and individual MCP servers";降载建议 "Manage context proactively / Choose the right model / Reduce MCP server overhead" |
| [22] | Commands(/usage·/context·/compact 条目)— Claude Code Docs code.claude.com/docs/en/commands |
官方文档 · 2026-09-12 核验 | "/usage Show session cost, plan usage limits, and activity stats."; "/context Visualize current context usage as a colored grid. Shows optimization suggestions for context-heavy tools, memory bloat, and capacity warnings."; "/compact [instructions] Free up context by summarizing the conversation so far. Optionally pass focus instructions for the summary."; 叙述句 "When the conversation gets long, /context shows what's filling the window and /compact summarizes it to free space." |
| [23] | How Claude remembers your project — Claude Code Docs code.claude.com/docs/en/memory |
官方文档 · 2026-09-12 核验 | "The directory contains a MEMORY.md index and one topic file per memory… MEMORY.md # Index, one line per memory, loaded into every session"; "To check which files actually loaded into the current session, run /context."; "after /compact, Claude re-reads it from disk and re-injects it into the session" |
| [24] | Memory and new controls for ChatGPT — OpenAI openai.com/index/memory-and-new-controls-for-chatgpt/ |
产品公告(2025-04-10 发布) · 2026-09-12 核验 | "You can also view and delete specific memories or clear all memories in settings (Settings > Personalization > Manage Memory)." ; "ChatGPT's memories evolve with your interactions and aren't linked to specific conversations. Deleting a chat doesn't erase its memories; you must delete the memory itself." |