Always-On Routing and Background Execution: A Minimal Multi-Agent Architecture in Practice

    This article explains how to build a minimal always-on multi-agent architecture for software engineering tasks that need to run continuously rather than in a single question-and-answer session. It covers why routing and execution roles must be separated, the five generic capabilities that form a working loop, key design points for the always-on router, context isolation for execution agents, event triggers and watchdog checks, deliberate gaps and an evolution roadmap, and security and cost constraints. Readers will get a practical blueprint using common, non-proprietary components.

    1. Background: From One-Shot Q&A to Continuous Operation

    Most AI coding tools still work in a conversational mode: the user issues one instruction, the tool performs one task, returns the result, and the session ends. This works well for isolated questions, but it quickly shows three weaknesses on engineering work that needs to progress over a long period.

    First, blocking. Long-running code searches, builds, and test runs occupy the interaction channel, so the user cannot submit new tasks and has to wait.

    Second, context pollution. When multiple tasks share the same session context, their intermediate outputs, error logs, and tentative conclusions interfere with each other and push later reasoning off target.

    Third, no one drives progress. Once the session ends, nothing is responsible for looking back, so acceptance, regression, and wrap-up of long-running work depend on the user’s memory.

    An always-on multi-agent architecture addresses these three points: it splits “communication and dispatch” from “actual execution” into two role types, uses one always-on routing role to receive tasks, runs multiple execution roles in parallel in independent contexts, and closes the loop with event triggers and external checks. This article does not try to reproduce every mechanism of a complete solution. Instead, it builds a runnable minimal skeleton from the most common engineering components and explains which capabilities are intentionally left out and how to fill them in later.

    2. Role Separation: Why Routing and Execution Must Be Distinct

    The first principle of an always-on architecture is separation of responsibilities. The routing role understands intent, breaks down tasks, selects executors, and aggregates results. Execution roles do the concrete work in controlled environments.

    The benefits of separation are structural, not performance tuning:

    • The interaction channel stays available. The routing process does not run long tasks itself, so it can always respond to new requests.
    • Contexts are naturally isolated. Each execution role has its own session, and tasks do not share intermediate state.
    • The failure radius is contained. If one execution role crashes or times out, the router and other tasks are unaffected.
    • Observability improves. Role boundaries are also log boundaries, which makes it easier to attribute problems.

    It is worth stressing that keeping the router from doing work itself is not a concession to limited capability but an architectural constraint. Once the router starts doing concrete modification work, it degrades from a dispatcher into a single point of congestion, and all four benefits above fail at once.

    3. The Minimal Architecture: Five Generic Capabilities That Form a Loop

    A practical minimal implementation needs only five types of generic capabilities, all replaceable with common industry options and none dependent on proprietary interfaces.

    1. An always-on routing process. It runs in a persistent terminal session, receives external messages, maintains a task list, and dispatches tasks.
    2. Persistent terminal sessions. These provide a long-lived runtime for the router, the message gateway, and each execution role, which can be attached to and inspected at any time and does not terminate when a connection drops.
    3. A remote message entry point. Tasks are submitted through a chat bot, and results are pushed back to the same entry point, giving an asynchronous rather than synchronous experience.
    4. Scheduled triggering. Periodic jobs generate “check” events that drive the router to review the status of long-running tasks.
    5. An isolated runtime environment. The whole system runs in a separate virtual machine whose working directory points to a shared directory on the host, which both makes existing project files accessible and provides a minimal form of compute-storage separation.

    The combination works like this: the first two provide “always-on,” the third provides “remote and asynchronous,” the fourth provides “self-driving,” and the fifth provides “isolation with file sharing.”

    A schematic dispatch flow can be abstracted as:

    1. Message received
    2. -> Normalize the task description and write a task record (status = pending)
    3. -> Select an execution role type
    4. -> Start the execution process in an independent terminal session, passing the working directory and task description
    5. -> Return "accepted" immediately, without waiting for the result
    6. Execution process finishes
    7. -> Append the execution log and artifact paths
    8. -> Push back a result summary
    9. Scheduled check
    10. -> Scan for timed-out or stalled tasks
    11. -> Generate reminder events and hand them back to the router

    4. Key Design Points for the Always-On Router

    The router is the control entry point of the system, and its design quality determines whether the system is stable.

    Minimize context. The router’s system prompt should contain only dispatch rules, the role list, the task record format, and the push-back convention, with no concrete code details. The leaner the context, the more stable the router’s decisions and the more controllable the token consumption.

    Keep task records external. Task state should not live only in the router’s reasoning context but should be persisted as structured files or a lightweight data table, containing at least the task ID, creation time, execution role, working directory, status, artifact paths, and last update time. This way the router can restore a global view from files even after a restart.

    Idempotency and deduplication. A remote entry point may deliver the same message more than once, so the router needs to deduplicate based on a task fingerprint to avoid running the same task concurrently and causing file conflicts.

    Return on acceptance. The router’s semantics are “accepted,” not “completed,” so the first message back to the user should be the task ID and the expected way work will progress, not the final result.

    5. Execution Roles and Context Isolation

    Execution roles are handled by general-purpose AI coding tools running in their own independent terminal sessions. Isolation depends not only on separate processes but also on workspace and branch strategy:

    • Each task uses its own working directory or its own version control branch to avoid concurrent writes overwriting each other.
    • An execution role receives only the information required for its task and does not inherit the history of other tasks.
    • Artifacts are delivered as files, their paths are written into the task record, and the router aggregates them rather than passing them verbally in a session.

    This “files are the interface” convention greatly reduces coupling between components: replacing an execution tool or adding a new execution type does not require changing the router’s core logic, only following the same task record and artifact conventions.

    6. Event Triggers and a Watchdog: Making the System Move Itself Forward

    Continuous operation essentially means something periodically wakes the system up. The minimal implementation uses scheduled jobs to generate check events; driven by these events, the router scans task records and identifies three kinds of anomalies: no progress after the expected duration, an execution process that has exited while its status was not updated, and missing artifacts or failed validation.

    Handling should be tiered: retry once first, then downgrade to a reminder for human intervention, while keeping complete logs. The value of a watchdog is not fixing everything automatically but turning “silent failures” into “visible events.”

    7. Deliberate Gaps and the Evolution Roadmap

    The current skeleton clearly lacks four capabilities that need to be filled in gradually through real use:

    • A task registry: upgrade from a file list to a registry with indexing and query capabilities, supporting lookup by status and tags.
    • A session correlation mechanism: assign a traceable thread ID to each task, linking messages, execution logs, and artifacts into one chain.
    • Fine-grained event routing: evolve from “periodic full scans” to “dispatching by event type to different handling logic.”
    • Independent state management: separate state transitions from the router prompt and let a dedicated component maintain them to guarantee consistency.

    The suggested order is: first add state management and the registry for reliability, then add session correlation for traceability, and finally optimize event routing to reduce overhead.

    8. Security and Cost Constraints

    An always-on system must have preset boundaries. Execution roles should run in isolated environments with only the necessary working directory permissions; the remote entry point needs identity verification and operation auditing; the frequency of scheduled checks and the number of concurrent execution roles should have upper limits to avoid runaway resource and cost usage; and all task records and logs should be archivable for later review. If stronger elasticity and observability are needed, common cloud capabilities such as container platforms, logging services, and monitoring and alerting can carry the system without changing the architecture itself.

    9. Conclusion

    The core of an always-on multi-agent architecture is not mysterious: one lightweight always-on role takes in all requests, multiple isolated roles execute in parallel, files carry state, and scheduled events drive self-checks. Fewer components and clearer boundaries make the system easier to understand and modify. Getting the loop running first, then filling in capabilities in the order of reliability, traceability, and dispatch precision, is the most reliable path to production for this kind of system.