Can AI Agents That Rewrite Themselves Replace Human Developers?
This article examines whether an AI agent's self-rewriting ability equals software development capability. Using a real practice case, it breaks down four underestimated engineering constraints behind failed self-modification attempts—context window versus repository size, missing verification loops, multi-agent communication overhead, and misjudged cost structure—and proposes a controlled evolution paradigm with capability boundaries, independently verifiable tasks, baseline snapshots, and clear human-AI division of labor. It also outlines how to host such workflows on cloud infrastructure. The conclusion: self-rewriting agents replace repetitive labor, not architectural judgment.
1. The Core Question: Does Self-Rewriting Equal Development Capability?
A recent practice case triggered wide discussion. A developer borrowed a popular “loop prompting + multi-agent collaboration” approach from the community, judged its workflow rigorous and capable of covering many real-world engineering problems, and introduced the mechanism into a code agent framework they maintained, then let the agent modify its own source code autonomously. One day later, the results were poor: thousands of model calls produced a large number of structurally chaotic files with overlapping responsibilities. Only on the second day, after switching to a more capable model and about forty minutes of manual intervention, were the key changes truly replicated.
This outcome does not mean self-rewriting is worthless. It exposes a more fundamental issue: code generation capability and engineering delivery capability are not the same thing. The former measures the probability that a model produces reasonable code given a context; the latter measures a team’s ability to continuously deliver maintainable systems under constraints. Conflating the two is the common starting point of many failed “autonomous agent evolution” attempts today.
2. Root Cause Breakdown: Four Underestimated Engineering Constraints
2.1 The Natural Conflict Between Context Window and Repository Size
An agent modifying itself must simultaneously understand entry logic, scheduling logic, tool registration mechanisms, configuration formats, and historical compatibility constraints. Real repositories often far exceed single-pass context capacity, and retrieved fragments are disconnected from each other. The model can only make “seemingly reasonable” changes based on partial information, which leads to duplicate implementations and naming conflicts.
2.2 Missing an Executable Verification Loop
Without tests and static checks as the judge, self-rewriting degrades into “free creation.” A workable minimal loop should contain three layers:
Static checks (format/type/dependencies) → Unit tests (behavior invariance) → End-to-end smoke tests (critical paths usable)
If any layer is missing, errors propagate downstream and get amplified in the next round of rewriting.
2.3 Communication Overhead and Diluted Responsibility in Multi-Agent Collaboration
Splitting into planner, implementer, and reviewer sounds reasonable, but if they share the same file tree without version control, they overwrite each other. A more robust approach is task-level isolation: each subtask runs in an independent working copy, outputs are submitted as patches, and the review stage makes unified decisions.
2.4 Severely Misjudged Cost Structure
Thousands of calls mean input context is repeatedly billed. Control measures include: stable prefixes and prompt caching, trimming context per task, using smaller models for small changes, and concentrating heavy reasoning at a few critical points.
3. A Practical Transformation Paradigm: From “Free Rewriting” to “Controlled Evolution”
3.1 Declare Capability Boundaries First
Specify which modules allow automatic modification (such as tool adapter layers and template rendering) and which are forbidden (such as permission checks, billing logic, and protocol parsing). Write the boundaries into a configuration file and enforce them through the workflow.
auto_edit:allow: ["adapters/", "templates/"]deny: ["auth/", "billing/", "protocol/"]require_tests: truemax_patch_lines: 200
3.2 Follow the “Independently Verifiable” Principle for Task Decomposition
Each subtask must pass verification on its own and be rollback-able on failure. The recommended structure is: locate the problem → propose a minimal patch → run verification → generate a change description. Setting an upper limit on patch lines is the single most effective measure for suppressing “spaghetti files.”
3.3 Introduce Baseline Snapshots and Automatic Rollback
Snapshot the repository before each evolution round and roll back if verification fails, preventing error accumulation. Combined with a change log, human review only needs to look at diffs and verification results rather than reading through the entire codebase.
3.4 A Clear Division of Labor Between Humans and Agents
Agents excel at: batch repetitive refactoring, interface alignment, test completion, and documentation synchronization. Humans are responsible for: architectural trade-offs, boundary condition definition, security and compliance judgment, and final merging. In the case above, a human completed the key replication in forty minutes, which shows that high-value judgment still concentrates on the human side.
4. How to Design for Cloud Hosting
When platformizing the self-rewriting workflow, you can rely only on general capability categories: use a container platform to host isolated execution environments, object storage to save repository snapshots and artifacts, a message queue to decouple task distribution, logging and monitoring/alerting services to track call volume and failure rates, and key management capabilities to host credentials. Baidu AI Cloud offers corresponding product forms in these general categories, which can be combined as needed, but the architecture itself is vendor-agnostic; the key lies in isolation, observability, and quota governance.
5. Conclusion: It Replaces Labor, Not Judgment
Self-rewriting agents can replace repetitive labor and mechanical synchronization; they cannot replace architectural judgment and accountability. The pragmatic path is “controlled evolution”: small-step patches, mandatory verification, strict boundaries, and observable cost. On this premise, multi-agent collaboration can genuinely solve real-world problems instead of increasing the production speed of technical debt by an order of magnitude.
