Building a 24/7 Multi-Agent Development System: Architecture and Engineering Practices
This article explains how to build a multi-agent system that runs continuously for long tasks, using a three-layer model of orchestrator, functional directors, and executors. It covers the message protocol, four engineering practices for long-running stability (externalized state, layered context compression, idempotency, and conflict control), a full walkthrough of a competitor price monitoring dashboard, observability and cost control, and a staged rollout approach. Readers will learn how to structure roles, keep contexts isolated, and make multi-agent workflows reliable over dozens of iterations.
1. Why a Single Model Is No Longer Enough
In real development work, a complete requirement often spans market research, requirement definition, architecture design, coding, and testing. The traditional approach pushes these stages forward manually and in sequence, connecting them with meetings and documents. This leads to heavy information loss and long cycles.
Recent progress has made “multi-agent collaboration” a practical option: assign each stage to an agent with a clear boundary of responsibility, let an orchestrator role handle decomposition and scheduling, give each agent its own context, and let agents communicate through a message mechanism.
The value is not only speed, but also the controllability that comes from separation of responsibilities. When a single agent’s context grows too large, it suffers from diluted attention and forgotten instructions. Splitting the work across independent contexts keeps each agent focused on its own segment, makes the chain more stable, and makes it easier to locate which stage a problem came from.
2. Overall Architecture: A Three-Layer Model of Orchestrator, Directors, and Executors
A working multi-agent system usually has three layers.
The first layer is the orchestrator agent. It is the only entry point facing the requester, and it does three things: understand the requirement, decompose tasks, and dispatch and aggregate results. The orchestrator does not write code directly; it maintains a task board that tracks the status of each subtask.
The second layer is the functional director agents, such as a marketing director, an architecture director, a development director, and a testing director. Each director is a context container for a specific domain and turns the goals issued by the orchestrator into an executable plan for that domain.
The third layer is the executor and tool layer, including intelligent coding tools, browser-based collection capabilities, message push channels, and file and spreadsheet export capabilities. The development director can autonomously call a local intelligent coding tool to enable continuous coding.
The three layers communicate through a message bus. A message contains at least the following fields:
{"task_id": "T-20260115-001","from": "orchestrator","to": "dev_director","role": "assign","goal": "Implement the collection scheduling module","constraints": ["concurrency no more than 5", "retry 3 times on failure"],"context_ref": "ctx://task/T-001/design","deadline": "2026-01-15T22:00:00Z"}
context_ref is a key design choice: context is not passed in full inside the message but shared by reference. This avoids bloating the message body and keeps each agent’s private context from being polluted.
3. Four Engineering Practices for Long-Running Stability
The real difficulty of a multi-agent system is not “can it run through once,” but “can it run through dozens of rounds without breaking.” The following four points must be handled in practice.
1. Externalize state. Task state must not live only in the conversation history; it must be written to external storage (such as structured files in object storage or database records). After any agent restarts, it can resume from the state file without replaying the entire history.
2. Compress context with layered summaries. Give each agent a three-tier memory of “recent verbatim text + mid-term summary + long-term index.” The recent tier keeps the last several rounds verbatim, the mid-term tier compresses with a rolling summary, and the long-term tier keeps only conclusions and file references.
def build_prompt(agent, task):recent = agent.memory.recent(n=8)summary = agent.memory.rolling_summary()refs = agent.memory.conclusion_index()return f"[Goal]{task.goal}\n[Summary]{summary}\n[Recent]{recent}\n[Index]{refs}"
3. Make tasks idempotent and resumable. Define a clear completion criterion and output path for each subtask. When rescheduling, first check whether the output exists and passes validation; if it does, skip it. This avoids repeated rework during unattended overnight runs.
4. Handle conflicts and rate limits. When multiple agents write to the same file at the same time, contention occurs, so introduce a lease mechanism or divide write permissions by directory. For external collection tasks, set a concurrency limit and backoff retries to avoid being denied service by the target site.
4. Full Walkthrough: A Competitor Price Monitoring Dashboard
Suppose the requester posts a requirement in a collaboration tool: build a competitor price monitoring dashboard that supports entering competitor links, periodically collects price, original price, discount, and stock status, provides trend charts and anomaly markers, sends alerts through the collaboration tool on low prices, sharp fluctuations, or out-of-stock conditions, and supports spreadsheet export.
Market research stage. The marketing director breaks down the dimensions to investigate: the page structure types of the target sites, whether login is required, access frequency limits, field naming conventions, and common anti-scraping strategies. The output is a research conclusion document and a feasibility rating, written into the shared context.
Requirement definition stage. Based on the research conclusions, the orchestrator generates a structured requirement specification and defines the data model:
Product(id, name, url, category)PriceSnapshot(id, product_id, price, origin_price,discount, stock_status, captured_at)AlertRule(id, product_id, metric, threshold, window)
Architecture design stage. The architecture director produces a layered design: the collection layer handles fetching and parsing, the scheduling layer handles timing and concurrency control, the storage layer persists snapshots, the computation layer handles trend aggregation and fluctuation detection, the notification layer handles alert distribution, and the export layer generates spreadsheet files. The design document must include failure paths, such as a parsing fallback strategy when the page structure changes.
Development stage. The development director splits the design into several independently verifiable commits, autonomously calls an intelligent coding tool to keep coding, and attaches unit tests to each commit. Fluctuation detection can use a simple, reliable rule: flag an anomaly when the relative deviation from the historical average exceeds a threshold, or when the range within a unit time window exceeds a threshold.
def detect_anomaly(history, current, rel=0.15, abs_range=0.2):if not history:return Falseprices = [h.price for h in history]avg = sum(prices) / len(prices)if avg and abs(current - avg) / avg >= rel:return Truereturn (max(prices + [current]) - min(prices + [current])) / avg >= abs_range
Testing and delivery stage. The testing director prepares samples of page structure changes for the parser, verifies that repeated triggers do not write duplicate records for the scheduler, verifies deduplication and silence windows for alerts, and verifies memory usage under large volumes for export. After everything passes, the orchestrator aggregates the delivery notes.
5. Observability and Cost Control
Unattended operation must be paired with observability. It is recommended to record at least three kinds of data: the duration and status of each subtask, the input and output size of each model call, and the success rate of each tool call. Logs are collected centrally into a logging service, metrics are connected to monitoring and alerting, and when consecutive failures occur, the responsible person is notified automatically.
For cost control, use cheaper models for summarization and formatting, and reserve more capable models for architecture decisions and difficult debugging. For collection tasks, make an incremental check: if the page has not changed, do not enter the downstream computation chain.
6. Rollout Recommendations
Do not build all roles at the start. The recommended path is: first build a minimal loop with the orchestrator and two directors, and run through one real requirement; then gradually add testing and observability; and only then introduce multi-agent parallelism and autonomous coding. The more roles there are, the more debugging cost rises nonlinearly. Get the message protocol, externalized state, and idempotency solid first, and later expansion will go much more smoothly.
