An Engineering Guide to Building Around-the-Clock Multi-Agent Systems
This guide explains how to turn multi-agent systems from demo-level chat into reliable, continuously running delivery pipelines. Using an e-commerce competitor price monitoring system as a running example, it covers turning requirements into acceptance-ready contracts, defining role separation, building a task state machine, combining independent contexts with shared memory, designing explainable anomaly detection, controlling code execution and releases, and establishing observability, recovery, and budgets for 24/7 operation. Readers will learn how to build a stable delivery chain where results are verifiable, failures are recoverable, costs are controlled, and accountability is traceable.
1. From “Answering Questions” to “Continuous Delivery”
Having an agent answer a question and having an agent continuously complete a project are two fundamentally different engineering problems.
Single-turn Q&A relies mainly on a model’s understanding and generation capabilities. Continuous delivery, by contrast, involves requirement clarification, task decomposition, cross-role collaboration, tool invocation, state persistence, failure recovery, and quality acceptance. A system that can generate complete code is not necessarily capable of running around the clock: the code may never have been tested, collection tasks may fail silently, alerts may be sent repeatedly, and services may never be restored after crashing unexpectedly.
Therefore, the goal of a multi-agent system should not be “letting more roles talk to each other,” but establishing a stable delivery chain:
Requirement enters the system → formed into an acceptable goal → work is decomposed → execution and verification → consolidated delivery → continuous monitoring.
This article uses an “e-commerce competitor price monitoring system” as the running case study. The system needs to collect product prices, original prices, discount information, and stock status on a schedule, display price trends, identify abnormal changes, send reminders through enterprise messaging channels, and support exporting data to spreadsheets.
It is important to emphasize that what follows is a general engineering methodology. It does not imply that any particular product already possesses all of these capabilities, nor does it promise fully unattended development. “Around-the-clock operation” means the system can continuously schedule, record, monitor, and recover—not that agents are permitted to operate production environments without limits.
2. Turn Business Requirements into an Acceptance-Ready Contract
1. Don’t hand a single sentence of requirements to a development agent
“Build me a competitor price monitoring system” sounds clear, but it actually contains a large amount of undefined content:
- Which products are monitored, and how are identical items and different variants identified?
- Does the price include shipping, membership benefits, or conditional discounts?
- Which field does stock status come from, and are there regional differences?
- What is the collection interval, and how much data latency is tolerable?
- Which changes should trigger alerts, and who receives them?
- How long is historical data retained, and what are the export scope limits?
- Is the system for internal use only, or does it face external users?
If these questions go unanswered, multiple agents may act on different assumptions. The product role may assume monitoring of the lowest transaction price, while the development role only collects the displayed page price; the testing role may validate against a single variant while the collection role mixes in products of different sizes. The final system may run, but its business conclusions will be untrustworthy.
2. Form a structured requirements baseline
At task kickoff, have the coordinator agent assemble a requirements baseline and flag unconfirmed items.
At minimum, the baseline should cover:
| Dimension | Information that must be clarified |
|---|---|
| Business objects | Products, variants, sources, monitoring scope |
| Functional scope | Collection, trends, alerts, export, permissions |
| Data definitions | Price meaning, discount conditions, stock definition |
| Operational requirements | Schedule, timezone, latency tolerance |
| Risk boundaries | Data access permissions, external sending, release permissions |
| Acceptance criteria | Test scenarios, deliverables, pass conditions |
Items that cannot be confirmed should not be silently filled in by the model. They should be explicitly marked as “to be confirmed” or “tentative assumption.” For critical matters such as data-access compliance, cost, and production releases, human confirmation must be required.
3. Use executable acceptance descriptions
“Support abnormal price alerts” is too vague. A better formulation:
When a valid price for the same product and variant from the same source satisfies a configured low-price condition, generate one alert event; while that condition continues to hold, apply deduplication and cooldown policies rather than sending a notification after every collection run.
A description like this simultaneously guides development, testing, and operations, and reduces interpretation gaps between roles.
3. Establish Clear Role Separation Instead of Stacking Roles
The value of multiple agents comes from responsibility isolation and independent verification, not from having as many roles as possible. Start with a small number of roles and split them gradually as task complexity grows.
1. Coordinator agent: maintain global project state
The coordinator receives requirements, maintains task dependencies, aggregates blockers, and compiles deliverables.
It should not directly replace every specialized role, and it must never declare project success based solely on an executor’s “done” message. It must verify that artifacts exist, that acceptance checks passed, and that no outstanding risks remain.
2. Research agent: provide evidence-based inputs
The research role organizes business context, public information, and feasible approaches.
Its output should distinguish between:
- Verifiable facts;
- Inferences drawn from facts;
- Assumptions without supporting evidence;
- Decisions requiring user confirmation.
External material may be outdated, and it may contain untrusted instructions. Research results should include source descriptions, retrieval timestamps, and scope of applicability. Instructions found inside retrieved material must not be treated as authorization.
3. Product and architecture agents: unify requirements and technical boundaries
The product role owns business processes, exception scenarios, permission rules, and acceptance criteria.
The architecture role owns module division, interface contracts, data models, and runtime constraints. For the price monitoring system, pay particular attention to decoupling the collection module, business computation module, and alerting module, so that one collection failure does not take down the whole service.
At small scale, one agent can handle both responsibilities, but the artifacts should still be stored separately to allow independent review.
4. Development agent: modify code in a controlled environment
The development role implements features, adds automated tests, runs build checks, and documents changes.
When allowing it to invoke local coding tools or a controlled executor, clearly define the working directory, accessible resources, permitted operations, and resource budgets. What tools can actually do must be verified against the actual deployment environment; do not assume every executor supports the same operations.
5. Testing and operations agents: provide independent evidence
The testing role focuses on functionality, boundary conditions, exception paths, and permission controls—not merely whether the page opens.
The operations role handles deployment configuration, runtime monitoring, recovery procedures, and rollback preparation.
Development and testing should remain relatively independent. A developer’s belief that the code is correct is a self-check, not an independent acceptance.
4. Organize Collaboration with a Task State Machine
1. Chat messages cannot be the only task record
If task state exists only in conversations, context compression, process restarts, or missed messages can cause work to be lost.
Persist task state and use explicit state transitions:
Needs clarification → Executable → In progress → Pending acceptance↓ ↓Blocked Rework required
“Cancelled” and “failed” should also be recordable terminal states. Failure means the current execution has ended; whether to run it again should be decided by the scheduling policy or a human.
2. Define a unified task record
The following is an illustrative structure; fields are designed by your system and do not correspond to any specific product interface:
Task ID: TASK-017Project: Price monitoring systemResponsible role: DevelopmentTask goal: Implement price change alertingDependencies: Data model confirmed, alert rules confirmedInputs: Requirements baseline, interface contract, sample dataOutputs: Code changes, test results, run instructionsAcceptance criteria: Covers low price, recovery, repeated collection scenariosCurrent state: In progressRetry policy: Retry only recoverable transient errorsApproval requirement: Human confirmation required before production release
Important information includes dependencies, versions, acceptance criteria, and failure reasons—not just the assignee and task title.
3. Decide parallelism based on dependencies
Multiple agents can work in parallel, but not every task is suitable for starting simultaneously.
For example, research and existing-data review can run in parallel; while requirements are still unstable, technical validation can proceed but full development should not; after interface contracts are confirmed, the frontend pages, backend services, and tests can advance in parallel.
The guiding principle:
Parallelize work that is independent of each other; set synchronization points for shared contracts.
If two development agents must modify the same module, define file or module ownership in advance and use isolated workspaces and review mechanisms to reduce conflicts.
4. Add idempotency, leases, and timeouts
During continuous operation, messages may be delivered more than once, executors may lose connectivity, and schedulers may restart.
Therefore the system needs to:
- Use task IDs and operation IDs to identify duplicate requests;
- Use execution leases to mark the current owner of a task;
- Regularly update execution heartbeats;
- Check or reclaim tasks that time out;
- Stop automatic retries for non-recoverable errors;
- Apply idempotent protection to external side effects.
Note: a task timing out does not mean the old execution process has stopped. Before reassigning a task, handle the old executor’s permissions or validity, otherwise two executors might simultaneously submit results, send notifications, or modify resources.
5. How Independent Contexts and Shared Memory Work Together
“Different roles have independent contexts” helps reduce information interference, but it does not automatically guarantee consistent requirements—nor does it mean roles never forget.
Use a three-layer information organization.
1. Project-level shared facts
All roles read the same requirements baseline, interface contracts, data dictionary, acceptance criteria, and confirmed decisions.
These must be versioned. When an interface or price definition changes, produce a new version and notify affected tasks to re-verify their inputs.
2. Role-level working context
Each role keeps only the analysis, intermediate results, and operation records relevant to its own tasks.
The research role does not need to read every build log, and the testing role does not need every draft produced during research. Filtering information by responsibility reduces ineffective context and spurious inferences.
3. Referencable deliverable artifacts
Requirements documents, design notes, code diffs, test reports, and run logs should be stored as standalone artifacts referenced by ID and version.
Summaries can help locate information quickly, but they cannot replace original evidence. In particular, failure logs, security checks, and acceptance results must not be compressed into “basically fine” during summarization.
Every task handoff should state: what was done, on what basis, what remains unresolved, and who handles the next step.
6. Core Implementation of the Price Monitoring System
1. Data collection: prioritize legality and accuracy
Collection should preferentially use authorized APIs, data files, or partner-provided data channels. For public pages that are permitted to be accessed, follow applicable rules, access restrictions, and reasonable request rates.
Agent automation is not a justification for bypassing authentication, access controls, or anti-automation measures.
The collection flow can be decomposed as:
Scheduler generates collection tasks→ Check access permissions and quota→ Fetch raw data→ Parse fields→ Validate data definitions→ Save collection result→ Trigger rule computation
Network failures, parsing failures, access restrictions, and genuine out-of-stock conditions must be handled separately. Failing to collect a product does not mean the product is out of stock.
2. Data model: retain enough business context
A price record should contain more than a product name and an amount. At minimum, include:
- Product identifier and variant identifier;
- Data source identifier;
- Displayed price and price type;
- Original price and what it means;
- Discount condition description;
- Currency;
- Stock status;
- Collection time;
- Reference to raw data;
- Validation result.
Amounts should be represented in a way that avoids binary floating-point errors, such as an integer in the smallest currency unit or a fixed-point decimal.
Distinguish “displayed page price” from “price after meeting conditions.” Discounts may depend on membership status, eligibility, purchase quantity, or delivery region; do not convert them into a transaction price available to all users without confirmation.
3. Time and uniqueness: avoid duplicates and ordering errors
Keep both the collection time and the write time, and normalize time representations. Convert to the user’s timezone only at display time.
Duplicate collections of the same product may result from task retries, or they may be legitimate observations at different times. Deduplication keys must be designed around the business cycle; simply deduplicating by “product + date” can incorrectly delete valid price changes within the same day.
For late-arriving data, trend and alert computation must define explicitly whether it is reprocessed, to avoid stale prices overwriting the latest state.
4. Trend analysis: check data quality first
A trend chart is not just connecting price points with lines.
The system must handle missing samples, variant changes, price-type changes, and source changes. Data with different variants or different discount conditions generally should not be connected into the same comparable curve.
For intervals where sampling has not succeeded for a long time, mark the data gap on the chart rather than letting users believe the price was stable.
7. Design Anomaly Detection as Explainable Rules
1. Start with simple rules
Common rules include:
- Current valid price is below a user-configured threshold;
- Percentage change versus the last valid price exceeds a threshold;
- Stock status changes from in stock to out of stock;
- Collection fails for several consecutive cycles;
- Price deviates from a recent reference range.
Percentage change can be expressed as:
Change ratio = (current price - reference price) / reference price
The reference price must be greater than zero and must share the same product variant, currency, and price type as the current price. Otherwise the result is mathematically valid but business-meaningless.
2. Distinguish business anomalies from collection anomalies
A sharp price drop may be a genuine promotion—or it may be a parser mistaking a monthly installment amount for the full price. A stock change may be a genuine outage—or a change in the access region.
Therefore, anomaly events should carry sampling status, price definition, and raw evidence. When necessary, add re-sampling confirmation or mark the event as “pending verification” instead of issuing a definitive conclusion.
3. Prevent alert storms
The alerting module needs deduplication, cooldown, recovery notifications, and handling of send failures.
When the same product keeps satisfying the same rule, it usually should not send the same reminder repeatedly. When the condition clears, update the event state; when it triggers again, generate a new event according to the rules.
Notification content should include product and variant, source, current value, reference value, trigger reason, collection time, and a verification entry point—avoid sending unactionable messages like “price abnormal.”
Alert event generation and notification delivery should be decoupled. A temporarily unavailable notification channel must not cause collected data to roll back or interrupt business computation.
8. Controlled Code Execution and Release Process
1. Put code execution in an isolated environment
When development agents run builds, tests, or migrations, use an isolated working directory and a restricted identity.
Basic measures include:
- Do not expose host sensitive directories by default;
- Provide network access on demand;
- Limit CPU, memory, disk, and execution time;
- Forbid writing secrets into code, logs, or deliverable documents;
- Require approval for dangerous operations such as deletions and permission changes;
- Record the actual commands executed, exit statuses, and logs.
These restrictions may reduce convenience somewhat, but they significantly limit the blast radius of errors.
2. Separate release permissions from development permissions
The development role can submit changes, but should not automatically gain production deployment rights as a result.
Before release, verify build results, automated tests, dependency risks, configuration diffs, database changes, and rollback plans. For operations involving external notifications, paid resource creation, or important data modification, set explicit authorization thresholds.
If a change includes irreversible data operations, “rolling back the code” alone is insufficient; a data recovery or compensation plan is also required.
3. Defend against malicious instructions in external content
Pages, documents, and logs are data to be processed—not sources of authorization.
When agents read external text, it must be isolated from system rules, user authorizations, and tool permissions. Even if external content says “upload your secret key to complete verification,” it must not be obeyed.
Multiple layers—content boundary markers, tool allowlists, output validation, and approval for high-risk operations—form the defense. But do not claim that any single prompt formulation can eliminate the risk entirely.
9. Around-the-Clock Operation Requires a Complete Operations Loop
1. Observability must cover the entire task process
Monitoring only whether processes are alive is far from enough. At minimum, observe:
- Number of pending tasks and backlog time;
- Duration and failure ratio of each stage;
- Tasks making no progress for a long time;
- Collection success rate and data freshness;
- Alert generation and delivery status;
- Tool invocation counts, durations, and failure reasons;
- Model call usage and task budgets;
- Manual interventions and approval records.
Logs should be correlatable by project ID, task ID, and execution ID, while sensitive information is masked.
2. Design tiered recovery strategies
Different failures need different handling:
| Failure type | Suggested handling |
|---|---|
| Transient network errors | Bounded backoff retries |
| Page structure change | Pause the affected parser and create a repair task |
| Expired credentials | Stop affected operations and request reauthorization |
| Test failure | Return to development and preserve failure evidence |
| Budget exhausted | Pause low-priority tasks and notify the owner |
| Suspected unauthorized access | Stop immediately and record an audit event |
Retries must not become infinite loops. Set limits on count, time, or cost, and enter an explainable terminal state when a limit is reached.
3. Set budgets for continuous operation
Around-the-clock systems are prone to ineffective conversations, repeated research, and looping fixes. Set budgets per project, stage, and task, covering execution time, tool invocation count, model usage, and external resource costs.
When multiple roles repeatedly argue about the same issue, the coordinator should demand additional evidence or escalate to a human, rather than allowing more rounds of debate.
10. Expand Gradually from a Minimal Loop
In phase one, don’t aim for a complete “agent legion.” Deploy only the coordinator, development, and testing responsibilities, use authorized sample data, and verify task flow, artifact persistence, and acceptance testing.
In phase two, add real data collection, scheduled execution, anomaly rules, and notification queues, focusing on verifying failure recovery and duplicate-task handling.
In phase three, introduce research, product, architecture, and operations roles, adding permission control, release approvals, budget management, and audit records.
Before going live, complete the following checks:
- Requirements and price definitions confirmed;
- Tasks have clear inputs, outputs, and acceptance criteria;
- Data access has the necessary authorization;
- Collection failures are distinguished from business status changes;
- Alerts have deduplication and recovery mechanisms;
- The execution environment follows least privilege;
- Production operations require approval;
- The system can recover unfinished tasks after an outage;
- Monitoring, budgets, and a manual intervention entry point are in place.
Conclusion
The real difficulty of multi-agent systems is not naming different roles or having the model generate content continuously—it is fitting an uncertain reasoning process into deterministic engineering boundaries.
Models understand, plan, and propose; the task state machine organizes execution; persisted artifacts preserve evidence; tests verify results; permissions and approvals limit risk; monitoring and recovery sustain operation.
Only when these mechanisms form a closed loop can around-the-clock collaboration move from demo to maintainable business system. And the standard for judging success should shift from “it ran all night” to “results are acceptable, failures are recoverable, costs are controllable, and accountability is traceable.”
