Engineering Practice Guide for Always-On Multi-Agent Collaboration

    This guide explains how to build always-on multi-agent systems that stay goal-aligned over long runs: persist task state, separate model judgment from controlled execution, define role contracts, recover from failures, and keep humans in the loop for high-risk actions. Using a competitor price-monitoring dashboard as a working example, it covers architecture layers, context management, orchestration, data semantics, constrained codegen, testable acceptance, and a staged path from a small closed loop to limited unattended work.

    1. Clarify the goal: continuous operation is not unbounded autonomy

    Handing a business request to multiple agents for research, product design, architecture, development, and testing is a typical multi-agent pattern. The hard part is not creating roles. It is keeping those roles aligned over long runs, completing handoffs, and recovering when something fails.

    A single agent can finish a local task and still be a poor owner of an end-to-end software delivery flow. Analysis must understand user goals, architecture must weigh constraints, development must change code, and testing must hunt for defects. Putting every duty in one conversation context mixes roles, inflates history, and lets acceptance criteria drift.

    An always-on multi-agent system should therefore mean:

    Within explicit permission and resource bounds, persistent task state drives several agents, and delivery closes through tool execution, quality checks, and human approval.

    “Always-on” means the system can keep accepting work, scheduling jobs, and handling faults. It does not mean the model must generate continuously, and it does not mean high-risk actions such as production release or data deletion can skip human confirmation.

    2. Use a price-monitoring dashboard as a complete requirements sample

    To keep the design actionable, pick a bounded scenario: a user submits a request through an enterprise messaging channel to build a competitor price-monitoring dashboard.

    The system should support:

    • Entering and managing product links to monitor.
    • Collecting current price, list price, promotions, and stock status on a schedule.
    • Showing price trends and flagging unusual moves.
    • Notifying when price crosses a threshold, volatility exceeds a limit, or stock status changes.
    • Exporting files that spreadsheet software can open.

    That description is not yet a buildable spec. A coordinator agent should first surface ambiguities, for example:

    1. Are the monitoring targets allowed data sources?
    2. Do prices depend on region, SKU, membership, or quantity?
    3. Do promotional prices include claim conditions, spend thresholds, and expiry?
    4. On collection failure, should the UI show last known price or unknown?
    5. Is “low price” a fixed amount, a historical low, or a drop versus a baseline?
    6. Should alerts be real-time or batched on a schedule?

    The model must not guess all of this. Options that affect compliance, business meaning, or cost should be confirmed with the user. Lower-risk items can get a default, but they must be labeled as unconfirmed assumptions.

    3. Overall architecture: separate judgment from reliable execution

    Split the system into six logical layers:

    1. Request intake
    2. ↓
    3. Coordinator and task orchestration
    4. ↓
    5. Specialist agents: research, product, architecture, development, testing
    6. ↓
    7. Controlled tool execution
    8. ↓
    9. Task-state store and artifact storage
    10. ↓
    11. Logs, monitoring, notifications, and approvals

    Models understand, plan, and propose candidates. Orchestration owns state transitions, dispatch, timeouts, and recovery. The tool layer actually reads files, runs checks, collects data, or calls business APIs.

    This split matters. If task state lives only in a chat, a process restart, truncated context, or a failed call can leave the system unable to tell which stage it is in.

    With persisted state, execution continues from records instead of asking the model to “remember what it did.”

    1. Request intake

    The enterprise messaging entry must authenticate, deduplicate, and normalize input. The same message may be delivered twice because of retries, so use a message id or business idempotency key to avoid duplicate projects.

    2. Coordinator and orchestration

    The coordinator decomposes the request, aggregates results, and proposes next steps. It should not hold every operational privilege. Whether development, release, or rollback may start should be decided by explicit process rules.

    3. Tool execution layer

    Model-proposed actions become structured requests, then pass permission checks, parameter validation, and resource limits. Unvalidated text must never run as a system command.

    4. Persistence layer

    Store tasks, messages, artifact references, approvals, execution records, and version links. Large reports, code packs, and screenshots can live in file or object storage; the database keeps URLs, summaries, and checksums.

    4. Role design: every agent needs inputs, outputs, and done criteria

    Role names are labels. Collaboration quality comes from duty boundaries.

    Role Primary inputs Primary outputs Done when
    Coordinator User request, stage artifacts Plan, status summary, approval requests Next stage is executable
    Business research Scenario, user goals, data constraints Research report, risk list Claims are sourced; uncertainty is explicit
    Product design Research, user confirmations Spec, acceptance criteria Feature bounds and error behavior are clear
    Architecture Spec, runtime constraints Module design, data model, API contracts Key technical risks have a path
    Development Confirmed design, work items Code changes, run notes Runs and passes required checks
    Testing Spec, build under test Test report, defect records Results are reproducible; defects are locatable

    Separate context is not total isolation. Each agent keeps its own work history and reads a shared, confirmed project record.

    Testers need not read every development discussion, but they must have the current requirements version, interface contracts, build under test, and how it is deployed. That cuts noise and avoids judgments made without shared facts.

    Cross-role messages should use a fixed shape. The following is a custom contract example, not a product API:

    1. Message ID: msg-104
    2. Task ID: task-208
    3. From: architecture
    4. To: development
    5. Type: artifact-ready
    6. Artifact ref: design doc v3
    7. Key conclusion: collection service separate from alerting
    8. Open issues: stock-field meaning for some sources still unconfirmed
    9. Expected action: persist collection results per the API contract

    Receiving a message is not completing a task. State advances on real artifacts and check results, not on a claim that work is “done.”

    5. Context management: make facts traceable instead of relying on long chats

    Long context helps with complex work; it does not replace engineered memory. As turns grow, early constraints get dropped and wrong conclusions get reused.

    Split context into three classes:

    1. Project facts

    Confirmed requirements, permission scope, budget, runtime environment, and acceptance criteria. Version them. Agents must not overwrite them at will.

    2. Stage artifacts

    Research reports, specs, architecture docs, code changes, and test results. Each artifact should name the requirements version it belongs to so stale design is not used for further coding.

    3. Scratch work

    Drafts, exploratory analysis, and failed attempts. These can be compressed, but summaries must separate confirmed facts, current hypotheses, and open questions.

    When a role task starts, load only what that task needs. Offer retrieval for full history instead of stuffing everything into context.

    Choose models by the real job: stable structured output, correct tool use, detecting missing information, adapting after failure, and finishing within latency and cost limits. A single code-generation sample is not enough to judge long-running collaboration.

    6. Orchestration: state machines, dependencies, and failure recovery

    A basic project flow:

    1. Needs clarification → researching → product design → architecture
    2. → development → testing → pending approval → delivered

    Also use waiting-for-external-input, paused, failed-needs-action, and cancelled.

    Every stage needs three things:

    • Entry: required inputs and approvals.
    • Actions: which tools may run.
    • Exit: required artifacts and checks.

    Some work can run in parallel, for example UI and backend after the API contract is stable. Unconfirmed core requirements must not be fanned out to many roles; that only parallelizes error.

    Illustrative orchestration pseudocode:

    1. task = claim_runnable_task()
    2. if task is empty:
    3. wait for a scheduling event
    4. if dependencies_not_met(task):
    5. mark waiting_on_dependency
    6. else:
    7. acquire execution lease
    8. load confirmed inputs
    9. run constrained role task
    10. persist artifacts
    11. run deterministic checks
    12. if checks pass:
    13. update task state and enqueue follow-on events
    14. else:
    15. record failure and choose retry, rework, or escalate

    Leases stop multiple workers from handling the same task. Operations with external side effects also need idempotency. If an alert is sent but state write fails, retry must not notify the user twice.

    Classify retries:

    • Transient network faults: delayed retry.
    • Bad parameters: fix, then run.
    • Insufficient permission: stop and request authorization.
    • Conflicting requirements: return to clarification.
    • Repeated failure or resource cap: pause and notify an owner.

    For important state updates and outbound messages, persist outbox events so a DB write cannot succeed while follow-on work never fires.

    7. Data and business design for price monitoring

    Price monitoring looks like scraping a few fields. The real difficulty is semantics.

    Split data into products, collection jobs, price snapshots, alert rules, and notification records. A snapshot should at least store:

    • Product id and source id.
    • Collection time and business timezone.
    • Current price, currency, list price.
    • Promotion text and applicability conditions.
    • Stock status.
    • Success/failure and failure reason.
    • Parser-rule version and evidence references.

    Store money in a way that represents decimal values exactly. Missing price must not become zero. Collection failure must not be treated as out of stock, or alerts will be wrong.

    Before comparing products, confirm SKU, unit quantity, and price definition. Items with different sizes or promo terms are not comparable even if page prices look close.

    Prefer authorized APIs or allowed sources. Respect access rules, rate limits, and personal-data protections. Do not treat bypassing access control, CAPTCHAs, or identity checks as an automation feature.

    Anomaly detection and alerts

    Fixed thresholds and relative-move rules are enough to start. For example:

    1. change_ratio = (current_price - baseline_price) / baseline_price

    Before computing, ensure the baseline is valid and greater than zero, and that both records share currency and SKU.

    To cut false positives:

    • Confirm new anomalies across consecutive collections.
    • Cooldown the same alert.
    • Send a recovery notice when conditions normalize.
    • Alert collection failure separately from business anomalies.
    • Merge related anomalies in the UI.

    When promo parsing is uncertain, mark “needs verification” instead of treating a derived figure as a firm transaction price.

    8. Automated development: agents write code without skipping engineering discipline

    A development agent can call constrained coding tools to edit, check, and fix code. Execution ability is not unlimited privilege.

    Advance in small batches:

    1. Create a minimal runnable project.
    2. Implement product management and snapshot storage.
    3. Connect one authorized data source.
    4. Implement trend queries and anomaly checks.
    5. Implement notifications and export.
    6. Add permissions, logging, and error handling.

    Each change should map to a clear task and an independent, reviewable commit. The execution environment should limit filesystem access, network, runtime, and resource use.

    Secrets, production data, releases, and destructive changes need dedicated credential management and approval. Do not put real secrets in prompts, code, or chat logs.

    Parallel work should not share a working directory that can overwrite itself. Prefer isolated workspaces, then merge through unified checks and review.

    9. Testing and acceptance: model opinion is not executable evidence

    The testing agent’s job is to find issues systematically, not to emit a “tests passed” report.

    At minimum cover:

    • Successful collection and historical trends.
    • Missing prices, field-format changes, and unreachable pages.
    • Duplicate product entry.
    • Collection timeouts and retries.
    • Stock going in-stock → out-of-stock → in-stock.
    • Duplicate alerts and cooldown.
    • Recovery after notification send failure.
    • Timezones, money precision, and export.
    • Unauthorized access and sensitive-data exposure.

    Conclusions should include build under test, environment, inputs, actual results, and reproduction steps. Critical acceptance items must become executable checks, not another model’s subjective review of a report.

    Exports must treat untrusted text carefully. If a spreadsheet might interpret a field as a formula, escape it for the target format so opening the file cannot trigger unexpected behavior.

    10. Continuous operation: safety, monitoring, and cost are core capabilities

    External pages, reports, and messages are untrusted. They may contain injected instructions. Distinguish data to analyze from instructions that may change behavior. A command on a collected page must not change tool permissions or leak internal material.

    Recommended controls:

    • Least privilege per role.
    • Human approval for high-risk tools.
    • Audit tool calls, file changes, and key decisions.
    • Redact sensitive data.
    • Cap per-task runtime, retries, and budget.
    • Global pause, cancel, and emergency stop.

    Monitor business outcomes and technical health: task success rate, stage latency, retries, collection failure rate, notification success, pending approvals, and resource use.

    Agent-to-agent talk needs a budget. If several roles loop on the same issue without new evidence, escalate instead of chatting forever.

    For unattended operation, the point is not never failing. It is detecting failure quickly, bounding blast radius, and making recovery auditable.

    11. A practical path: close the loop first, then widen autonomy

    Phase 1: a minimal loop—intake, one data source, price persistence, rule evaluation, and notify. Keep more human confirmation and prove business value.

    Phase 2: role split and structured handoff. Put product, development, and testing on shared task state, with exit criteria per stage.

    Phase 3: recovery, permission isolation, audit, and resource limits. Allow unattended execution only for low-risk tasks.

    Phase 4: multi-project parallelism, richer dependencies, and auto-tuning. Expand only after the original flow already handles duplicate messages, tool failure, process restart, and requirement change.

    Maturity is not role count or uptime. It is delivering verifiable results. Reliable always-on collaboration needs: stateful tasks, bounded roles, contracted handoffs, permissioned operations, evidenced outcomes, recoverable faults, and cost caps. Only then do agents move from demo chat to maintainable engineering productivity.