Building an Always-On Multi-Agent Development System: A Practical Guide
This guide walks through building a multi-agent collaboration system for continuous software delivery, using a competitor price monitoring service as the running example. It covers defining the business loop before deciding how many agents you need, six agent roles (coordinator, research, requirements, architecture, development, testing), a layered architecture where models make judgments and deterministic programs enforce constraints, task contracts instead of open-ended chat, context isolation plus shared knowledge, data modeling for products, monitoring targets and collection snapshots, compliant collection scheduling, anomaly detection and notification deduplication, controlled use of a code execution sandbox by the development agent, state management for always-on operation, evidence-based testing and acceptance, and a staged rollout plan with the metrics worth tracking.
1. From Autonomous Chat to Continuous Delivery: What You Actually Need to Build
The value of multi-agent collaboration is not having several models take turns answering questions. It is breaking a complex goal into work units that each have inputs, outputs, an owner, and acceptance criteria, then delivering them through a controlled process.
Take “build a competitor price monitoring system for an e-commerce category” as an example. A single business request usually spans market research, field definitions, collection strategy, data storage, page display, alerting, and ongoing operations. One agent can generate a plan or some code, but if all of that work happens inside a single conversation, you get missed requirements, mixed context, repeated citation of wrong conclusions, and testing that is only formal.
A more reliable approach is to build a multi-agent collaboration system:
- Business stakeholders submit requests, and a coordinator agent clarifies and decomposes them.
- Different roles produce research reports, requirements documents, architecture plans, code, and test results.
- A task orchestration layer handles state transitions, dependency management, and failure recovery.
- A controlled execution environment runs code and tests.
- Humans approve at key checkpoints.
Two boundaries need to be stated up front.
First, “always-on” means the system can keep scheduling work and recover from failures. It does not mean the models are always right, and it does not mean unlimited changes to production are acceptable.
Second, “independent context” between agents is logical isolation. If you also want security isolation, you must restrict file access, network access, credential use, and execution permissions.
2. Define the Business Goal First, Then Decide How Many Agents You Need
Many projects start by carving out a large number of roles. This adds coordination cost without improving delivery quality. The correct order is to establish the business loop first, then identify which steps genuinely need separate responsibilities.
The price monitoring system can start with this minimal loop:
- Maintain the products to be monitored and their specifications.
- Fetch price and inventory data on a schedule, within authorized scope.
- Validate data completeness and store valid snapshots.
- Display historical trends and anomalous changes.
- Send notifications for events that match defined rules.
- Support table export and collection failure tracking.
On top of that, split delivery into six roles.
2.1 Coordinator Agent
Responsible for understanding the goal, asking clarifying questions, decomposing tasks, assigning owners, and consolidating results. It should maintain global progress but does not need to hold all raw data.
The coordinator must not close a task just because another agent said “done.” It should check where deliverables live, what test evidence exists, and whether acceptance conditions are met.
2.2 Research Agent
Responsible for mapping business scenarios, data sources, collection constraints, and price definitions. Research output should state sources, applicable scope, and uncertainty. Speculation must not be written up as settled fact.
For data that cannot be accessed legally, the agent should propose alternatives such as authorized APIs, manual imports, or public data, rather than trying to work around access controls.
2.3 Requirements Agent
Turns business language into verifiable requirements. For example, “notify me when the price drops significantly” must be refined into: which baseline it is compared against, how large a drop triggers it, which price types participate in the comparison, and whether the same event triggers repeated notifications.
2.4 Architecture Agent
Responsible for component boundaries, data models, interface contracts, error handling, and permission boundaries. The point is not to draw a complex structure but to ensure each module can be implemented, tested, and replaced independently.
2.5 Development Agent
Modifies code, runs tests, and writes change notes within the approved task scope. It may call a controlled local coding executor, but should not have system-level privileges or production credentials by default.
2.6 Testing Agent
Designs tests independently from the requirements and interface contracts, covering happy paths, error paths, and boundary conditions. The testing role should not merely replay the success cases the development role provides; it should actively look for missing data, repeated execution, and inconsistent state.
For smaller projects, some roles can be merged. The number of roles is not a capability metric; clear responsibility boundaries are.
3. Build a Layered Architecture: Models Judge, Programs Constrain
A maintainable system can be split into six layers:
Business entry point↓Identity verification and request intake↓Task orchestration and state management↓Role-based agents↓Controlled tools and code execution environment↓Deliverable storage, audit records, monitoring and alerting
The business entry point can be an enterprise messaging channel or an internal admin page. Either way, messages should be converted into structured tasks rather than being treated directly as execution instructions.
The orchestration layer maintains dependencies. For example, architecture design starts only after requirements are confirmed; development and test design can run in parallel once the interface contract is confirmed; a release approval can be requested only after integration tests pass.
Role-based agents handle analysis, planning, and content generation. Hard rules such as state transitions, permission checks, approval decisions, and retry limits should be executed by deterministic programs. This prevents a model from skipping required steps because it misunderstood something.
Deliverable storage should retain requirements documents, design documents, code changes, test reports, and approval records. Keeping only chat history is not enough to support later maintenance, because conclusions in a chat may lack versions, references, and clear ownership.
4. Replace Casual Chat with Task Contracts
Agents can exchange messages, but real collaboration works better around task contracts. Each task should contain at least:
- Task identifier and the project it belongs to.
- Goal and scope of work.
- Input materials and their versions.
- Output format and storage location.
- Acceptance criteria.
- Tools and permissions allowed.
- Timeout, retry, and human escalation conditions.
Below is an illustrative task description. It does not map to any specific product API:
Task ID: Price rule designOwner: Requirements roleGoal: Define price anomaly and notification rulesInputs:Confirmed business goalsProduct specification notesList of collectable fieldsOutputs:Rule specification documentEdge case listAcceptance samplesAcceptance criteria:Distinguish list price from conditional promotional priceDefine the comparison baseline and trigger thresholdsCover missing data and duplicate notifications
Task contracts should also separate “produced” from “complete.” Generating code is a produced artifact; it is complete only when testing and review requirements are satisfied.
When two roles disagree, do not let them discuss in an infinite loop. Set a limited number of rounds, require each side to submit its evidence, and have the coordinator or a human owner decide.
5. Balancing Context Isolation with Shared Knowledge
Independent contexts reduce cross-task contamination, but excessive isolation causes duplicated research and inconsistent definitions. So three kinds of information need to be maintained.
The first is shared project facts: confirmed requirements, interface contracts, terminology definitions, and data definitions. These materials should be version controlled with a named maintainer.
The second is role-private workspaces: drafts, temporary analysis, and execution logs. Other roles do not need to read all of it; they only need the consolidated results.
The third is task handoff summaries: what has been completed, current blockers, assumptions still to be verified, and where the relevant deliverables are.
Shared knowledge should clearly distinguish “confirmed facts,” “tentative proposals,” and “assumptions to be verified.” For instance, a collection frequency that has not been verified must not be treated by later roles as a settled system capability.
In addition, web page text, imported files, and external messages should all be treated as untrusted input. Even if such content contains instructions to change permissions, leak credentials, or ignore rules, it can only be analyzed as data and must never gain execution authority.
6. Key Data Design for the Price Monitoring System
The most common problem in price monitoring is not collection failure. It is collecting data under different definitions and then comparing it directly.
The same product may involve different specifications, sales regions, membership conditions, threshold discounts, shipping, and validity periods. If these conditions are not recorded, a trend chart can mistake a change in conditions for a change in price.
Separate the product entity, the monitoring target, and the collection snapshot.
Product Entity
Describes the basic identity of a product, such as internal product ID, name, specification, and unit of measure.
Monitoring Target
Describes the specific monitoring configuration for a product under one data source, including source identifier, authorized access method, specification matching rule, and collection interval.
Collection Snapshot
Records collection time, list price, promotion information, inventory status, currency, data quality status, and source evidence. Conditional discounts should be stored separately and should not overwrite the list price.
Out-of-stock, collection failure, and missing fields must be represented separately. “Unable to read inventory” must not be automatically interpreted as “out of stock,” and a missing price must never be written as zero.
When a discount combination cannot be computed accurately, keep the original condition description and flag whether the price is directly comparable, so the system does not manufacture a false low-price record.
7. Collection Scheduling, Anomaly Detection, and Notification Design
7.1 Compliant Collection and Task Scheduling
Prefer authorized data APIs, business export files, or publicly accessible information that permits access. Before collecting, confirm terms of use, access frequency, and data retention scope. Do not bypass authentication or access controls.
The scheduler needs to control concurrency, request rate, and failure retries. Retries should have a cap and a backoff interval to avoid wasting resources through repeated access in a short window.
Also prevent the same monitoring target from being collected by multiple execution instances. Use task leases or a mutual exclusion mechanism to limit parallel execution, and build a deduplication key from the monitoring target, scheduled execution time, and task version.
7.2 Price Anomaly Detection
Common rules include:
- Price below a business-defined absolute threshold.
- A significant rise or fall relative to the last valid price.
- Deviation from a stable baseline over a period of time.
- Inventory changing from in-stock to out-of-stock.
- No valid data obtained for a long time.
The rate of change can be expressed as:
Change rate = (Current valid price - Baseline price) ÷ Baseline price
Before computing, verify that the baseline price is valid and greater than zero, and confirm that product specification, currency, and price conditions match. Rule thresholds are business configuration; there is no single value that suits all products.
For highly sensitive alerts, require several consecutive valid observations to satisfy the condition, or trigger a second verification, to reduce false positives caused by a single parsing error.
7.3 Notification Deduplication and Recovery Messages
Alerts should not be resent on every collection cycle. Generate an event key from the monitoring target, rule identifier, and anomaly state, then apply a notification cooldown.
Distinguish anomaly onset, anomaly persistence, and anomaly recovery. Notification content should include product information, values before and after the change, the triggered rule, collection time, and data quality notes, so business users can decide whether action is needed.
A failed notification must not simply be dropped. Record it in a pending-send state and retry a limited number of times. For severe anomalies, escalate to a human handling queue.
8. Letting the Development Agent Call a Coding Executor Under Control
An agent that can keep writing code is not thereby allowed to execute code without limits. The recommended loop is “propose a plan → verify permissions → execute in isolation → inspect results.”
Before execution, the agent submits the files it intends to modify, the expected behavior, and the verification method. The system checks task scope and permissions, then allows execution in a separate workspace.
The execution environment should enforce these constraints:
- No production credentials injected by default.
- Restricted writable directories and accessible network.
- Limits on runtime, process count, and resources.
- Unapproved high-risk operations prohibited.
- Execution output, failure reasons, and file change records retained.
Dependency installation should also be controlled. New dependencies can bring security risk, licensing obligations, and maintenance cost, and should not be accepted automatically just because a code generator suggested them.
Production releases, destructive database changes, and sensitive configuration changes should keep human approval. The development agent can prepare a change plan and rollback steps, but final execution authority must match the risk level.
9. Always-On Operation Depends on State Management, Not Infinite Loops
A continuously running system needs explicit task states, for example:
Pending → In progress → Pending acceptance → Completed↓Pending retry↓Pending human handling
Every state change should be persisted. After a service restart, the system should resume unfinished tasks rather than create a new batch of duplicate work.
In-progress tasks need heartbeats and leases. If an execution instance goes silent, the scheduler can arrange a takeover after the lease expires. But the original instance may only have lost connectivity temporarily, so takeover must still account for possible duplicate execution.
For external notifications, data writes, and release operations, design for idempotency as far as possible: resubmitting the same business action should not produce duplicate alerts, duplicate records, or duplicate deployments.
Also set per-task budgets: maximum runtime, maximum model calls, maximum retries, and maximum parallel tasks. When a limit is reached, save progress and request human intervention instead of continuing to consume resources.
10. Testing and Acceptance Must Form an Evidence Chain
A multi-agent system needs at least two groups of tests: business system tests and agent collaboration tests.
Business system tests should cover price parsing, specification matching, promotion conditions, inventory changes, duplicate collection, notification failures, and export content. Abnormal samples matter especially: empty prices, invalid numbers, changed source fields, and collection timeouts.
Collaboration tests should verify task dependencies, context handoff, permission limits, execution interruption, and failure recovery. They should also check whether agents still respect established permission boundaries when they receive malicious external text.
Acceptance cannot rely on model self-assessment alone. Use reviewable evidence:
- Mapping between requirement items and implementation items.
- Automated test results.
- Operation records for key scenarios.
- Code changes and review comments.
- Data quality and alert behavior verification.
- Known limitations and unresolved issues.
Note in particular that passing tests does not mean the feature is complete. If the test cases themselves omit a business requirement, the system can still deliver the wrong result. Test design should therefore start from confirmed requirements, not only from the existing code.
11. Recommended Rollout Order
Phase one: implement a single closed loop. One request entry point, one coordinator role, one development role, and one testing role, handling collection, storage, and notification for a small number of monitoring targets.
Phase two: add task contracts, state persistence, deliverable management, and failure retries, so the process becomes traceable and recoverable.
Phase three: split out the research, requirements, and architecture roles, using a shared fact base and versioned documents to reduce collaboration friction.
Phase four: introduce continuous scheduling, finer-grained permissions, human approvals, and runtime monitoring, gradually expanding task scope rather than letting the system operate production unattended from the start.
During operation, track task completion rate, human rework, collection validity rate, alert false positives, task waiting time, and resource consumption. These metrics should be computed from actual run records; system maturity should not be judged from a single demo.
Conclusion
The core of multi-agent collaborative development is embedding the analysis and generation ability of models into a reliable software engineering process. Role separation solves responsibility, task contracts solve handoff, independent contexts solve information interference, controlled execution solves permissions, and state management plus acceptance evidence solve continuous operation and delivery trustworthiness.
Starting from price monitoring, you can gradually build an automated path from business requirement to a running system. But what is worth pursuing is not “how much code was generated overnight.” It is whether every result has a basis, whether every action can be constrained, whether every failure can be recovered, and whether the final system serves the business reliably.
