A Minimalist Architecture for Persistent AI Agents: From Single Responses to Always-On Execution
This article presents a minimalist, product-agnostic approach to building persistent AI agents that run continuously instead of answering one prompt at a time. It breaks the design into six general engineering capabilities: a resident router, persistent terminal sessions, a remote messaging entry point, a coding execution unit, a scheduled trigger, and a VM with a shared working directory. The core constraint is simple: the coordinator does not do the work, and the executor does not make decisions. The article also covers context isolation per task, asynchronous dispatch, file-based state as a lightweight database, and the known limitations of the design, followed by a four-step evolution path for teams moving toward production workloads.
1. Background: From Single Responses to Continuous Operation
Most agent interactions today still follow a simple pattern: the user sends one instruction, and the model returns one result. This pattern has several problems. The agent holds no resident state, so task context is never accumulated. Long-running operations block the interaction. Multiple tasks can easily pollute each other’s context. And once the process exits, the work stops.
The goal of a persistent agent is to separate interaction, scheduling, and execution: a resident entry point continuously accepts tasks, independent execution units push concrete work forward in parallel, and an external mechanism acts as a fallback when something goes wrong. This article discusses an implementation approach with as few components as possible. It does not attempt to replicate a complete mechanism; it only gets the most critical collaboration path working.
2. Overall Architecture: Six General Capability Slots
The design relies on only six categories of general engineering capabilities and is not bound to any specific product:
- Resident router: a long-running coordination process that receives requests, interprets intent, and dispatches tasks.
- Persistent terminal sessions: long-lived runtime environments for the router, the messaging gateway, and each execution unit, so state survives disconnects.
- Remote messaging entry point: tasks are submitted from a chat bot, and results are returned through the same entry point, so work can move forward even when the user is away.
- Coding execution unit: a command-line coding agent handles the actual code changes and verification.
- Scheduled trigger mechanism: a periodic wake-up checks the status of long-running tasks, forming a supervision loop.
- Virtual machine and shared working directory: the system runs in an isolated environment, while the workspace points to a shared directory on the host, a minimalist form of separating storage from compute.
The core constraint of the architecture fits in one sentence: the coordinator does not do the work, and the executor does not make decisions.
3. Resident Router: A Lightweight Control Plane
The router is the single entry point of the whole system and runs inside a persistent terminal session. It constrains its own behavior boundaries through a system prompt, uses a message mirroring extension to convert external messages into internal task descriptions, and then starts the corresponding execution unit.
There are three design points:
- Single entry point. All tasks enter from one place, avoiding the state fragmentation and permission confusion caused by multiple entry points.
- Minimal context. The router keeps only the task list and scheduling information and does not load concrete code details.
- Separation of decisions and execution. The router decides “what to do and who to hand it to,” while the execution unit handles “how to do it.”
The scheduling logic can be abstracted schematically as:
on_message(msg):task = parse(msg) # normalize into a structured taskif task.type == "coding":session = ensure_session(task.id) # isolated session per tasksend(session, task.prompt) # background dispatch, non-blockingrecord(task) # persist plan/logs/statusreturn ack(msg)
The key point is that the dispatch action is asynchronous: the router returns to an interactive state immediately after issuing the instruction, while the long-running tool calls happen inside the execution unit.
4. Execution Units and Context Isolation
Each concrete development task is dispatched to an independent terminal session, where a coding tool reads code, modifies code, runs tests, and performs other actions. This brings three direct benefits:
- Interaction is not blocked. A build or test run that may last several minutes does not make the entry point unresponsive.
- Context does not bleed. Different tasks hold separate histories, so constraints from task A do not pollute the judgment of task B.
- Better observability. The output of each session can be captured, archived, and replayed individually.
In practice, it is recommended to establish a three-way binding of “task ID - session ID - working directory” for each task and to reclaim the session uniformly when the task ends, preventing resource leaks.
5. Asynchrony, Events, and Scheduled Patrols
Continuous operation depends on more than the ability to accept tasks; the system must still be working while tasks are in progress.
- Event triggers: external messages, execution unit completion notifications, and error output can all serve as trigger sources.
- Asynchronous execution: time-consuming operations are placed in background sessions so the entry point stays responsive.
- Scheduled patrols: a periodic scheduler wakes the router to check, one by one, whether long-running tasks are stuck and whether they need a reminder or termination.
The patrol logic can be simplified as:
every N minutes:for t in running_tasks:if no_output(t) > threshold:notify(t, "suspected stall")if t.deadline_exceeded:terminate(t); notify(t, "terminated after timeout")
This deliberately avoids fine-grained event routing and keeps only the two most necessary fallback rules, stall detection and timeout termination, in exchange for a substantial reduction in implementation complexity.
6. State and Persistence: Files as the Database
The minimalist approach introduces no separate state service. Instead, plans, logs, and task records are all stored as files, organized in directories by task ID. The benefits are zero dependencies, easy troubleshooting, and direct compatibility with version control; the cost is the lack of concurrent write protection and complex query capabilities. As the task volume grows, these can gradually be replaced with general-purpose capabilities, for example object storage for artifacts, a message queue for events, a logging service for retrieval, and monitoring and alerting for anomaly notifications.
7. Known Boundaries and Evolution Path
It must be clear what this design does not do: there is no complete task registry, no association model between sessions and tasks, no fine-grained event routing, and no independent task state machine. It is therefore suitable for individuals and small teams validating the feasibility of persistent agents, and not suitable for directly carrying high-concurrency production traffic.
The suggested evolution path has four steps: first add a task registry and state machine, then add event routing and a priority queue, then introduce centralized logging and alerting, and finally containerize the execution units and connect elastic scaling. If the whole deployment is on the cloud, a smooth upgrade can rely on general capabilities such as container platforms, object storage, and logging, monitoring, and alerting.
8. Summary
The essence of a persistent agent is packaging “model capability” into a “continuously running service”: the resident router keeps the entry point from being lost, independent execution units keep contexts from mixing, asynchronous mechanisms keep interactions from blocking, scheduled patrols provide a fallback for anomalies, and file-based state keeps the implementation light enough. Getting the loop working with the fewest components first, then replacing them step by step as bottlenecks appear, is the most reliable way to put this kind of system into practice.
