构建长时间运行 AI Agent 的 5 种设计模式 ✍ Google Cloud Tech🕐 2026-04-23📦 11.1 KB 🟢 已读 𝕏 文章列表 文章探讨了在构建需要持续运行数天甚至数周的 AI Agent 时所面临的挑战,并介绍了 Google Cloud Agent Runtime 支持的五种核心设计模式。这些模式包括:检查点与恢复以确保容错性、委托审批以实现人机协同、分层记忆架构以管理长期上下文、环境处理以应对无监督任务,以及针对多 Agent 协同的舰队编排。文章强调了状态管理、治理策略和基础设施在将 Agent 从演示转化为生产级系统中的重要性。 Agent设计模式架构Google Cloud状态管理人机协作记忆层编排生产实践AI工程 # 5 Agent Design patterns for Long-running AI Agents **作者**: Google Cloud Tech **日期**: 2026-04-22T16:30:13.000Z **来源**: [https://x.com/GoogleCloudTech/status/2046989964077146490](https://x.com/GoogleCloudTech/status/2046989964077146490) ---  Developers spend weeks perfecting prompt engineering, tool calling, and response latency. None of it matters when your agent needs to stay alive for five days. The workflows that actually matter in production (processing thousands of insurance claims, running week-long sales sequences, reconciling financial data across systems) don't fit inside a single conversation turn. They take days, not seconds. The moment you try to build these long-running agents, you realize most agent architectures are stateless. They reconstruct context from databases on every interaction. They lose the reasoning chain, the soft signals, and the confidence gradients that made the agent's previous decisions make sense. At Cloud Next 26, we announced that Agent Runtime now supports long-running agents that maintain state for up to seven days. In this article, we’ll share five essential agent design patterns for building long-running agents with Agent Runtime. By @addyosmani and @Saboo_Shubham_ Here are five design patterns that separate production systems from demos. ## Pattern 1: Checkpoint-and-Resume The most common failure mode in multi-day workflows is context loss. An agent processes 200 documents over four hours, then hits an error on document 201. Without checkpointing, you restart from scratch.  Long-running agents on Agent Runtime maintain persistent execution state in a secure cloud sandbox. The agent has full access to bash commands and a sandboxed file system, so you can write intermediate results to disk, maintain processing logs, and recover from failures. Treat your agent like a long-running server process, not a request handler. The same way you build a data pipeline that processes millions of records: checkpoint progress, handle partial failures, ensure idempotency. Here is how you structure a document processing agent that checkpoints after every batch using Google Agent Development Kit: Notice the checkpoint granularity. Not after every document (wasteful). Not only at the end (risky). Fifty documents per batch balances durability against overhead. Your specific number depends on how expensive each unit of work is. ## Pattern 2: Delegated Approval (Human-in-the-Loop) Every framework advertises human-in-the-loop. But in practice, most implementations are: serialize state to JSON, send a webhook, hope someone checks it. The problems compound fast. JSON serialization loses implicit reasoning context. Notifications compete with dozens of alerts. When the human responds hours later, the agent has to deserialize, re-establish context, and hope nothing changed. Long-running agents handle this differently. When the agent hits an approval gate, it pauses in place. Full execution state stays intact: reasoning chain, working memory, tool call history, pending action. Here's what that looks like in practice:  The critical detail: hours 8 through 32 are dead time for the agent but active time for the human. The agent consumes zero compute while paused. Sub-second cold starts mean zero latency penalty when it resumes. Mission Control provides the inbox that makes this manageable at scale. Notifications categorized into "Needs your input," "Errors," and "Completed." If you're managing twenty long-running agents, you're not hunting through Slack channels to figure out which ones need attention. ## Pattern 3: Memory-Layered Context A seven-day agent needs more than session state. It needs to remember things from previous sessions, user preferences from weeks ago, and organizational context that no single conversation could contain. This is where Memory Bank and the new Memory Profiles work together.  Memory Bank (now available for everyone) dynamically generates and curates memories from conversations, organized by topic. Memory Profiles add low-latency access to specific, high-accuracy details. Think of Memory Bank as long-term memory and Memory Profiles as working memory. But here's the problem most developers don't anticipate until production: memory drift. Your agent's behavior isn't shaped only by its code and prompts. It's shaped by accumulated experience. If an agent "learns" from a few atypical interactions that a procedural shortcut is acceptable, it might start applying that shortcut broadly. And if multiple agents read and write to shared memory pools, data leakage between distinct workflows becomes a real risk. You can't let agents write to a vector database unchecked. You need to govern them the same way you govern microservices. This is where Agent Identity, Agent Registry, and Agent Gateway come in. They bring standard infrastructure concepts into the agent lifecycle: Agent Identity works like IAM for agents. Just as a microservice needs a service account, an agent needs a cryptographic identity that determines exactly which memory banks and tools it's authorized to access. Agent Registry works like service discovery. When you have dozens of long-running agents, you need a centralized way to track which agents are active, what version of the prompt and code they're running, and what their current execution state is. Agent Gateway works like an API gateway tailored for LLMs. It sits between the agent and its memory and tools, evaluating requests against organizational policies. If an agent tries to commit PII to its long-term Memory Bank, the Gateway blocks the transaction. Build auditing into your memory layer from day one. The question isn't just "what are my agents doing?" It's "what are my agents remembering, and how is that changing their behavior?" ## Pattern 4: Ambient Processing Not every long-running agent interacts with humans. Some are ambient. They watch for events, process data streams, and take action in the background without any user prompting. Batch and Event-Driven Agents connect directly to BigQuery tables and Pub/Sub streams. Here's a concrete example: a content moderation agent that processes user-generated content as it arrives.  This agent runs for days. It doesn't wait for someone to ask it to moderate content. It processes events as they arrive, maintains its own state about trends and patterns, and escalates only when necessary. The important architectural decision here ties back to the governance layer from Pattern 3. Don't hardcode content policies into the agent. Define them in Agent Gateway and the agent enforces them at runtime. When policies change, you update Gateway once and every ambient agent picks up the new rules. The agent's identity (from Agent Identity) determines which policies apply to it, and the Registry tracks which version of the agent is running against which policy set. This separation matters because ambient agents run unsupervised for long stretches. If you hardcode policies, every policy change requires redeploying every agent. If you externalize policies through the Gateway, you update once and the fleet adapts. ## Pattern 5: Fleet Orchestration The final pattern is about managing multiple long-running agents as a coordinated fleet. In production, you rarely have a single agent working alone. You have a coordinator agent that delegates sub-tasks to specialist agents, each running independently for different durations. Consider a sales prospecting sequence:  Each specialist has its own Agent Identity (so it can only access the tools and memory it needs), its own policy enforcement through Agent Gateway (so the Outreach Agent can't access financial data meant for the Scoring Agent), and its own entry in the Agent Registry (so you can track versions and execution state across the fleet). The coordinator maintains global state and handles handoffs between specialists. This is the same coordinator/worker pattern used in distributed systems for decades. What's new is that ADK handles this natively with graph-based workflows that define coordination logic declaratively. The operational advantage of treating each specialist as an independent unit is that you can update them independently too. If your Scoring Agent's ranking logic needs improvement, you can deploy the new version, monitor its performance through Agent Observability, and promote it only when the results hold up. And because each agent runs in its own container (with Bring Your Own Container support for your existing CI/CD and security requirements), a bad deployment in one specialist never cascades to the others. ## Choosing the Right Pattern These patterns compose. A compliance system might use Checkpoint-and-Resume for document processing, Delegated Approval for review gates, Memory-Layered Context for cross-session knowledge, and Fleet Orchestration to coordinate specialists. The key question: what is the longest uninterrupted unit of work your agent needs to perform? If it's minutes, you probably don't need long-running agents. If it's hours or days, these patterns are where you start. ## Get started Long-running agents are available today on Gemini Enterprise Agent Platform. Build with ADK, deploy on Agent Runtime, monitor via Mission Control. The combination of 7-day persistence, human-in-the-loop approvals, and long-term memory is what turns an agent from a chatbot into an autonomous worker. Start here: https://cloud.google.com/gemini-enterprise/agents ## 🚢 Put These Patterns into Practice: Google for Startups AI Agents Challenge Don't just read about agent architecture - build it. We’re inviting startups to a 6-week global challenge to build, optimize, or refactor AI agents on the Gemini Enterprise Agent Platform. You'll get $500 in cloud credits, full platform access and a shot at the $90,000 prize pool. Sign up today to start building! ## 相关链接 - [Google Cloud Tech](https://x.com/GoogleCloudTech) - [@GoogleCloudTech](https://x.com/GoogleCloudTech) - [66K](https://x.com/GoogleCloudTech/status/2046989964077146490/analytics) - [@addyosmani](https://x.com/@addyosmani) - [@Saboo_Shubham_](https://x.com/@Saboo_Shubham_) - [https://cloud.google.com/gemini-enterprise/agents](https://cloud.google.com/gemini-enterprise/agents) - [Sign up today to start building](https://devpost.team/hackathon_guest_invites/4fb181b4-2722-415d-a442-285a57dcaba5?utm_source=twitter&utm_medium=social&utm_campaign=google-for-startups-ai-agents-challenge&utm_content=twitter-post) - [Upgrade to Premium](https://x.com/i/premium_sign_up) - [12:30 AM · Apr 23, 2026](https://x.com/GoogleCloudTech/status/2046989964077146490) - [66.4K Views](https://x.com/GoogleCloudTech/status/2046989964077146490/analytics) - [View quotes](https://x.com/GoogleCloudTech/status/2046989964077146490/quotes) --- *导出时间: 2026/4/23 10:44:01*
图 图工程究竟是什么? 文章探讨了AI工程领域的新术语“图工程”。它并非新发明,而是对多Agent协作系统的宏观视角,通过节点和边映射工作流、状态和依赖关系,解决复杂系统的架构与调试问题。 技术 › Agent ✍ Towards AI🕐 2026-07-20 Graph EngineeringAgentWorkflowAI架构Claude动态工作流状态管理
每 每位 ADK 开发人员都应该了解的 5 种代理技能设计模式 本文重点介绍了 ADK 开发中的 5 种代理技能设计模式,旨在帮助开发者超越单纯的格式规范,深入内容逻辑设计。文章详细解析了工具包装器、生成器、审核员、反转和流水线五种模式,涵盖了从知识封装、一致性生成、代码审查到交互流程控制等关键环节,并提供了决策树以指导开发者选择合适的模式构建更可靠的智能体。 技术 › Agent ✍ Google Cloud Tech🕐 2026-03-18 ADKAgent设计模式Skill开发工具Google Cloud代码审查工作流智能体技术架构
C ChatGPT Agent Loop 优化技术解析 本文深入解析了 ChatGPT 如何通过 Harness、API 和 Inference 三层架构优化 Agent 循环,重点介绍了持久化 WebSocket、增量 Token 化、KV 缓存管理和推测解码等技术,以降低成本并提升效率。 技术 › Harness Engineering ✍ Bytebytego🕐 2026-07-30 Agent优化LLM架构ChatGPTOpenAI性能成本控制WebSocketTokenization
B BestBlogs 早报 · 07-29|MCP 无状态化与多智能体编排成本 本期早报探讨 MCP 协议的无状态核心变化与 Claude 的生产化接入,分析 Codex 与 ChatGPT Work 共用的执行框架差异,并审视多智能体并行中上下文搬运的隐性成本“编排器的税”。同时涵盖图工程、vLLM 商业化及 Uber 零增长架构等速览内容。 技术 › LLM ✍ ginobefun🕐 2026-07-29 MCPAgentOpenAI架构多智能体上下文Claude早报DevOps工程化
R Run Your Harness Outside of the Sandbox (Why and How) 本文探讨了2026年以来关于Agent运行位置的争论,指出行业趋势是将Agent运行在沙箱之外。作者详细解释了沙箱内运行的三个主要问题:爆炸半径、信任边界和沙箱的间歇性运行,并提出了将沙箱作为工具暴露的正确架构,最后提供了基于Vercel AI SDK的实现示例和生产环境中的挑战。 技术 › Agent ✍ Nathan Flurry🕐 2026-07-28 Agent沙箱架构设计DevOps后端LLM安全性生产环境Vercel AI SDK状态管理
G Graph Engineering:从 0 到 1 小白完整教程 文章介绍了 Graph Engineering,一种通过流程图协调多个 AI 协作完成复杂任务的方法。它将复杂任务拆解为节点、边和状态,解决了单 Loop 应对复杂任务时的局限性。文章详细解析了 Graph 的核心概念、与 Loop 的关系、四个核心模块及具体实践模板,并提供了新手学习路径。 技术 › Agent ✍ Adrian Punk🕐 2026-07-27 Graph EngineeringAgentLLMAI 协作工作流Loop Engineering教程节点设计状态管理AI 架构
金 金融中的图工程:设计稳健的Agent图 本文探讨了金融领域中Agent图的设计与实现。文章指出,Agent图解决了脚本在等待、重启和并行分支上的缺陷,并通过状态图而非DAG来实现条件路由和循环。重点讨论了状态管理、并行拓扑模式(如Fan-out、Supervisor)以及在金融任务中的实际应用。 技术 › Agent ✍ zostaff🕐 2026-07-25 Agent图工程状态管理并行计算金融LangChain拓扑模式
从 从选题到写作再到发布,我把几十个 skill 串成了一条自动流水线 作者分享了自己如何利用 Hermes、Codex 和 Claude 中的数十个 Skill,搭建了一条从素材抓取、选题分析、风格润色到图文排版的内容自动生成流水线。文章详细介绍了自动化流程的设计思路、遇到的痛点以及如何通过拆分 Prompt 保持文风一致性,同时也反思了人机协作中人工审核与决策的重要性。 技术 › Skill ✍ 得否🕐 2026-07-23 自动化工作流AI写作AgentHermesCodexClaude效率工具内容生产prompt工程人机协作
G Graph Engineering 101: When a Loop Isn’t Enough 文章探讨了AI Agent从简单的ReAct循环向图工程架构的演进。循环模式在处理复杂、多步骤及需人工介入的任务时存在状态持久化、错误处理和分支逻辑的局限性。图工程通过显式的节点、边和状态管理,解决了并发、暂停恢复及复杂流程控制问题,为构建更健壮的Agent系统提供了架构基础。 技术 › Agent ✍ Alex Prompter🕐 2026-07-22 AgentGraph EngineeringReActLangGraph架构设计状态管理LLM
构 构建 Agent 基础设施的真实挑战 文章探讨了构建 Web Agent 基础设施(如浏览器池、隔离机制、观测性等)所面临的复杂性与工程挑战。作者指出,这远不止是启动一个浏览器,需要处理冷启动、安全隔离、资源调度等深层问题,并分析了自建与购买的权衡。 技术 › Agent ✍ harsehaj🕐 2026-07-22 Agent基础设施浏览器架构DevOps安全性工程化
个 个人开发者的生产级 AI 堆栈 文章探讨了 AI 时代单人开发者面临的挑战,指出虽然 AI 加速了从想法到原型的过程,但并未解决从原型到生产环境的安全和运维问题。通过分析失败案例和成功者(如 OpenClaw 作者)的实践,强调了建立构建循环、防御层和自动化运维系统的重要性。 技术 › Agent ✍ Rohit🕐 2026-07-21 AI开发独立开发安全DevOpsAgentOpenClaw生产力架构
为 为什么顶级 AI 工程师不再写提示词:Loops 与 Harness 的崛起 文章指出,AI 交互方式正在从单一的“提示词”转向“循环”。顶级工程师不再手动编写 Prompt,而是设计自动化循环,让智能体自我迭代直至任务完成。以 Slate 工具为例,介绍了如何通过编写 JavaScript“程序”来掌控循环逻辑,实现多模型并行处理和真实世界交互,从而构建更强大的智能系统。 技术 › Agent ✍ Rahul🕐 2026-07-18 AI工程AgentLoopSlate自动化Claude编程提示词工作流JavaScript