Designing a Layered Architecture for Long-Running AI Agents
This article examines the limitations of the basic agent loop in long-running tasks and explains when a layered architecture becomes necessary. It defines long-running task agents through persistent goals and state, proactive execution, and configurable governance, while highlighting the engineering trade-offs behind greater autonomy.
1. The Limits of the Basic Agent Loop
Most agent systems use the same basic structure: the model reads the current context, decides what to do next, calls a tool to obtain a result, writes that result back into the context, and then starts another round. This “perceive, decide, act, observe” loop works well for short tasks such as single-turn question answering, code modifications, and file retrieval. It is also relatively straightforward to implement.
As a task extends from hours to days, however, the limitations of this structure gradually become apparent:
- Context growth: Results returned by tools accumulate over time. Important information can become buried, while the model’s attention is increasingly scattered.
- State loss: If a session is interrupted, task progress, intermediate artifacts, and previous decisions can be difficult to recover.
- Error accumulation: An early misjudgment may be treated as an established premise in later steps, gradually pushing the entire task away from its original objective.
- Coarse-grained permissions: Once a tool is made available, the model may have insufficiently differentiated constraints on what it can do.
- Limited reuse of experience: Similar tasks start from scratch each time, and user preferences cannot be consistently reused.
The core problem is not simply whether the loop itself is intelligent enough. It is also that the loop lacks an operational and governance layer around it.
When to Upgrade to a Layered Architecture
The following thresholds are engineering guidelines rather than absolute rules. A task may exceed one threshold and still be suitable for a simple loop. Conversely, even when all values remain below these thresholds, a governance layer may be necessary if the actions involve significant risk.
- More than 30 steps in a single task, or progress that must continue across multiple sessions.
- A duration exceeding 30 minutes, or a requirement to resume after interruption.
- More than 10 available tools, or dependencies between tools.
- More than three consecutive errors that require rollback, or the same error recurring at different steps.
- Actions involving difficult-to-reverse operations such as deletion, sending messages, deployment, or payment.
When at least two of these conditions are met, it is generally advisable to begin planning a layered architecture.
2. Defining Long-Running Task Agents
This article uses the term long-running task agent to describe a system that can break down objectives over an extended period, continue making progress, manage its own resources, and stay aligned with the user at critical points. It is not equivalent to artificial general intelligence, nor does it claim to provide general-purpose superintelligence. In this context, “autonomy” refers to bounded engineering capabilities: the system still operates within defined constraints.
Compared with a conventional conversational assistant, a long-running task agent can be distinguished in four ways:
- Persistent goals: The task objective and subgoals are recorded explicitly rather than relying on implicit context from a single conversation turn.
- Persistent state: Intermediate results, file artifacts, and execution logs can be stored and restored.
- Proactive behavior: The system can determine what to do next based on changes in its state instead of merely waiting for instructions.
- Configurable governance: Each category of action can have its own permissions, budgets, and approval rules.
When discussing “greater autonomy,” three things must be made explicit: the scope of autonomy…
