Engineering Guide to Always-On Multi-Agent Collaboration
This article explains how to turn one-off LLM answers into a durable multi-agent delivery system: verifiable requirements, role isolation, a persistent task state machine, external memory, constrained code execution, and 24/7 operations with retries, budgets, and safety boundaries. A competitor price-monitoring system is used as a running example.
From one-shot answers to continuous delivery
Generating a requirements document is easy. Getting multiple agents to research, design, implement, test, and prepare a release is an engineering problem.
A single chat tests understanding of the current prompt. Long-running work also needs external state, reliable tool execution, task dependencies, and acceptance checks. A long context does not mean the model permanently remembers the job, and “it is still generating” is not the same as “the work is progressing.”
A sustainable multi-agent system needs at least four capabilities:
- Decomposable work: turn vague goals into units with inputs, outputs, and acceptance criteria.
- Traceable process: record who did what, which tools ran, and which artifacts were produced.
- Recoverable failure: after restarts, timeouts, or errors, resume from the last valid state.
- Constrained permissions: each role sees only needed data and tools; high-risk actions require approval.
Always-on operation is not an infinite model loop. It is a system that can advance under explicit rules without constant human babysitting, and that pauses when the situation is uncertain or high-risk.
The rest of this article uses a competitor price-monitoring system for e-commerce as a running example. Configurations and pseudocode are illustrative only and do not describe a real product API.
Write business goals as testable requirements
A request such as “monitor competitor prices and notify me on anomalies” is not ready for implementation. Different agents will disagree on “competitor,” “price,” and “anomaly,” and ship something that looks complete but is unusable.
A coordinator agent should fill in the following.
1. Targets and matching rules
Specify the catalog, SKUs, channels, regions, and access methods. Different sizes, pack counts, colors, or bundles must not be treated as the same SKU by default.
Matching works best in two stages:
- On first ingest, build candidate mappings from name, spec, and seller data.
- Have a human confirm critical mappings before continuous collection.
Unreliable matches poison trends and alerts. Automation should not amplify ambiguity at the front door.
2. Price semantics and inventory states
“Price” may mean list price, strikethrough reference, promo price, member price, or a conditional discount. Store those fields and their conditions separately; do not collapse every number into a single “final deal price.”
Inventory should distinguish:
- In stock
- Out of stock
- Inventory not provided on the page
- Fetch failed; unknown
Unknown is not out of stock; a failed fetch is not a vanished price. Keep these states independent in the data model and in alerting.
3. Cadence and notifications
Frequency should reflect business latency, source limits, and cost. Not every SKU needs high-frequency collection; schedule by priority.
Alerts should specify:
- How low-price thresholds are set
- Which baseline volatility is measured against
- Whether consecutive confirmations are required
- Dedup / mute windows
- Recipients and channels
- What happens if delivery fails
4. Turn requirements into an acceptance list
Examples:
- Persist SKU and source identifiers
- Fetch reachable price and inventory on the agreed schedule
- Show history and mark missing data
- Emit events for low price, sharp moves, and stock-outs
- Send events to a team collaboration channel
- Export a generic spreadsheet
- Query collection failures and last successful fetch time
Each item needs test data and a judgment method. “Feature done” without acceptance criteria cannot support reliable automated delivery.
Roles: split by duty, not by agent count
Multi-agent value comes from clear ownership and isolated context, not from more agents.
| Role | Primary duty | Core artifacts |
|---|---|---|
| Task coordinator | Clarify needs, split work, manage dependencies, assemble delivery | Plan, status reports |
| Business analyst | Business definitions, compliance bounds, usage flows | Business notes, constraint list |
| Product designer | Features, interaction, acceptance | Spec, acceptance checklist |
| Architect | Module boundaries, data model, API contracts | Architecture notes, data dictionary |
| Developer | Change code in an authorized environment and run checks | Diffs, execution logs |
| Tester | Independently verify happy paths and failures | Test report, defect list |
| Operator | Deployment conditions, metrics, recovery | Runbook, ops notes |
Early on, merge some roles to cut coordination cost. Keep implementation and acceptance somewhat independent so one actor does not propose the design, write the code, and declare everything passed.
Contexts should not be fully sealed. Each role keeps its own working notes and shares confirmed requirement versions, API contracts, and an artifact index.
Orchestration: a persistent state machine owns the truth
Free-form agent chat easily produces duplicated work, mutual waiting, and nobody owning acceptance. Keep authoritative task state in the orchestrator.
1. Task lifecycle
Useful states include:
- Pending
- In progress
- Waiting for external input
- Waiting for review
- Completed
- Failed, retryable
- Terminated
Keep “waiting for review” separate from “completed.” Submitting code is not acceptance; a tool finishing is not proof the output meets quality bars.
2. Dependencies
A typical chain:
Requirements clarification → confirmation → architecture and API design → module development → integration tests → human review → controlled deploy
Parallel branches are fine after contracts stabilize—for example collection vs. trend UI. Parallelizing before contracts are stable causes rework.
3. Persist a full task record
Illustrative structure:
Task:id: price-rules moduleowner: developerstatus: pendinginput versions: confirmed requirements, data contractpredecessor: data model confirmedexpected artifacts: rule implementation, tests, usage notesacceptance:- missing prices must not fire low-price alerts- different currencies must not be compared directly- reruns must not create duplicate alert eventsretry: limited; then humanpermissions: named code dirs and test env
Store state outside the chat. On completion, persist artifacts and verification results before flipping status, so a crash cannot leave “done” with missing outputs.
Use time-bounded execution leases. Workers heartbeat; if a lease expires, the orchestrator inspects partial results and may reassign. That reduces tasks stuck forever after a worker disappears.
Context: external memory beats an endless transcript
Long jobs fail when early constraints are overwritten or old versions leak into new implementations.
Split information into three layers.
1. Shared facts
Versioned, confirmed items:
- Goals
- In-scope / out-of-scope
- Field definitions
- API contracts
- Permission constraints
- Current acceptance criteria
All roles treat this as source of truth. Changes need reason, blast radius, and approval status.
2. Role workspaces
Analysis, experiments, failure notes, and open questions stay here. They help the worker continue but must not auto-promote to global fact.
A developer saying “a cache might help latency” is a hypothesis, not an approved architecture requirement.
3. Artifacts and evidence
Specs, diffs, tests, logs, deploy records. Coordinators should cite artifacts, not accept “done” in prose.
Handoff template:
Handoff:completed:artifacts:evidence:open issues:next owner actions:current requirement and API versions:
Summaries compress context; they do not replace evidence. Keep searchable records of key decisions, failures, and test results.
Automated development: the model proposes; the system constrains
A developer agent may call local coding tools only through a controlled execution layer, not with unrestricted host access.
1. Isolated workspaces
Give each task its own directory or sandbox so roles do not edit the same files. Merge only at integration under an explicit process.
Limit:
- Readable/writable paths
- Network reach
- Allowed action types
- Wall-clock per run
- Resource use
- Credential visibility
Production secrets must not enter model context, code, or logs.
2. Controlled change flow
Recommended order:
Read task and existing code → propose a plan → edit files → static checks → tests → summarize diff and risk → submit for review
Deletions of large trees, schema changes, ACL changes, and production deploys need extra approval.
3. “Checks passed” is not “business correct”
Automated checks only prove nothing failed in their coverage.
Price-rule tests should at least cover:
- Normal prices and stock
- Nulls, malformed and illegal values
- Currency or SKU mismatches
- Unmet promo conditions
- Duplicate collection and duplicate notify
- Timeouts and temporary source outages
- Time boundaries and time zones
If page structure or input format changes, collection should fail closed, not feed unverified numbers into calculations.
Data path for price monitoring
Six modules:
Ingest → normalize → history store → rules → notify → query/export
1. Ingest: authorization and compliance first
Prefer authorized APIs, partner files, or permitted public sources. Rate, scope, and retention must follow applicable rules.
Bypassing access controls, skipping verification, or harvesting non-public data must not be the default path. If a source is unreachable, report the limit and change the plan; do not let agents expand privileges on their own.
2. Normalize: keep numbers and meaning
A price record should include:
- Internal product id
- Source id
- SKU
- Collection time
- Amount and currency
- Promo conditions
- Inventory state
- Data-quality flag
- Pointer to raw record
Use decimal fixed-point or integer minor units so binary floats do not skew thresholds.
Keep limited raw data for audit, with minimization and retention limits.
3. Rules: separate business alerts from data faults
Volatility:
rate = (current valid price − baseline) / baseline
Only if the baseline is valid and > 0, and SKU, currency, and promo semantics match.
Baseline may be last valid price or a window median. The product requirement must choose; the model must not pick arbitrarily.
Business events: low price, moves, stock changes. Data-fault events: consecutive fetch failures, stale records, bad fields. Different types so users do not confuse pipeline failure with the market.
4. Notify: persist events for traceability
On a rule hit, persist an event, then send. The notifier records attempts, status, and errors.
Do not assume exactly-once across modules. Allow retries and use unique event ids plus dedup.
Support mute and recovery: do not page on every poll while a SKU stays out of stock; emit a separate recovery event when it returns.
5. Query and export: charts must not hide holes
Mark missing and invalid intervals. Do not linearly interpolate long gaps as if price were stable.
Exports should include time, SKU, currency, and quality flags. Sanitize external text so spreadsheet software cannot treat it as formulas.
Always-on: scheduling, recovery, and budgets—not infinite self-loops
Two independent schedulers:
- Business jobs: collection, rules, reports
- Agent jobs: development, repair, analysis, review
Stable pipelines need not call a model every time. Deterministic work (compare prices, cron, dedup) belongs in code. Models are for analysis, incident explanation, and code maintenance.
1. Bounded retry and backoff
For transient faults, increasing wait plus jitter avoids thundering herds.
For missing permission, bad input, or conflicting requirements, retrying is usually useless—route to pending or human review.
2. Checkpoints
Save at key stages:
- Task status
- Artifacts so far
- External side effects already applied
- Remaining steps
- Last error and recovery hint
On resume, check whether side effects already happened before redoing them, or you will double-write, double-notify, or double-deploy.
3. Budgets and stop conditions
Cap wall time, model calls, tool calls, and resources. Near the cap, require a progress dump and blockers instead of unbounded retry.
Stop when:
- Acceptance passes
- Retry budget is exhausted
- Extra permission is required
- A serious security issue appears
- Critical inputs are missing
- Projected cost exceeds authorization
A 24/7 system must be able to stop safely.
Security: untrusted content is data, not instructions
Price pages, uploads, messages, and comments can contain jailbreak-like text. Treat them as data. External “ignore the rules” text must not change permissions or trigger extra actions.
Engineering controls:
- Structurally separate task instructions from external data
- Enforce permissions and parameters at the tool layer
- Require explicit approval for dangerous actions
- Limit sensitive reads and outbound sends
- Audit requests, authorizations, and artifacts
Prompts can describe boundaries; they do not replace an authorization system. The execution layer must block overreach even if the model is wrong.
Observability and what “done” means
Watch at least:
- Tasks: completion rate, wait time, retries, timeouts
- Data: fetch success, missing fields, freshness, matching errors
- Notify: send success, latency, duplicates, muted events
- Resources: model spend, runtime, storage growth, compute
Correlate ids across tasks, tools, records, and events so a bad alert traces to the fetch, the rule, and the run.
Delivery is more than a repo. A complete package includes:
- Confirmed requirements and acceptance results
- Architecture and data dictionary
- Code and dependency notes
- Tests and known limits
- Config and permission requirements
- Deploy, rollback, and recovery
- Monitoring and alert config
- Retention and cleanup policy
Production deploys, sensitive permissions, and important business rules still need human review.
Implementation path: close the loop, then scale
Phase 1: one source, one price definition, one alert rule; run ingest → store → decide → notify → query.
Phase 2: coordinator, developer, independent tester; task state, artifact handoff, failure recovery.
Phase 3: more SKUs, sources, notify policies; isolation, budgets, ops metrics.
Phase 4: add roles and parallelism only where bottlenecks justify it. Optimize delivery quality, recovery, and total cost—not agent count.
Multi-agent collaboration does not replace engineering constraints. It embeds reasoning in a stateful, evidenced, permissioned runtime: programs for deterministic work, models for hard analysis, authorized people for high-risk decisions. That is how a demo becomes an always-on capability.
