Multi-Agent Coordination Architecture: A Practical Guide to Persistent Task Boards

    This article explains why early multi-agent systems often break down as tasks grow longer and more agents join, and how to fix the problem with a dedicated coordination layer. It walks through a minimal design built on a local embedded relational database, including the data model for a board–task–event structure, atomic task claiming with optimistic locking, heartbeat and timeout recovery, and role separation for heterogeneous agents. It also covers reliability engineering for long-running tasks, observability and cost control queries, a practical rollout path, and common anti-patterns to avoid. The approach is vendor-neutral and can run entirely on your own machine.

    1. The Problem: Why Multi-Agent Collaboration Turns into a “Slapdash Operation”

    Most early multi-agent systems relied on a “master–slave” orchestration model: a controller agent sequentially invoked several sub-agents in code and passed context through function return values. This structure is sufficient for demos, but once the task lifecycle grows longer and more roles are involved, problems surface quickly:

    • Volatile state: After a process restart or container rebuild, all task progress and intermediate artifacts are lost.
    • Tight coupling: The control logic and execution logic live in the same process, so any blocked step drags down the entire system.
    • Poor observability: Without unified state tracking, debugging means “archaeology” through logs.
    • Hard to support heterogeneity: Planning agents, execution agents, and long-running resident agents have completely different needs for context and pacing; forcing them into the same call stack is awkward.

    The root issue is that collaboration is written into code control flow instead of being modeled as first-class data that can be persisted and queried. The solution is to push “coordination” down from the code layer into a separate coordination layer—a persistent task board.

    2. Core Design: A Persistent Board as the Coordination Hub

    The minimal viable form of a coordination layer is a task board driven by a local embedded relational database. It does not aim for the complexity of an enterprise control panel; instead, it sticks to a philosophy of “local-first, user-owned, user-defined rules”: data stays on your own machine, and control is fully returned to the user.

    2.1 Why an Embedded Relational Database

    • Zero operations: No separate service process is needed; it is ready as soon as the application starts.
    • Transaction guarantees: Task state transitions require atomicity, which relational transactions naturally provide.
    • Single-file portability: The entire coordination state is one file, making backup, migration, and version control extremely simple.
    • Queryable: Standard query language is enough for backlog analysis, bottleneck identification, and auditing.

    2.2 Data Model for the Task Board

    At minimum, include the following entities to form a three-tier “board–task–event” structure:

    1. -- Board/columns (state containers)
    2. CREATE TABLE columns (
    3. id INTEGER PRIMARY KEY,
    4. name TEXT NOT NULL UNIQUE, -- backlog / ready / running / verifying / done
    5. position INTEGER NOT NULL
    6. );
    7. -- Task cards
    8. CREATE TABLE tasks (
    9. id INTEGER PRIMARY KEY,
    10. title TEXT NOT NULL,
    11. spec TEXT, -- task description and acceptance criteria
    12. status TEXT NOT NULL, -- maps to columns.name
    13. assignee TEXT, -- identifier of the agent handling the task
    14. priority INTEGER DEFAULT 0,
    15. version INTEGER DEFAULT 0, -- optimistic lock version
    16. deadline TEXT,
    17. created_at TEXT NOT NULL,
    18. updated_at TEXT NOT NULL
    19. );
    20. -- Append-only event stream (audit and observability)
    21. CREATE TABLE events (
    22. id INTEGER PRIMARY KEY AUTOINCREMENT,
    23. task_id INTEGER NOT NULL,
    24. kind TEXT NOT NULL, -- claimed / commented / blocked / released / done
    25. payload TEXT,
    26. actor TEXT,
    27. ts TEXT NOT NULL
    28. );

    Three design points are worth emphasizing:

    1. States are stored in a separate table rather than hard-coded as enum strings, making it easy to reorder columns and add custom swim lanes.
    2. The event stream is append-only and never modified; it is the single source of truth for post-mortems and observability.
    3. The version field supports optimistic locking, preventing two agents from claiming the same task simultaneously.

    3. Asynchronous Collaboration: Claiming, Heartbeats, and Release

    The value of the board is turning “invocation” into “claiming.” No agent waits for another agent’s return value; instead, each polls or subscribes to the columns it cares about.

    1. import sqlite3, json, time
    2. def claim_task(conn, agent_id, prefer_status="ready"):
    3. """Atomically claim a task and return its details; return None if none available"""
    4. conn.execute("BEGIN IMMEDIATE") # write transaction, serializes claims
    5. row = conn.execute(
    6. """SELECT id, title, spec, version FROM tasks
    7. WHERE status = ? AND assignee IS NULL
    8. ORDER BY priority DESC, id ASC LIMIT 1""",
    9. (prefer_status,)
    10. ).fetchone()
    11. if row is None:
    12. conn.commit(); return None
    13. conn.execute(
    14. """UPDATE tasks SET status='running', assignee=?, version=version+1,
    15. updated_at=datetime('now')
    16. WHERE id=? AND version=?""",
    17. (agent_id, row[0], row[3])
    18. )
    19. conn.execute(
    20. "INSERT INTO events(task_id, kind, actor, ts) VALUES(?,?,?,datetime('now'))",
    21. (row[0], "claimed", agent_id)
    22. )
    23. conn.commit()
    24. return {"id": row[0], "title": row[1], "spec": row[2]}

    Two safeguards are also needed:

    • Heartbeats and timeout recovery: Running tasks must periodically update updated_at; tasks exceeding a threshold are moved back to ready by a “watcher” with a released event recorded, preventing tasks from being occupied forever.
    • Idempotent execution: The same task may be claimed again after recovery, so the execution side must use the task id as an idempotency key; repeated execution must produce no side effects.

    4. Role Division for Heterogeneous Agents

    The coordination layer is neutral toward agent types and only defines a “board protocol.” Common role divisions are as follows:

    Role Main Responsibility Columns of Focus
    Planner Break down goals, define acceptance criteria, create task cards backlog → ready
    Executor Claim and implement, produce changes and notes ready → running → verifying
    Verifier Review against acceptance criteria, decide pass or reject verifying → done / ready
    Long-term Assistant Maintain memory and preferences, do periodic cleanup and reminders Global read-only + comments

    The key constraint is: agents do not communicate directly; they exchange information only through the board. This brings three benefits: adding a new role requires no changes to existing logic; upgrading a single role does not affect the whole system; and collaboration history is naturally recorded.

    5. Reliability Engineering for Long-Running Tasks

    For tasks with extremely long lifecycles, failure is the norm rather than an exception. Four mechanisms should be designed in advance:

    1. Idempotency and deduplication: Build an idempotency key from task id + content digest; duplicate submissions short-circuit and return immediately.
    2. Conflict control: All updates carry a version condition; on failure, re-read and retry, eliminating silent overwrites.
    3. Explicit blocking: When external dependencies are not ready, set the task to blocked and record the reason instead of letting it “fake-die” in running.
    4. Resume from checkpoints: Write intermediate artifacts to external storage (such as object storage or a local file directory); task cards store only reference paths, and context is restored from those references after a restart.

    6. Observability and Cost Control

    The board itself is the best observability panel; a few queries yield key metrics:

    1. -- Backlog count per status
    2. SELECT status, COUNT(*) FROM tasks GROUP BY status;
    3. -- Average transition time (approximate)
    4. SELECT AVG(julianday(updated_at) - julianday(created_at))
    5. FROM tasks WHERE status='done';
    6. -- Repeatedly rejected tasks (quality risk)
    7. SELECT task_id, COUNT(*) FROM events
    8. WHERE kind='released' GROUP BY task_id HAVING COUNT(*) > 2;

    For cost control, the recommendations are: add exponential backoff to polling to avoid wasting compute on idle spinning; summarize and compress long-text context before putting it on the board; externalize large artifacts and keep only metadata on the board; set priorities and quotas for high-value tasks to prevent low-value tasks from crowding out resources. If stronger retrieval is needed, vector search can be layered on top of local files and the database, but the board should remain the single source of truth.

    7. Rollout Advice and Common Anti-Patterns

    Rollout path: First define the state machine (no more than 6 states recommended), then implement claiming and event writing, then add heartbeat recovery and idempotency, and finally connect a visualization dashboard and metric alerts. If deployed on a container platform or cloud host, simply mount the database file to a persistent volume and combine it with logging and monitoring services to achieve a complete operations loop, without introducing additional control-plane components.

    Common anti-patterns:

    • Stuffing large blocks of natural-language conversation into task fields, causing the board to bloat and queries to slow down;
    • Allowing tasks to jump between columns without constraints, breaking the state machine and distorting metrics;
    • Updating or deleting the event table arbitrarily, losing auditability;
    • Letting agents modify the database directly instead of going through a unified interface, bypassing optimistic locking.

    8. Conclusion

    The stability of a multi-agent system depends on whether collaboration is modeled as persistent, queryable, recoverable first-class objects. By building a task board on a local embedded database, replacing invocation with claiming, replacing logs with an event stream, and replacing mutex waits with optimistic locking, you can evolve a “slapdash operation” demo prototype into an engineering system that runs long-term, is auditable, and can evolve. This approach does not depend on any specific vendor product, can be fully implemented on your own machine, and can easily integrate with common cloud capabilities such as object storage, message queues, container platforms, and logging and monitoring as needed.