Building a 24/7 Multi-Agent Development Pipeline: A Practical Guide
This article explains why a single monolithic agent struggles with real delivery work and how a multi-agent architecture turns those problems into engineering ones. It covers a four-layer system design, role contracts, message-bus communication with isolated contexts, dependency-based concurrent scheduling, quality gates, observability and cost control, common pitfalls, and a step-by-step adoption path for running a development pipeline around the clock.
1. Why a Single Monolithic Agent Cannot Handle End-to-End Delivery
In most agent projects of the past two years, the default shape is “one prompt plus a set of tools,” asking the model to handle research, documentation, and coding end to end. This works well in demos, but it breaks down quickly in a real delivery pipeline, exposing three problems.
The first is context pollution. Noise from web pages collected during research and large volumes of error logs from testing pile up in the same context, so later reasoning gets pulled off course by irrelevant information and output quality degrades with each turn.
The second is blurred responsibility boundaries. When one agent must make market judgments and write implementation details, its prompt inevitably grows into a set of conflicting clauses, producing contradictions such as “argue rigorously” and “ship fast” at the same time.
The third is that it is not operable. When a monolithic chain fails, you cannot tell whether research was distorted, the design was flawed, or the code was wrong, so the only option is to rerun everything, which is unacceptable in both cost and time.
The value of a multi-agent architecture is that it converts these three problems into engineering problems: role isolation resolves conflicting responsibilities, independent contexts resolve pollution, and messages plus logs provide observability.
2. Overall Architecture: Orchestrator, Specialists, and Shared State
A multi-agent system built to run for the long term usually has four layers.
- Ingress layer: requests arrive as tickets, documents, or messages, and an “orchestrator agent” performs intent recognition, scope definition, and prioritization.
- Orchestration layer: responsible for task decomposition, dependency management, concurrent scheduling, and failure retries. It is essentially a workflow engine with persistent state.
- Execution layer: specialist agents for market research, product requirements, architecture design, development, testing, and review, each holding its own context and dedicated toolset.
- Support layer: message bus, object storage, logging service, monitoring and alerting, and container platform, providing communication, traceability, elasticity, and observability.
The key design principle is to minimize shared state. Agents do not share contexts directly; they share only structured artifacts (documents, interface definitions, task status) and pass references through messages rather than copying content. This lowers coupling and makes each step’s output a natural input contract for the next.
3. Roles and Contracts: Make Each Agent Responsible for One Thing
A role definition should contain four elements: goal, input contract, output contract, and prohibitions. Take the developer agent as an example:
role: developergoal: produce runnable code based on reviewed architecture and interface definitionsinput:- artifact: architecture.md # must have passed the review gate- artifact: api_contract.yaml # single source of truth for interfaces and data structuresoutput:- artifact: src/**- artifact: unit_tests/**forbidden:- modifying the interface contract on its own- introducing third-party libraries not in the dependency listconstraints:- no single file exceeds the agreed line limit- all public functions must have type annotations and comments
The rule “do not modify the interface contract on your own” matters especially. In practice, a large amount of rework comes from developers casually renaming a field during implementation, which then breaks tests and the frontend as well. Collapsing contract changes into a single explicit review is one of the most effective ways to control rework cost.
4. Communication: Message Bus and Independent Contexts
For agent communication, a combination of publish/subscribe plus a task queue is recommended: events broadcast state changes, and queues dispatch specific tasks point to point. Keep message bodies short, carrying only a task identifier, type, priority, and artifact address.
{"task_id": "T-20260812-0031","type": "code.submit","from": "developer","to": ["tester", "reviewer"],"payload_ref": "storage://build/0031/","trace_id": "run-9f2c"}
The key to implementing independent contexts is “session isolation plus summary write-back.” Each task opens its own session, and when the task ends only a conclusive summary is written to shared state while the raw process stays in each agent’s own logs. This keeps context length under control and makes it easy to replay the whole chain by trace_id.
5. Orchestration and Scheduling: From Serial Pipelines to Dependency-Based Concurrency
Early implementations often hard-coded a fixed serial chain: research finishes, then design, then coding. That is logically safe but wastes a great deal of time on waiting. A better approach is to declare dependencies explicitly so that independent stages run concurrently.
tasks = [{"id": "research", "deps": []},{"id": "prd", "deps": ["research"]},{"id": "arch", "deps": ["prd"]},{"id": "api", "deps": ["arch"]},{"id": "dev", "deps": ["api"], "parallel": 3},{"id": "test", "deps": ["dev"]},{"id": "review", "deps": ["test"]},]def schedule(tasks):done, running = set(), []while len(done) < len(tasks):for t in tasks:if t["id"] not in done and set(t["deps"]) <= done:running.append(t["id"])# hand off to the executor to launch concurrently, and collect failed tasks into the retry queuedone.update(run_and_collect(running))running.clear()return done
Concurrency needs an upper bound. Model calls and code retrieval are both expensive operations, and unbounded concurrency triggers rate limiting and amplifies the avalanche effect of failure retries. In engineering practice, concurrency is usually a configuration item, combined with exponential backoff and circuit breaking.
6. Quality Gates: Automated Delivery Needs Acceptance Criteria
“Run overnight and deliver automatically” sounds appealing, but automated delivery without gates only automates defect production. Four gates are recommended:
- Contract gate: changes to interface definitions and data structures must be confirmed by the review agent, and unconfirmed changes are blocked.
- Static gate: type checks, code style checks, and dependency allowlist validation.
- Dynamic gate: unit test pass rate, coverage of critical paths, and build reproducibility.
- Security gate: sensitive information scanning, dependency vulnerability scanning, and least-privilege checks.
When any gate fails, the task falls back to the corresponding role with a failure summary attached rather than simply rerunning. The fallback information must be specific down to the file and the assertion; otherwise the agent will keep making the same mistake in the same place.
7. Observability and Cost Control
Metrics to collect include per-task duration, model call count and token consumption per role, first-pass rate of gates, number of rework rounds, and end-to-end delivery time. Logs and metrics feed into a unified logging service and monitoring and alerting system, correlated by trace_id, with automatic notifications when anomalies appear.
For cost control, tasks can be tiered: deterministic steps (format conversion, field validation) go to rules or a smaller model, and only steps that require judgment use a high-capability model. Caching and reusing repeated artifacts also avoids regenerating the same research over and over.
8. Common Pitfalls and How to Avoid Them
- Roles that are too fine-grained: once the number of agents exceeds what is necessary, communication and scheduling overhead outweighs the benefits. Five to eight roles are usually enough to cover a development chain.
- Summary distortion: overly brief write-back summaries leave downstream agents missing key constraints. A summary should always contain three sections: conclusions, constraints, and open questions.
- Unlimited autonomy: human confirmation points must be retained, especially for scope changes, writes to external resources, and release actions.
- Ignoring idempotency: task retries require idempotent artifact writes, otherwise duplicate files and dirty data appear.
9. Suggested Adoption Path
Start with a two-role loop (coding plus testing) to validate the messaging and gate mechanisms. Then add requirements and design roles and make contracts explicit. Next, introduce concurrent scheduling and cost tiering. Finally, connect monitoring, alerting, and human confirmation points to gradually form a development pipeline that can run 24/7. Baidu AI Cloud can serve as the underlying foundation for such an architecture through general capabilities such as container platform, message queue, object storage, and log monitoring, letting teams focus their energy on role design and gate rules themselves.
