Multi-Agent Collaboration in Practice: Building a 24/7 Automated Development System
This article explains how to move from one-off code generation to a controlled software delivery system powered by multiple agents. It covers the overall architecture, agent role design, context isolation, task state management, a practical e-commerce competitor price monitoring case, closed-loop AI coding, fault recovery, security boundaries, and a recommended rollout sequence with acceptance criteria.
1. From “Automatic Code Writing” to “Controlled Software Delivery”
Generating a piece of code with a model is different from having multiple agents continuously carry out software development.
The former mainly tests the model’s ability to understand requirements and generate code. The latter must also address task decomposition, dependency management, information transfer, execution permissions, result verification, and failure recovery. Only when these steps form a closed loop can an automated system move from a one-time demonstration to continuous operation.
This article uses an e-commerce competitor price monitoring system as an example. A user submits a request through an enterprise messaging entry. The system then completes requirement analysis, product design, technical design, development, testing, and delivery. After launch, the business system periodically collects product prices and inventory information, displays trends, and sends alerts when conditions are met.
Two types of “24/7” should be distinguished here:
- The development workflow remains on standby: it can receive tasks at any time and advance development within the limits of permissions and resources.
- The business service runs continuously: it performs collection, calculation, display, and alerting according to a schedule.
Neither means that the model must perform inference all day, nor does it mean that human approval can be removed. A reasonable goal is: machines handle repetitive execution, humans control key decisions, and the system can reliably pause, resume, and trace actions.
2. Establish the Overall Architecture First, Then Define Agent Roles
A multi-agent system should not be just a group of roles that can chat with each other. It should first have a clear control layer, execution layer, and data layer.
A general architecture can be represented as:
Enterprise messaging entry↓Identity verification and request registration↓Task orchestrator├─ Requirement analysis agent├─ Product design agent├─ Technical design agent├─ Development agent└─ Testing agent↓Controlled tool execution environment↓Deliverable storage and acceptance records↓Human approval, deployment, and runtime monitoring
1. Control Layer: Manage the Process, Not Arbitrary Execution
The control layer manages task status, dependencies, timeouts, retries, and approval checkpoints. The model may propose decomposition suggestions, but whether a task is allowed to proceed should be determined by deterministic rules.
For example, when requirements are not yet confirmed, the system may explore possible solutions, but it should not directly modify the production environment. If tests have not passed, the task cannot be marked as delivered.
2. Execution Layer: Let Agents Work Through Restricted Tools
The execution layer provides capabilities such as file reading and writing, code modification, test execution, and document generation. Agents can only use authorized tools and must operate within designated working directories.
Operations proposed by the model should not automatically have execution permission. In particular, deleting data, reading secrets, installing dependencies, accessing external networks, and deploying changes require separate control rules.
3. Data Layer: Preserve Reproducible Project Facts
The data layer should store at least:
- Original requirements and confirmation records;
- Task decomposition and dependencies;
- Product specifications and technical designs;
- Code changes and their versions;
- Test reports and execution logs;
- Approval results and delivery notes.
These materials together form the source of project facts. Relying only on chat context is insufficient, because key constraints may be lost during long tasks, restarts, or role switches.
3. Divide Roles by Responsibility, Not by Quantity
More agents usually mean higher coordination costs. Role design should serve work boundaries rather than pursue a sense of scale.
1. Requirement Analysis Agent
This agent converts natural-language requirements into business problems, target users, functional scope, and items that need confirmation.
For a price monitoring requirement, it should proactively identify questions such as:
- Who maintains the product data, and how is the same product or specification confirmed?
- Is the monitored price the displayed price, promotional price, or final price under specific conditions?
- Is it necessary to distinguish regions, membership status, and purchase quantity?
- Are there limits on collection frequency?
- Which changes require alerts, and which are only retained for records?
If these questions are unanswered, the system should generate a clarification list instead of filling gaps with business commitments on its own.
2. Product Design Agent
This agent produces the product requirements document, page structure, and acceptance criteria.
“Support price trends” is not a complete acceptance condition. It should further specify the time range, how missing data is displayed, currency, price definition, and anomaly marking rules.
Likewise, “support table export” should define fields, filter scope, time format, and permission boundaries to avoid repeated rework during development.
3. Technical Design Agent
This agent defines system layering, data models, API contracts, scheduling strategies, and security plans.
Its output should explain the rationale behind technical choices. For example, why collection tasks and page queries need to be decoupled, why price snapshots should retain source timestamps, and why alerts must include deduplication.
4. Development Agent
This agent modifies code, runs tests, and organizes change notes within a controlled environment. It may invoke AI coding tools to assist implementation, but it should not expand the task scope on its own or skip quality gates.
5. Testing Agent
This agent independently verifies deliverables and checks functionality, exception paths, and security boundaries. The testing role may independently generate test scenarios, but test conclusions must come from real execution records rather than subjective evaluation of the code.
The overall control role maintains overall progress, handles conflicts, and reports status to the user. It does not need to repeat the work of every specialized role.
4. Context Isolation and Shared Facts Must Coexist
Independent contexts help reduce interference between roles. However, if contexts are completely isolated, roles may easily work from different assumptions.
A more reasonable design is:
Private context handles the current reasoning, while shared materials preserve project facts.
Each agent should receive only the information needed for the current task, such as the requirement version, relevant design sections, affected files, and acceptance conditions. The full history does not need to be injected repeatedly, but important decisions must be persisted.
Shared materials should carry version identifiers. Before the development agent starts work, it should confirm whether the requirements and API definitions it is using are still valid. If the design changes, the orchestrator needs to identify affected tasks and trigger re-evaluation.
For design disagreements, infinite discussion should be avoided. The system can record alternatives, risks, and a recommended conclusion, then route the decision to the responsible person for approval according to preset rules.
5. Manage Collaboration with a Task State Machine
Natural-language messages are suitable for explaining context, but they are not suitable as the sole basis for process control. Task status should be explicitly maintained by the system.
A common state flow is:
Pending clarification → Pending execution → Executing → Pending verification → Pending approval → Completed↓Execution failed↓Retry, replan, or human takeover
Task records should include task ID, owner, input materials, output location, dependent tasks, execution count, and deadline conditions.
Messages between agents should express clear intent, for example:
Message type: Request verificationSource role: DevelopmentTarget role: TestingRelated task: Price anomaly detectionInput: Current code version, acceptance criteria versionDeliverables: Change notes, test execution recordsNeeds confirmation: Threshold boundaries, missing data, duplicate alerts
These fields are design examples, not fixed interfaces of a specific product.
Parallel Execution Requires Clear Dependencies
After requirements are confirmed, page prototypes and some technical research can proceed in parallel. Once API contracts are stable, page development and service development can also proceed in parallel.
However, if multiple agents modify the same files at the same time, task locks, independent working directories, or a clear merge process must be established. Otherwise, the speed benefit of concurrency may be offset by conflict resolution.
The message system may also deliver duplicates. Therefore, receivers should identify duplicate requests based on message IDs and task status to avoid duplicate execution, duplicate submission, or duplicate notifications.
6. Case Design: E-Commerce Competitor Price Monitoring System
This case includes collection, data processing, visualization, and notification. It is suitable for verifying whether the multi-agent development workflow is complete.
1. Data Collection: Confirm Authorization Before Implementation
Collection should prioritize authorized data interfaces, data files provided by partners, or other legally usable data sources. For public pages, access rules, terms of use, and applicable legal requirements should also be checked.
The system should not be designed to bypass access controls, CAPTCHAs, or identity restrictions.
Collection tasks should set limits on access frequency, timeouts, retry intervals, and concurrency. When a data source becomes abnormal, the system should reduce frequency or pause, rather than retry indefinitely.
The following states should also be distinguished:
- Valid data was successfully obtained;
- The request failed;
- The page or data structure changed;
- The product was clearly delisted;
- Inventory status is unknown.
A failed request should not be directly interpreted as out of stock.
2. Price Definition: More Important Than Collection Success
The same product may have a displayed price, promotional price, member price, and bundle discount price. If the definitions differ, even a correctly drawn price curve may lead to wrong conclusions.
It is recommended to store the price type, currency, product specification, applicable conditions, and source timestamp together. Amounts should preferably use fixed-point representation or the smallest currency unit to avoid boundary errors caused by binary floating-point calculation.
Inventory can also use explicit states such as “in stock,” “out of stock,” and “unknown.” A single Boolean value should not be used to hide collection failures.
3. Data Model: Separate Configuration from Historical Snapshots
Data can be divided into four categories:
- Product monitoring configuration: product ID, specification, source, collection cycle, and enable/disable status.
- Price snapshot: collection time, source time, price definition, price value, inventory status, and data quality.
- Alert rule: threshold, fluctuation condition, duration, and recipients.
- Alert event: trigger reason, related snapshot, delivery status, and handling record.
Historical snapshots should generally be append-only. If errors are found later, they should be explained through quality flags or correction records rather than silently overwritten.
4. Anomaly Detection: Start with Explainable Rules
Complex models are not necessary in the initial stage. Three types of rules can be used:
- The current price is below a specified threshold;
- The change compared with the last valid snapshot exceeds a threshold;
- Inventory status changes from in stock to out of stock.
The adjacent price change rate can be expressed as:
Change rate = (Current price - Last valid price) ÷ Last valid price
Before calculation, the system must confirm that the last price is greater than zero, that both records use the same price definition, and that data quality is acceptable. If the sampling interval is too long, the limitations of the comparison result should also be indicated.
To reduce false positives, the system can require an anomaly to appear consecutively several times or introduce a recovery threshold, avoiding repeated notifications when data fluctuates near the boundary.
5. Alerts and Display: Make Data Explainable
An alert should include the product, price definition, current value, comparison value, trigger time, and reason, rather than only sending “price anomaly.”
For the same product, same rule, and same anomaly stage, deduplication and cooldown strategies should be set. Delivery failures may be retried, but large numbers of duplicate messages must be avoided.
Trend charts should mark missing intervals and data quality issues. Without explanation, missing data should not be filled with zeros, and interpolated results should not be presented as real collected records.
Exported files should also state the time zone, currency, and field meanings, and should guard against the risk of text fields being interpreted as formulas by spreadsheet software.
7. Make AI Coding Execution a Closed Loop
When the development agent invokes local AI coding tools, it is recommended to follow a “plan-execute-verify-summarize” process.
1. Plan
List the modification scope, dependent materials, testing method, and potential risks. If the task involves new external dependencies, data migration, or permission changes, it should first enter an approval checkpoint.
2. Execute
Each task is completed in an isolated working environment. Tool execution should be constrained by directory scope, command categories, network access, and resource quotas.
Production secrets should not be placed directly into prompts or ordinary logs. Sensitive configuration should be injected through controlled mechanisms, with read scope restricted.
3. Verify
At minimum, automated tests related to the change should be executed. For a price monitoring system, coverage should include:
- Empty responses and malformed formats;
- Collection timeouts;
- Duplicate snapshots;
- Different price definitions;
- Zero values and boundary amounts;
- Unknown inventory;
- Alert delivery failures and duplicate sends;
- Export permissions and abnormal fields.
Successful code generation, successful build, and business acceptance are different levels of results and cannot replace one another.
4. Summarize
The delivery report should list implemented content, actual test results, known limitations, and pending approvals. Checks that were not executed should be clearly marked as “not verified,” and speculation must not replace results.
8. Continuous Operation Depends on Fault Recovery, Not Continuous Conversation
The core of a 24/7 system is persistent state and reliable recovery.
1. Timeouts and Bounded Retries
Each task should have an execution time limit and a retry limit. Temporary network errors may be retried; insufficient permissions, requirement conflicts, and data structure changes usually require fixes or human intervention.
Retries should use increasing wait intervals and, when necessary, random jitter to avoid multiple tasks hitting a failing service at the same time.
2. Checkpoints and Task Leases
The system should save progress at key stages. After a process restart, it should resume from persistent state rather than re-executing all work.
Task claiming can use execution leases with expiration. Execution nodes need to renew leases periodically. If a lease expires, the orchestrator decides whether to reassign the task, preventing the same task from being repeatedly executed by multiple nodes for a long time.
3. Observability
Logs and monitoring should cover at least task ID, role, stage, tool call results, duration, and error categories.
Key focus areas include:
- Task success rate and failure reasons;
- Queue backlog and execution latency;
- Number of retries and human takeovers;
- Data collection success rate;
- Alert delivery failure rate;
- Model invocation and execution resource consumption.
Metrics should come from actual runtime records. Long-term stability or efficiency improvement ratios should not be inferred from a single demonstration.
4. Cost Control
Set budgets for individual tasks, individual roles, and the overall system. Limit concurrency, tool call counts, and maximum iteration rounds.
When a task fails repeatedly or discussion produces no new information, the system should pause and output the blocking reason instead of continuing to consume resources.
9. Security Boundary: External Content Is Data, Not Instructions
Price pages, message attachments, and requirement texts may contain misleading content. When agents read these materials, they must not treat embedded operational suggestions as system authorization.
Three types of information should be clearly distinguished:
- Control rules: determine permissions and allowed behavior;
- Confirmed requirements: determine business goals;
- External materials: provide analysis evidence.
External materials must not require agents to read secrets, disable checks, or send data to unknown addresses. Even if the model generates such a tool request, the execution layer should reject it independently.
High-risk actions such as deployment, data deletion, production configuration changes, and access permission expansion should require human approval. The approval target must be a specific change, not a vague “allow continuation.”
10. Recommended Rollout Sequence and Acceptance Criteria
It is not advisable to open full autonomous operation from the beginning. A more reliable implementation sequence is:
- Establish a single-task closed loop: complete a small feature and verify code modification, testing, and delivery records.
- Introduce specialized roles: add requirement, development, and testing roles, and verify material handoff.
- Add controlled parallelism: process independent tasks in parallel after dependencies are clear.
- Connect the business entry: complete identity verification, permissions, status queries, and notifications.
- Build continuous operation capabilities: add scheduling, recovery, monitoring, budgets, and human takeover.
Final acceptance should not only check whether the page can open. It should also answer:
- Are there confirmation records and executable acceptance conditions for requirements?
- Can each change be traced to a task and code version?
- Can the system continue processing unfinished tasks after a restart?
- Will duplicate messages cause duplicate execution?
- Can missing data and business anomalies be correctly distinguished?
- Are high-risk operations constrained by permissions and approvals?
- When continuous failures occur, can the system stop and notify the responsible person?
The value of multi-agent automation is not endless conversation between roles. It is breaking complex work into verifiable, recoverable, and auditable steps. Independent contexts provide clear division of labor, shared materials ensure consistent understanding, deterministic orchestration constrains execution, and real testing determines delivery quality. Once these foundations are in place, 24/7 automated development has a chance to become a stable engineering capability rather than an accidental successful demonstration.
