Multi-Agent Orchestration Architecture: A Practical Guide to Persistent State and Reliable Scheduling
This guide explains why multi-agent systems often fail in practice and presents a practical architecture built around a persistent task board as the single source of truth. It covers a three-layer design, atomic task claiming with leases, execution-layer isolation, artifact contracts, and the reliability and observability capabilities needed for production use. Readers will learn how to prevent orchestrator overreach, recover long-running tasks after interruptions, and eliminate direct calls between agents.
1. Why Multi-Agent Systems Turn Into a Mess
AI coding tools and multi-agent workspaces have become a common setup for engineering teams over the past couple of years. Teams usually split agents by role: one handles research and solution design, one handles implementation, and one handles testing and regression. In theory, the role boundaries are clear and the pipeline flows automatically. In practice, three types of failures show up repeatedly.
The first is orchestrator overreach. The control node is supposed to act as a dispatcher that only splits and assigns tasks, but in real runs it starts implementing details itself. Execution roles end up idle, outputs are duplicated, and code styles conflict. The root cause is usually not a lack of model capability, but the absence of hard constraints on role boundaries.
The second is fragility in long-running tasks. For tasks that span hours or even days, once the main process exits or the session is interrupted, already-started subtasks terminate silently. There is no state record and no recovery entry point, so the only option is to rerun everything.
The third is state drift. Multiple agents each maintain their own context and develop inconsistent understandings of the same task’s progress, conclusions, and artifact paths. Handoffs rely on “verbal passing,” and information decays segment by segment along the chain.
To address these problems at the root, collaboration between agents must move from in-process calls to externally persisted shared state. The approach below provides a practical architectural pattern.
2. Core Design: A Persistent Board as the Single Source of Truth
The core idea is that agents never communicate directly with each other. All handoffs happen by reading and writing a single persistent task board. The board is typically backed by a local embedded database with write-ahead logging enabled to improve concurrent read and write performance, along with a lightweight periodic scheduler that advances tasks.
The system is divided into three layers:
- Control layer: Facing users, it accepts instructions, progress queries, and additional tasks through terminal commands or a chat gateway.
- State layer: The single source of truth for the system, containing only the board data file and the periodic scheduler. The scheduler’s responsibilities are deliberately limited to three things: recomputing task status, atomically claiming task locks, and launching worker processes.
- Execution layer: Composed of mutually isolated worker profile processes. Each role has its own working directory. For example, the research role searches for material in a draft area, while the coding role modifies files in a separate code worktree.
A sample board table structure is shown below (it only expresses field semantics and is not a specific product interface):
CREATE TABLE task (id INTEGER PRIMARY KEY,title TEXT NOT NULL,role TEXT NOT NULL, -- target rolestatus TEXT NOT NULL, -- queued/claimed/running/done/faileddeps TEXT, -- list of prerequisite task IDslease_until INTEGER, -- lease expiration timestampattempts INTEGER DEFAULT 0,artifact TEXT -- artifact path or summary pointer);
The key constraint is that there is no direct call channel between agents. Handoffs can only happen by “writing an artifact + updating task status,” which eliminates the possibility of overreach and cross-talk at the architectural level.
3. Scheduling: Atomic Claiming, Leases, and Status Recomputation
The scheduler runs on a fixed interval and keeps its logic “dumb” and repeatable:
- Scan for tasks whose dependencies are satisfied and whose status is queued.
- Atomically claim them with a single conditional update statement. For example, set the status to claimed and write the lease expiration only if the status is still queued.
- Launch the isolated process for the corresponding role, passing the task identifier through an environment variable or startup argument.
- After the process ends, do not modify global state. The next scheduling round recomputes everything.
The conditional update is the basis of concurrency correctness, as illustrated below:
UPDATE task SET status='claimed', lease_until = strftime('%s','now') + 600WHERE id = ? AND status = 'queued';
If the number of affected rows is 0, the task has already been claimed by someone else, and this round skips it. The lease mechanism solves the problem of “a task getting stuck forever after a process crashes”: tasks that remain incomplete past the lease expiration are reverted to queued by the scheduler and have their attempt count incremented. If the count exceeds a threshold, the task is marked as failed and waits for manual intervention.
Status recomputation must be idempotent: no matter how many times the scheduler runs, the result is the same. The approach is to fully re-derive status from the task table and whether artifacts exist on each run, rather than maintaining it incrementally in memory.
4. Execution-Layer Isolation: Workspaces, Permissions, and Artifact Contracts
Isolation is the prerequisite for stable long-running tasks and can be implemented along three dimensions:
- File isolation: Each role is bound to a separate directory or a separate code worktree, avoiding conflicts from concurrent writes to the same file.
- Permission isolation: The research role is granted only read-only search and draft-write permissions; only the coding role is granted write access to the code repository; the testing role only reads artifacts and writes back conclusions.
- Artifact contracts: Task handoffs use explicit artifacts as the carrier. For example, a research task must output a structured conclusion file, and a coding task must output a change description and verification records. Downstream tasks depend only on the contract, not on the upstream’s contextual memory.
A minimal execution skeleton can be described as:
task_id = os.environ["TASK_ID"]workdir = os.environ["WORKDIR"] # isolated directory assigned by the schedulertask = load_task(task_id) # read the boardresult = run_role(task.role, task.input, workdir)write_artifact(task_id, result) # write only the artifact, do not change global state
This combination of “stateless execution + external state” ensures that any process being interrupted will not pollute the overall system state.
5. Reliability and Observability
To make the approach trustworthy in production, four capabilities need to be added:
- Recovery: After a process restarts, the scheduler automatically continues unfinished tasks based on the board, with no manual replay required.
- Observability: Record the time, role, attempt count, and failure reason for each state transition to form a traceable timeline. Logs and metrics can be integrated with general-purpose logging services and monitoring and alerting capabilities.
- Concurrency safety: Enable write-ahead logging in the database and set a reasonable busy-wait to avoid lock contention when multiple scheduler instances compete.
- Cost control: Set lease limits and retry limits for long-running tasks to prevent infinite loops from consuming compute. When necessary, place large artifacts in object storage and keep only pointers in the board.
If elastic scaling is needed, the state-layer files can be hosted on shared storage and the execution layer can run on a container platform, enabling independent scaling by role while keeping the “single source of truth” unchanged.
6. Implementation Recommendations
When practicing in environments such as Baidu AI Cloud, follow a local-first principle: keep state and execution on your own machines, and only use general-purpose capabilities to supplement when needed, such as object storage for artifacts, a message queue for event notifications, a container platform for isolated execution, and logging and monitoring services for observability.
The recommended implementation order is: first solidify the task table structure and state machine, then implement atomic claiming and leases, then add artifact contracts and isolated directories, and finally integrate observability and alerting. The criteria for judging whether the architecture succeeds are simple: the control node no longer writes business code, tasks can automatically resume after the main process exits, and there is no direct call between any two agents.
