Multi-Agent Collaboration for Two Months: A Post-Mortem on Why We Rewrote Everything
This article shares lessons from a two-month experiment that used AI agents as the primary force for building software. Despite roughly 6,050 commits and 800,000 lines of code, the project was ultimately rewritten. The core finding is that when output speed far outpaces architecture convergence, code volume becomes a liability. The article walks through two key architectural shifts—moving from internal calls to message- and document-based handoffs, and adding a chief design layer above the orchestrator—and explains the four metrics that triggered the rewrite. It closes with a reusable engineering playbook covering fixed roles, templated handoff contracts, automated quality gates, corrected metrics, and predefined rewrite triggers.
1. Background and Final Outcome
This was a long-cycle software construction experiment in which AI agents served as the primary source of productivity. Over two months, the repository accumulated roughly 6,050 commits, and the codebase grew to 800,000 lines. By any traditional measure, this was a “high-output” project: dense commits, fast delivery, and broad module coverage.
Yet the final decision was to rewrite everything from scratch.
This outcome does not mean agent collaboration is worthless. Instead, it exposes a more fundamental problem: when output speed far exceeds the rate at which the architecture converges, code volume turns into a liability. Of the 800,000 lines, only a small fraction was actually verified, reused, or maintained over the long term. A large portion consisted of temporary adapter layers, duplicate implementations, and defensive branches generated just to make a given agent “pass” within its current context.
It is worth stressing that this article does not compare the capabilities of any specific AI coding tool. Instead, it abstracts a general engineering methodology for multi-agent collaboration. Regardless of which class of AI coding tool or self-built agent orchestration framework you use, the problems below will surface in the same way.
2. The First Architectural Leap: From Internal Calls to Messages and Documents
Early on, agents interacted through an “internal call” model: one agent directly triggered another agent’s capability within its own execution flow, treating the other as a callable function or sub-process.
This model is extremely efficient when there are few agents and tasks are linear, but its weaknesses amplify with scale:
- Tight coupling. Any change to the callee’s prompt, output format, or internal strategy immediately breaks the caller.
- Context pollution. Every layer in the call chain stuffs upstream intermediate conclusions into its own context, tokens balloon rapidly, and attention is diluted.
- Failures cannot be attributed. When any link in the chain fails, it is hard to tell whether the cause is a comprehension error, a format error, or an execution error.
- No asynchrony. All agents are forced to wait synchronously, and long tasks block the entire chain.
Midway through the project, a critical change was made: internal calls were removed and replaced with message passing plus document handoffs. Each agent became an independent product or model instance, residing long-term in its own area of responsibility, communicating and handing off work results only by sending messages and writing shared documents.
Expressed as a schematic structure, it can be written as:
# Shared handoff area (pseudo-structure, illustrative only)/handoff/inbox/<agent_id> # Pending messages for a specific role/specs/<feature>.md # Requirements and constraints (single source of truth)/contracts/<module>.md # Module's external contract: inputs, outputs, error codes/decisions/ADR-00x.md # Architecture decision records/evidence/<task_id>.json # Verification evidence: commands, output summaries, pass rates
This change delivered four direct benefits:
- Contractualization. Handoff content changed from “a piece of natural-language request” to “a versionable document,” and interface changes go through review rather than implicit conventions.
- Observability. All cross-role interactions are persisted as messages and documents, naturally forming an audit trail, and problems can be traced back to a specific handoff point.
- Decoupling and replaceability. Any role can be replaced or rewritten as a whole, as long as it follows the same contract, and the other roles are unaffected.
- Asynchronous parallelism. Roles queue through inboxes, and long tasks no longer block the whole system.
The cost is equally clear: documents become the system bottleneck. If documents are written unclearly, agents will each fill in their own imagined gaps, and conflicts erupt downstream in a concentrated way. Therefore, documents must have mandatory templates and a minimum field set; a handoff missing fields is considered non-compliant.
3. The Second Leap: Adding a Chief Design Layer Above the Orchestrator
In the later stage, a second layer grew into the architecture: a chief design role was added above the orchestrator agent.
- The orchestrator agent is responsible for “driving things to completion”: decomposing tasks, dispatching, aggregating, and gating.
- The chief design role is responsible for “what things should grow into”: defining the domain model, module boundaries, dependency direction, naming and error semantics, and acceptance criteria.
The reason layering was necessary is that the orchestrator’s optimization goal is throughput and completion rate, so it naturally tends to accept any solution that runs; architectural consistency, however, requires a role that produces no business code and is responsible only for structure and constraints. The two have different objective functions, and putting them in the same layer inevitably forces mutual compromise.
The chief design layer’s output is not code but four kinds of artifacts: domain and boundary definitions, module contracts, architecture decision records, and acceptance checklists. It holds veto power over downstream work: handoffs that do not conform to contracts can be rejected rather than entering the implementation phase.
4. Why a Rewrite Was Necessary After 800,000 Lines
The basis for the rewrite decision was not code volume, but four metrics deteriorating simultaneously:
- Rising duplicate implementation rate. The same capability appeared in multiple modules as several semantically similar but detail-different implementations.
- Contract drift. Documentation no longer matched actual behavior; agents implemented according to the docs, so integration inevitably failed.
- Non-linear change cost. Modifying a foundational concept required synchronized changes in many places, and the regression scope was unpredictable.
- Missing verification evidence. Most modules had only “it runs” evidence, with no pass evidence under boundary conditions.
At this point, the marginal return of continued incremental patching was lower than a rewrite, because the root of the problem lay in the structure rather than local implementation. The rewrite did not start from zero: documents, contracts, decision records, and verification methods were fully retained; what was discarded was the implementation code lacking structural constraints. This was also the most valuable output of the experiment—a reusable collaboration protocol.
5. A Reusable Engineering Playbook
Fix roles and responsibilities. Set up at least five types of roles—requirements clarification, architecture design, implementation, verification, and orchestration—residing long-term without frequent swapping, so each role accumulates contextual expertise in its position.
Template the handoff protocol. Each contract should contain at least: goal, input structure, output structure, error and exception semantics, non-goals, and acceptance commands. Example:
## Contract: <module_name> v0.x- Goal:- Input: field / type / constraint- Output: field / type / constraint- Error semantics: error code + trigger condition + caller response- Non-goals: what it explicitly does not do- Acceptance: executable command + expected result
Automate quality gates. Commits must carry verification evidence, and gates should cover at least static checks, unit tests, contract consistency checks, and duplicate implementation detection; missing evidence means merge is rejected. Container platforms can help ensure environment consistency, and logging services with monitoring alerts can observe the failure distribution of long tasks.
Correct the metrics. Move “lines of code” and “number of commits” from efficiency metrics to risk metrics, and adopt contract pass rate, rework rate, duplicate implementation rate, and change impact radius as core measures.
Define rewrite triggers upfront. Write the rewrite criteria at project kickoff to avoid sunk costs holding decisions hostage.
6. Conclusion
The two-month experiment ended in a rewrite, but the real conclusion is not pessimistic: the bottleneck of multi-agent collaboration lies not in model capability but in collaboration protocols and architecture governance. Changing internal calls into a loosely coupled, message- and document-driven structure, adding a chief design layer above the orchestrator that writes no business code, and then constraining output with automated gates and evidence-based acceptance—only then can the output speed of an agent cluster be turned into code assets that evolve sustainably. If you need a runtime foundation to carry this kind of pipeline, general capabilities on Baidu AI Cloud—such as container platforms, object storage, message queues, and logging and monitoring—are sufficient to meet the needs of environment isolation, artifact retention, and full-chain observability.
