Building an Always-On Multi-Agent Development System from Scratch

    This article walks through the engineering design of an always-on multi-agent development system, using a competitor price-monitoring dashboard as the running example. It covers the five-layer architecture (interaction entry, orchestration and state, agent execution, tools and isolated environments, storage and observability), role separation across orchestrator, research, product, architecture, development, and testing agents, task contracts, layered context management, message semantics, decomposition of the price-monitoring requirements into verifiable modules, bounded coding permissions, quality gates per stage, and the state machine, recovery, idempotency, and budget controls needed for continuous operation. It closes with model evaluation criteria and a four-step rollout order that prioritizes reliability before parallelism.

    1. Start With the Goal: Always-On Does Not Mean Unsupervised

    Sending a requirement to one agent that then organizes other agents to handle research, product design, architecture design, development, and testing is the typical multi-agent development scenario.

    But a system with real engineering value is not “a prompt per role.” It is an execution pipeline with explicit inputs, deliverables, state management, quality checks, and failure recovery.

    “Always-on” here means the system can continuously accept tasks, execute them under defined rules, and recover after failures. It does not mean the model gets unlimited network access, can modify production, or makes every business decision on a human’s behalf.

    This article uses a “competitor price monitoring dashboard” as the running case and designs one complete chain:

    User submits a requirement → orchestrator agent decomposes the task → research → product design → architecture design → coding → testing → delivery approval.

    The final business system must support:

    • Entering product URLs to be monitored.
    • Collecting price, original price, promotion text, and stock status on a schedule.
    • Displaying price trends and flagging abnormal movements.
    • Sending enterprise messages on low prices, significant changes, or out-of-stock.
    • Exporting tabular data for later analysis.

    Two systems must be kept distinct: the multi-agent collaboration system that does the development work, and the price monitoring business system that gets delivered. They have different permissions, data, and operating lifecycles, and should not be merged.

    2. Overall Architecture: Models Judge, Programs Constrain

    Split the collaboration system into five layers.

    2.1 Interaction Entry

    The entry point receives user requirements and shows progress, approval requests, and delivery results. It can be an enterprise messaging entry or an internal web page.

    The entry point should not trigger high-privilege operations directly. On receiving a message, it first verifies identity, then converts the natural-language requirement into a structured task.

    For example, when a user types “build a price monitoring system,” the system still needs to confirm:

    • Whether the monitoring targets have a legitimate data acquisition channel.
    • The expected range of product count and collection frequency.
    • Whether prices differ by region, variant, or membership status.
    • Alert recipients and notification rules.
    • Deployment environment and delivery scope.

    When this information is insufficient, the task should enter a “waiting for clarification” state rather than having the model silently fill in business facts.

    2.2 Orchestration and State Layer

    The orchestration layer maintains task dependencies, execution order, timeouts, retries, and approval rules. It is the control center of the whole system.

    The orchestrator agent may propose a decomposition, but actual task flow should be executed by the program according to a state machine. That way, even if a model session breaks, the task does not exist only inside an unrecoverable conversation.

    2.3 Agent Execution Layer

    Different agents take different responsibilities, each with its own session context. They collaborate through structured messages and shared deliverables rather than reading each other’s full chat history.

    This reduces pollution from irrelevant information, but it does not automatically eliminate errors. Agents can still pass wrong conclusions to each other, so key facts need source records and verification mechanisms.

    2.4 Tools and Isolated Environments

    Code generation, file reads and writes, test execution, and data queries happen through controlled tools.

    The execution environment should define file scope, network access, resource quotas, and timeouts. Operations involving database changes, external message sending, or release deployment are controlled through explicit permission policies.

    2.5 Storage and Observability Layer

    Task state, events, deliverables, logs, and approval records must be persisted. Model context is not a database and cannot serve as reliable storage.

    The system must at minimum answer three questions:

    1. Which step is the current task on?
    2. Which document or execution did a given conclusion come from?
    3. Where should recovery start after a failure?

    3. Role Split: Define Responsibility First, Add Parallelism Later

    More roles is not better. For an initial version, use the following split.

    Role Core Responsibility Main Deliverable Key Constraint
    Orchestrator agent Clarify requirements, decompose tasks, review deliverables Task plan, stage summaries Does not bypass approval
    Research agent Analyze business scenarios and data availability Research report, risk list Does not present speculation as fact
    Product agent Define features, flows, and acceptance criteria PRD Does not expand scope on its own
    Architecture agent Design modules, data, and interface contracts Architecture doc, data dictionary Does not rely on unconfirmed capabilities
    Development agent Implement code, add development tests Code, change notes Executes only in the authorized workspace
    Testing agent Check requirement coverage and failure paths Test report, defect list Does not pass based on description alone

    The Orchestrator Is Not an Omnipotent Admin

    The orchestrator coordinates; it should not also perform all execution work. It checks whether deliverables are complete, whether preconditions are met, and whether anything needs user confirmation.

    For example, if research finds that prices cannot be reliably obtained from a certain class of pages, the orchestrator should feed that constraint back to product design instead of forcing the development agent to implement it anyway.

    Keep Research and Product Design Separate

    Research answers “which requirements hold and which data is obtainable.” Product design answers “what we build this time and how we accept it.”

    Separating the two reduces the risk of writing unverified market judgments straight into development requirements.

    Testing Should Stay Relatively Independent

    It is necessary for the development agent to run tests itself, but that cannot replace independent acceptance.

    The testing agent should design cases from the requirements document and then check execution results. For problems that the same class of model may collectively overlook, deterministic rule checks, human spot checks, or other independent verification are also needed.

    4. Write Task Contracts First, So Agents Stop Guessing

    The most common failure in cross-role collaboration is a blurry delivery boundary.

    “Please do the architecture design” is not a sufficient task description. A better task includes the goal, inputs, outputs, acceptance conditions, and permission boundaries.

    Below is an illustrative task contract. The fields are defined by the application and are not any product’s API:

    1. Task ID: TASK-104
    2. Task type: Architecture design
    3. Goal: Design the first version of the price monitoring architecture
    4. Inputs:
    5. - Confirmed requirements document
    6. - Data acquisition method description
    7. Outputs:
    8. - Module breakdown
    9. - Data entities and field meanings
    10. - Collection and alert processing flows
    11. - Risks and open questions
    12. Acceptance conditions:
    13. - Every core requirement maps to a module
    14. - Collection failure has an explicit state
    15. - Alerts have a deduplication rule
    16. - Missing prices are not written as zero
    17. Permissions:
    18. - May read project documents
    19. - May not modify production data

    Each task should also bind a deliverable version. If the product document changes, downstream roles must state which version they are working from, so architecture and code do not implement different requirements.

    For information from unreliable sources or not yet confirmed, deliverables should mark it “to be verified” instead of letting downstream roles treat it as settled fact.

    5. Context Management: Separate Sessions Plus Persistent Memory

    Long-task stability cannot rely on model context length alone.

    Even if a model can accept a large amount of text, it may drop constraints, confuse versions, or be influenced by wrong conclusions in the history. A more reliable approach is layered memory.

    5.1 Session Context

    Holds the local information the current role is working on, such as the module being modified or the most recent test failure reason.

    This part should stay focused and does not need to copy every discussion from other roles.

    5.2 Project Fact Base

    Holds confirmed requirements, interface contracts, the data dictionary, deployment constraints, and approved technical decisions.

    Entries in the fact base need source, version, and confirmation status, so “the model once said” never becomes the basis for a fact.

    5.3 Deliverable Repository

    Holds reports, code, test results, and run instructions. When passing work across roles, prefer sending a deliverable reference plus a summary rather than pasting all content again.

    5.4 Decision Records

    Record significant choices and their rationale, for example:

    The first version does not support automatic cross-variant price comparison, because variant mapping rules are not confirmed and wrong matches could distort price alerts.

    Such records help later agents understand the tradeoffs and avoid repeatedly overturning approved decisions.

    When compressing context, keep unresolved questions, key constraints, and failure reasons. Keeping only a summary like “architecture design complete” is usually not enough to support later development.

    6. Agent Communication: Messages Should Trigger Flow, Not Flood the Chat

    Agents can communicate with each other, but message semantics need constraints.

    Recommended message categories:

    • Task assignment.
    • Progress update.
    • Deliverable submission.
    • Question clarification.
    • Defect feedback.
    • Approval request.

    A delivery message can look like this:

    1. Message type: Deliverable submission
    2. Message ID: MSG-208
    3. From role: Research agent
    4. To role: Orchestrator agent
    5. Related task: TASK-101
    6. Deliverable reference: Research report v2
    7. Summary: Authorized data sources are usable for the first version; some fields may be missing
    8. Blocker: Need to confirm how to display the missing stock field

    Do not treat “message sent” as “task complete.” Completion requires the deliverable to exist and to pass the relevant checks.

    If you use a message queue, account for duplicate delivery. Consumers should deduplicate by message ID or business identifier to avoid creating duplicate tasks, notifying users repeatedly, or executing a change multiple times.

    For communication failures, the send state must also be persisted rather than relying only on an in-memory retry loop.

    7. Decomposing the Price Monitoring Requirement Into Verifiable Modules

    A price monitoring system looks simple; the real difficulty is in data definitions, reliable collection, and alert accuracy.

    7.1 Monitored Object Management

    One product URL does not necessarily map to one unique price. Price can vary by variant, region, time, or user identity.

    A monitored object should therefore record at least:

    • The original URL and a normalized identifier.
    • Product name and source.
    • Confirmed variants or options.
    • Collection frequency.
    • Enabled/paused state.
    • Data acquisition method and authorization basis.

    The first version can limit monitoring to a single variant and a fixed region, but that limitation must be stated clearly in the UI and the documentation.

    7.2 Data Collection and Normalization

    Prefer authorized APIs or legitimate, permitted acquisition methods. For web data, follow applicable rules and access limits; bypassing access controls is not an implementation path.

    Collection results should distinguish:

    1. product_id
    2. collected_at
    3. price_amount
    4. currency
    5. original_price_amount
    6. promotion_text
    7. stock_status
    8. collection_status
    9. data_source

    Amounts should use exact decimal representation or integer minor currency units to avoid binary floating-point error.

    A failed collection must not be recorded as a price of zero; when stock cannot be determined, it must not be marked out of stock. Business-level “unknown” and “confirmed out of stock” must stay separate.

    Product configuration and price history should be stored separately. History is typically append-only, so overwriting does not destroy the audit trail.

    Trend charts need to make explicit:

    • Which timezone is used for display.
    • Whether missing points are left empty.
    • Whether the chart shows the collected price or some estimated post-discount price.
    • Whether the data is aggregated.

    Missing data should not be filled with zero, or it can create a fake price crash.

    7.4 Abnormal Movements and Alerts

    The most basic rule compares two adjacent valid prices:

    1. change_ratio = (current_price - last_valid_price) / last_valid_price

    This calculation applies only when the last price is valid and greater than zero.

    Rules can also include:

    • Price below a user-defined threshold.
    • Change ratio beyond a configured range.
    • Stock moving from in-stock to confirmed out-of-stock.
    • Consecutive collection failures.

    Different alerts need different semantics. A collection failure is a data quality problem and must not be disguised as an out-of-stock product.

    To avoid notification storms, add cooldown periods, event deduplication, and recovery notifications. When necessary, require several consecutive matching observations before sending a business alert; the exact rule is set by business acceptance.

    7.5 Tabular Export

    Exports must keep time, amount, and null semantics consistent. Text collected externally may be interpreted as a formula by spreadsheet software, so it must be handled safely for the target format.

    Large exports are better run as background jobs with access permissions, file expiry, and download auditing.

    8. Automated Coding: Allow Execution, Not Unlimited Authorization

    The development agent can call controlled coding tools to modify code and run tests, but its execution permissions must be constrained by the program.

    Recommended flow:

    1. Read the approved requirements and architecture.
    2. Generate a change plan.
    3. Modify code in an isolated workspace.
    4. Run static checks and tests.
    5. Submit a change summary and test evidence.
    6. Have the testing stage check requirement coverage.
    7. Enter deployment only after authorization.

    Tool calls should at minimum limit:

    • Readable and writable directories.
    • Network targets.
    • Allowed categories of operations.
    • Per-execution timeout.
    • Compute resources and disk space.
    • Credential access scope.

    Secrets must not be written into prompts or ordinary task logs. When access to protected resources is needed, use controlled identity and least-privilege mechanisms.

    Web pages, documents, code comments, and logs that the agent reads are all potential untrusted input. They may contain text that induces additional operations, so external content is reference material only and must never gain the standing to modify system rules or elevate privileges.

    9. Quality Gates: No Evidence, No “Done”

    Every stage needs checkable exit conditions.

    Research Stage

    Must provide data sources, feasibility limits, and open questions, not just generic market description.

    Product Stage

    Every feature needs acceptance criteria. For example:

    When collection fails, the page shows a failure state and keeps the timestamp of the last valid price; it does not present that value as a fresh collection result.

    Architecture Stage

    Check that data flows, permission boundaries, failure handling, and module dependencies are complete.

    Development Stage

    Require actual changes, the checks that were run, and failure records, not a written judgment that “the code should run.”

    Testing Stage

    At minimum cover:

    • Normal collection and display.
    • Missing prices.
    • Undeterminable stock.
    • Timeouts and retries.
    • Duplicate messages.
    • Alert deduplication.
    • Export safety.
    • Unauthorized access.

    Passing tests still does not mean automatic release. Production changes, access to sensitive data, and operations with large external impact should keep a human approval node.

    10. Continuous Operation: State Machines, Recovery, and Budget Control

    An always-on system must handle interrupted execution.

    Task states can be designed as:

    1. pending clarification → ready → running → pending acceptance → done
    2. ↓
    3. waiting for retry
    4. ↓
    5. blocked

    When persisting state, persist a version too, so concurrent executors do not overwrite each other’s results.

    10.1 Heartbeat and Execution Lease

    Executors report liveness periodically. After the lease expires, the orchestration layer can assume execution may have been interrupted and start a recovery check.

    But a timeout does not mean the operation did not happen. For operations with external side effects, verify the result first, then decide whether to retry.

    10.2 Bounded Retries

    Network jitter can be retried; insufficient permissions and conflicting requirements usually cannot be solved by retrying.

    Retries need a maximum count and a backoff strategy. Once the limit is reached, the task becomes blocked and the relevant people are notified.

    10.3 Idempotency and Side-Effect Control

    Sending alerts, creating monitored items, and releasing changes should all have idempotency identifiers.

    For complex tasks, it is unrealistic to promise strict “execute exactly once.” A more practical approach is to allow duplicate message arrival while using state checks and idempotency to avoid duplicate effects.

    10.4 Cost Budget

    Set budgets per task for model calls, execution duration, retry count, and resource consumption.

    When a budget is exhausted, pause and report:

    • What work has been completed.
    • Which problems remain unresolved.
    • What authorization is needed to continue.
    • Whether the scope can be reduced.

    Do not let agents discuss endlessly with each other while making no real progress.

    11. Model Evaluation: Judge Whole Tasks, Not Single Answers

    Choose models by evaluating the actual workflow, not by one code generation result.

    Watch for:

    • Whether the task contract is followed consistently.
    • Whether facts and speculation are correctly distinguished.
    • Whether deliverable versions stay consistent.
    • Whether tools are used accurately and failures handled.
    • Whether clarification is requested when information is insufficient.
    • Whether the output code and docs meet the acceptance requirements.

    Build a fixed set of tasks covering normal requirements, missing information, conflicting constraints, and tool failures, then compare results with a consistent acceptance method.

    Final metrics should include task success rate, number of human corrections, recovery behavior, and overall cost. A longer context does not necessarily produce more reliable collaboration, and stronger single-turn ability cannot replace permission control and quality gates.

    In practice, proceed in four steps.

    Step 1: Get a minimal loop working.
    Use only three roles — orchestrator, development, and testing — and deliver one small feature with a clear scope. First validate task persistence, deliverable passing, and test feedback.

    Step 2: Fill in the business flow.
    Add research, product, and architecture roles to turn natural-language requirements into verifiable engineering contracts.

    Step 3: Add safety and recovery.
    Complete isolated execution, permission policies, heartbeats, idempotency, budgets, and approvals.

    Step 4: Open limited parallelism.
    Parallelize only independent tasks. Freeze shared interfaces and data structures first, then split coding work to reduce conflicts and rework.

    At delivery, include not just code but also deployment instructions, a configuration list, data definitions, test results, known limitations, and a rollback plan.

    The core value of multi-agent development is not copying human job titles into multiple sessions. It is turning engineering work into a process that can be divided, checked, and recovered. Models provide understanding and reasoning; the system provides state, permissions, evidence, and constraints. Only when the two work together does “continuous autonomous work” move from a demo to manageable engineering practice.