Persistent Router and Background Execution: A Minimal Super Agent Architecture in Practice

    This article explains how to design a Super Agent as a long-running software system rather than a single request-response call. It covers the core principle of separating scheduling from execution, the four basic actions of a minimal implementation (persistent router, task dispatch, asynchronous execution, and periodic inspection), and a closed-loop architecture built from six replaceable components. It also details context isolation for workers, event triggering with a watchdog, file-based state tracking for observability, and a staged roadmap for future evolution. Readers will get a practical, component-minimal path to a reliable agent system without confusing a minimal build with production completeness.

    1. Background: From “One Question, One Answer” to Continuous Hosting

    Over the past two years, the form of AI agents has been shifting noticeably. Most early implementations followed a request-response model: a user issues one instruction, the model performs a single round of reasoning and tool calls, returns a result, and the session ends. This works well for short tasks such as single-turn Q&A or single-file edits, but bottlenecks appear quickly once a task has the following characteristics:

    • It runs for a long time, such as cross-file refactoring, dependency installation, or batch test fixing.
    • It is triggered by external events rather than manual input line by line.
    • Multiple tasks must progress concurrently without polluting each other’s context.
    • It must run unattended for long periods, and failures must be detectable and recoverable.

    The concept of a “Super Agent” was proposed precisely for these characteristics. Its core judgment is that the difficulty of agents has spilled over from “model capability” to “system capability.” What truly determines usability is scheduling, isolation, state management, and observability—traditional distributed systems problems. So instead of continuing to pile on a single prompt, it is better to design the agent as a long-running software system.

    This article does not aim to replicate every mechanism of a complete solution. Instead, it lays out an implementation path with as few components as possible while keeping the main loop complete, and clearly marks which capabilities are later evolution items, so readers do not mistake a minimal implementation for production completeness.

    2. Core Design Principle: Separation of Duties and Four Basic Actions

    The first principle of a Super Agent architecture is separation of duties: separating “communication and scheduling” from “execution.” The role that handles scheduling is called the Router, and the role that handles execution is called the Worker. Separating the two yields three direct benefits:

    1. The Router stays lightweight with stable interaction latency, and will not “freeze” because of a single long-running tool call.
    2. Each Worker has an independent context, so tasks do not bleed into each other.
    3. Workers can be restarted, rate-limited, or have their implementation swapped independently, without the Router needing to know the details.

    Under this principle, a minimal implementation only needs to deliver four basic actions:

    • Persistent router: a long-lived process that receives all entry requests in one place.
    • Task dispatch: delivering tasks to independent background sessions instead of running them synchronously in the current session.
    • Asynchronous execution: the Router returns immediately after dispatch, staying interactive.
    • Periodic inspection: using recurring events to drive state checks and timeout reminders.

    To be honest, a minimal implementation usually does not include a complete task registry, session-to-task association tracking, fine-grained event routing, or independent task state storage. These are evolution directions, not current requirements.

    3. Overall Architecture: A Closed Loop from Six Generic Components

    A runnable minimal architecture can be assembled from six categories of generic capabilities, all chosen from common, replaceable engineering components in the industry, without binding to any specific product:

    Capability Role Responsibility Replaceable Options (Generic Description)
    Persistent Router Receive instructions, understand intent, dispatch tasks Any long-session AI coding tool
    Persistent Session Layer Host the Router, entry gateway, and multiple Workers Terminal multiplexer tools
    Remote Entry Task submission and result return Instant messaging bot interface
    Worker Perform concrete coding and verification work AI coding command-line tool
    Scheduled Trigger Periodic inspection and reminders System cron jobs
    Runtime Environment Isolated execution, file sharing Virtual machine + host shared directory

    The data flow can be summarized as one unidirectional main path plus one supervision path:

    1. User / Event Source
    2. │ (message)
    3. ▼
    4. [Remote Entry Gateway] ──► [Persistent Router]
    5. │ dispatch (background)
    6. ▼
    7. [Worker #1..#N]
    8. │ read/write
    9. ▼
    10. [Shared Workspace / Files]
    11. ▲
    12. [Periodic Inspection] ──check status──┘ [Watchdog: timeout/exception alerts]

    The most important design here is a minimal form of “separating compute from state”: the execution environment runs in a virtual machine to guarantee isolation and reproducibility, while the workspace points to a host shared directory, so existing project files can be accessed directly, and state is not scattered inside containers where a rebuild would lose it.

    4. Persistent Router: Keeping the Control Plane from Ever Blocking

    The Router is the control plane of the whole system and must live long-term in a persistent session. Its input comes from the remote entry, and its output is a “dispatch action” rather than an “execution result.” To keep the Router stable in its scheduling duty, three things must be constrained in engineering.

    First, define boundaries clearly at the prompt level. The system prompt should state that the Router’s job is to understand, decompose, dispatch, and summarize, not to personally make large code changes. A sample:

    1. You are a dispatch router. Your responsibilities:
    2. 1. Determine task type and priority;
    3. 2. Assign an independent execution session and name for the task;
    4. 3. Dispatch the task and return a task identifier;
    5. 4. Summarize results returned by workers; do not rewrite code yourself.
    6. Prohibited: running any tool call longer than 30 seconds in the current session.

    Second, the entry adapter must be “thin.” The remote entry is only responsible for normalizing external messages into a unified task structure, for example:

    1. {
    2. "task_id": "t-20260812-001",
    3. "title": "Fix login timeout issue",
    4. "workspace": "/shared/repo-a",
    5. "priority": "normal",
    6. "created_at": "2026-08-12T09:00:00Z"
    7. }

    Third, acknowledgments must be immediate. After a successful dispatch, the Router immediately returns the task identifier and the expected feedback channel, so the user knows the task is “accepted” rather than waiting for the final result.

    5. Workers and Context Isolation: The Right Way to Handle Concurrency

    Workers run in their own independent persistent sessions, with an AI coding command-line tool doing the actual coding, building, and testing. The key to isolation is not “different processes” but “context and workspace do not cross.” In practice, it is recommended to:

    • One task, one session: include the task identifier in the session name for easy manual intervention and log lookup.
    • Reusable workspace with branch isolation: a shared directory improves file access efficiency, while code changes are separated by version control branches.
    • Structured output: require workers to return conclusions in a fixed format, such as “list of changed files / verification commands and results / remaining risks.”
    • Rerunnable on failure: after a worker is terminated or times out, the Router simply redispatches, without relying on in-memory state.

    Sample dispatch logic (pseudocode):

    1. def dispatch(task):
    2. session = f"worker-{task.task_id}"
    3. open_session(session, cwd=task.workspace)
    4. send(session, build_prompt(task)) # do not wait after sending
    5. register(task.task_id, session, status="running")
    6. return {"accepted": True, "task_id": task.task_id}

    This “dispatch and return” pattern is the fundamental reason the Router stays lightweight, and the source of concurrency capability.

    6. Async, Event Triggering, and Watchdog: Letting Long Tasks Move Forward on Their Own

    Async alone is not enough; long tasks need external supervision. A minimal implementation covers this with two mechanisms:

    • Periodic inspection: periodically wake the Router to check the status of each Worker, and issue reminders or redispatch for tasks with no output for a long time.
    • Watchdog: use timeout thresholds, missing heartbeats, and error log keywords as trigger conditions to produce alerts with the task identifier attached, making them easy to locate.

    It is recommended to unify event sources into three categories: manual messages, scheduled events, and worker return events. All three enter the same entry point and are classified by the Router, avoiding multiple parallel logic paths. The decision policy should stay simple and explainable, for example:

    1. If running and time since last output > 15 minutes → remind
    2. If running and time since last output > 40 minutes → terminate and redispatch once
    3. If 2 consecutive failures → escalate alert, hand over to a human

    7. State Tracking and Observability: Pinning Down the System with Files

    A minimal implementation does not introduce an independent state service. Instead, it writes plans, logs, and task records to files, forming an auditable source of truth. Three types of files are recommended:

    • Task ledger: one task per line, recording status, session name, and timestamps.
    • Execution logs: split into files per task, making it easy to trace tool calls and errors.
    • Plan and decision records: recording decomposition thinking and trade-offs for easy handover.

    For observability, at minimum ensure “three things are queryable”: tasks are queryable (ledger), process is queryable (logs), and environment is queryable (session list and workspace paths). This step looks plain, but it is a prerequisite for later integration of monitoring alerts and metrics.

    8. Capability Boundaries and Evolution Roadmap

    The currently missing capabilities must be stated clearly to avoid misjudging maturity: no unified task registry and priority queue, no structured association between sessions and tasks, no fine-grained event routing, and no independent task state storage and recovery semantics.

    Evolution can be split into three stages: the first stage adds the ledger and structured events; the second introduces independent state storage and a queue to enable priority, retry, and idempotency; the third integrates containerized execution, resource quotas, log services, and monitoring alerts to form a horizontally scalable execution pool. If running in the cloud, you can correspondingly use a container platform to host Workers, object storage to save artifacts, a message queue for task distribution, and logging and monitoring services for observability, thereby improving elasticity and reliability without changing the main architecture.

    9. Conclusion

    The essence of a Super Agent is turning an agent from “a single call” into “a long-running distributed system.” The value of a minimal implementation is not full features, but validating the main loop with six generic components: a persistent router ensures stable interaction, background execution brings concurrency, periodic inspection and a watchdog keep long tasks controllable, and file-based tracking ensures auditability. Doing these four things solidly first, then gradually filling in the registry, state management, and observability system, is the lowest-risk and most certain path to landing.