3 patterns to build long-running AI agents
By Google Cloud Tech
Key Concepts
- Long-Running Agents: AI agents that maintain state across sessions and operate over extended periods (hours, days, or weeks) to complete multi-step workflows.
- Stateless vs. Stateful: The difference between agents that discard context after a single prompt (stateless) and those that persist memory and progress (stateful).
- Event-Driven Dormancy: The ability of an agent to "sleep" and consume zero compute resources until triggered by an external event.
- Durable Checkpointing: The process of saving the agent's state at every transition to ensure continuity even after system crashes.
- Separated Evaluation: The architectural requirement to use distinct agents for planning, generating, and evaluating to avoid self-bias.
1. Defining Long-Running Agents
Unlike standard "stateless" agent demos that operate within a single, finite context window, long-running agents are designed for workflows rather than simple prompts. They function as autonomous entities that own a multi-step process from start to finish, maintaining their state across sessions that may span days or weeks.
2. Three Pillars of Long-Running Agent Architecture
For an agent to function effectively over a long duration, three technical requirements must be met:
- True Dormancy: Agents must be able to "sleep" to avoid burning compute resources. They should remain inactive until awakened by external triggers such as webhooks, scheduled tasks, human approvals, or tool callbacks.
- Durable Checkpointing: Every transition in a workflow must be durably persisted. This ensures that if a container crashes or a process is interrupted, the agent can resume exactly where it left off without hallucinating intermediate steps or losing context.
- Separated Evaluation: Agents should not grade their own work. Research (including findings from Anthropic) indicates that agents tend to overrate their own performance. A robust architecture requires a three-agent setup:
- Planner: Defines the strategy.
- Generator: Executes the tasks.
- Evaluator: An independent agent that tests the output for quality.
3. Common Challenges ("The Three Walls")
The speaker identifies three primary obstacles that cause agent failure:
- Context Degradation: Even with large context windows, information can become cluttered or lost, leading to a drop in quality. Starting from zero in every session prevents the agent from maintaining a coherent understanding of the problem.
- Lack of Persistent State Primitives: Without external structure, agents are prone to "drift," where they lose track of the objective, break existing work, or simply give up.
- Self-Verification Failure: If an agent cannot objectively determine if a task is complete or if the quality is sufficient, the workflow will inevitably fail or produce subpar results.
4. Breakthroughs and Methodologies
Recent advancements have enabled more reliable long-running agents:
- Agent Harness Engineering: Moving away from monolithic loops toward structured harnesses that manage planning, building, and evaluating separately.
- Persistent Memory Patterns: Utilizing formats like Markdown for "living plans" and change logs (acting as "lab notes") to maintain a record of the agent's reasoning and progress.
- Loop Integration: Implementing frameworks like the ReAct loop (Reason + Act) within the agent harness to ensure tasks are completed systematically.
- Infrastructure Management: Platforms like the Gemini Enterprise Agent platform provide productized solutions for session management and "memory banks," allowing for long-term storage of agent context.
5. Real-World Applications
Long-running agents are ideal for complex business processes that are inherently time-consuming, such as:
- Employee Onboarding: Managing multi-day documentation and access provisioning.
- Loan Processing: Handling multi-step verification, analysis, and approval workflows that require human interaction and external data validation.
Synthesis
The transition from "chatbot" to "long-running agent" represents a shift from simple request-response interactions to autonomous workflow management. By implementing durable state, event-driven triggers, and independent evaluation, developers can create agents capable of handling complex, multi-week business processes. The key to success lies in moving away from monolithic, self-evaluating models toward structured, persistent, and modular agent architectures.
Chat with this Video
AI-PoweredLoad the transcript when you're ready to chat so the initial page stays lighter.
Related Videos

Build a multi-agent system using ADK & MCP
Google Cloud Tech

Build a multi-agent system: A2A & Agent Registry
Google Cloud Tech

Build Systems, Not Code - Angie Jones, Agentic AI Foundation
AI Engineer

The Log Is The Agent - Ishaan Sehgal, Omnara
AI Engineer

This Is The First Real Shape Of AGI: Fusion Agents
AI Revolution

The New RAG Method that Sees the Page Instead of Reading It
The AI Automators

Building long-running AI agents with ADK
Google Cloud Tech