Building a 7×24-Hour Automated Delivery Pipeline with Multi-Agent Systems
This article explores the engineering practices for building a 7×24-hour automated delivery system using a multi-agent architecture. It covers role orchestration, context isolation, message contracts, long-task stability, execution layer sandboxing, observability, and cost governance, providing a comprehensive guide to achieving predictable and resilient unattended operations.
1. The Starting Point: The Ceiling of Single-Agent Capabilities
When teams first attempt to automate research and development, they often reach the same conclusion: the demo looks impressive, but it is unusable in production. The reason is straightforward. A single agent is required to simultaneously act as a requirements analyst, architect, coder, and tester. Its system prompt gets stuffed with conflicting behavioral guidelines, and its context window is repeatedly washed out by logs, errors, and retrieval results. After dozens of rounds, early constraints are diluted and forgotten.
Splitting roles is the first step to solving this problem. The core benefit of a multi-agent architecture is not that it is “smarter,” but rather the behavioral predictability brought by single responsibility and the anti-forgetting capability enabled by context isolation. Each agent faces only one goal, one set of acceptance criteria, and a limited context. The chain is maintained by an external scheduler.
2. Role Orchestration: Mapping the R&D Workflow to an Agent Topology
A functional agent legion typically includes the following roles. It is recommended to organize them in a two-tier structure of “Orchestrator + Professional Roles”:
- Orchestrator: The single external entry point for requirements. It is responsible for task decomposition, dispatching, progress aggregation, and conflict resolution, but does not directly produce deliverables.
- Market Research Agent: Collects public information and competitor dynamics, outputting structured conclusions and source lists.
- Product Agent: Transforms research conclusions into requirement documents, clarifying feature boundaries, acceptance criteria, and priorities.
- Architecture Agent: Provides module division, data models, interface contracts, and deployment forms.
- Development Agent: Implements code according to interface contracts. It is the only role allowed to write to the file system.
- Testing Agent: Writes and executes test cases based on acceptance criteria, producing a defect list to return to the Development Agent.
For topology, a “star scheduling + local bus” approach is recommended. The Orchestrator connects to each role in a star pattern to ensure a clear control plane. Roles exchange artifacts through shared message topics, avoiding context pollution caused by full broadcasting.
agents:- id: orchestratorrole: Task decomposition and arbitrationtools: [message_bus, task_board]- id: devrole: Coding implementationtools: [code_workspace, shell, message_bus]max_retry: 3- id: qarole: Test cases and defectstools: [test_runner, message_bus]channels:- name: artifacts # Read-only broadcast for deliverablessubscribers: [orchestrator, qa]- name: defects # Defect feedback loopsubscribers: [dev, orchestrator]
3. Context Isolation and Message Contracts
In multi-agent systems, message formatting is the easiest thing to lose control over. Free text experiences semantic drift after three rounds of transmission. Therefore, you must define a structured message contract: task ID, source, destination, type, payload, expected artifact path, and deadline. The payload should only contain references (e.g., object keys in object storage, code repository branch names) rather than the full text. This prevents the context size from expanding as the workflow progresses.
def dispatch(task_id, src, dst, kind, payload_ref, deadline):msg = {"task_id": task_id, "src": src, "dst": dst,"kind": kind, "ref": payload_ref, "deadline": deadline,"trace": get_trace_id() # End-to-end tracing}bus.publish(kind, msg) # Asynchronous message queue delivery
Accompanying storage layering is equally important: structured artifacts go to object storage, task states go to a database, event streams go through a message queue, and runtime logs go to a logging service. By separating these four layers, any agent can recover from the state layer upon restart without relying on memory.
4. Long Task Stability: Checkpoints, Idempotency, and Self-Healing
Long workflows spanning dozens of rounds will inevitably encounter timeouts, rate limits, and tool errors. From an engineering perspective, these should be treated as distributed tasks, not as a single long conversation:
- Explicit State Machine: A task can only be in one state: “To Do / In Progress / Pending Review / Completed / Failed”. Transitions are event-driven, and agents are prohibited from skipping steps autonomously.
- Checkpoint Persistence: At the end of each phase, write the artifact hash and version number. When re-running, compare the hash first; if it matches, skip the step.
- Idempotent Design: Write operations carry an idempotency key. Duplicate deliveries do not produce duplicate records.
- Bounded Retries and Degradation: Set an upper limit on retry attempts with exponential backoff. If the limit is exceeded, degrade to “output an issue report” rather than failing silently.
- Link Guard: The Orchestrator maintains a task board. If no response is returned after a timeout, it triggers a reminder. If there is no response twice in a row, the subtask is decomposed again.
5. Execution Layer: Enabling Autonomous Local Coding Capabilities
The Development Agent should not rely on remote APIs, but instead drive a local AI coding tool running inside a container. It possesses an independent workspace, a writable branch, and the ability to execute test commands, autonomously deciding the loop of “read code – modify code – run tests – fix errors”. The key constraint is sandboxing: the container platform allocates an independent namespace, mounts only the task workspace, routes egress traffic through a whitelist proxy, and injects secrets via environment variables without persisting them to disk.
# Standard action sequence for the Dev Agent inside the container (illustrative)git checkout -b task/${TASK_ID}run_coding_agent --task-file /workspace/task.md --max-turns 40run_tests --suite smoke && git commit -am "task ${TASK_ID}"git push origin task/${TASK_ID}
6. Implementation Paradigm: Scheduled Collection and Anomaly Alerting System
Consider a “competitor price monitoring” system as an example. It covers almost all elements of multi-agent automation:
- Collection Layer: Scheduled tasks scrape target pages or APIs based on a schedule, applying rate control and failure backoff. Raw responses are compressed and archived to object storage.
- Cleaning Layer: Unifies the field model (price, original price, discount, stock status, collection time), normalizes units, and deduplicates. Anomalies are flagged rather than discarded directly.
- Storage Layer: Time-series tables are partitioned by day, retaining raw snapshots to support traceability.
- Analysis Layer: Calculates moving averages and volatility rates, identifies drastic fluctuations using percentile thresholds, and outputs trend sequences.
- Alerting Layer: When rules for low prices, drastic fluctuations, or out-of-stock items are triggered, it pushes message cards via enterprise collaboration platform APIs, including jump links.
- Export Layer: Generates spreadsheet files periodically for manual review.
Different agents are responsible for implementing and self-testing each layer. The Testing Agent verifies against an acceptance table of “given sample input – expected fields and threshold output”. Defects are looped back to the Development Agent for repair, forming a closed loop.
7. Observability and Cost Governance
The bills and failures of an automated legion hide in the details. It is recommended to uniformly inject a trace_id to link every model call, tool invocation, and message delivery into a single trace. Once logged into the logging service, configure monitoring alerts for three metrics: failure rate, latency, and token consumption per task. On the cost side, set per-task budget caps and concurrency limits to prevent infinite loops from amplifying consumption. For high-frequency repetitive tasks, cache intermediate artifacts.
8. Common Pitfalls and Acceptance Checklist
- Pitfall 1: Excessive Role Granularity. When the number of roles exceeds eight, the scheduling overhead outweighs the benefits. Merge them into four or five first before iterating.
- Pitfall 2: Messages Carrying Full Text. The context expands rapidly; ensure payloads are reference-based.
- Pitfall 3: No Acceptance Criteria. The Product Agent must output verifiable acceptance tables, otherwise the Testing Agent can only evaluate subjectively.
- Pitfall 4: Excessive Permissions. The Development Agent should not be given production credentials or unrestricted network access by default.
Confirm the following items before going live: task states can be persistently recovered, message formats are validated by contracts, retries are bounded and idempotent, artifacts have versions and hashes, the entire link is traceable, budgets and concurrency have caps, and failures trigger alerts. Meeting these seven conditions gives this legion the foundation to operate unattended 7×24 hours.
