Introduction: Trapped in the Cage of Language
Today's AI agents may orchestrate tools and coordinate tasks, but they remain fundamentally caged: no matter how elaborate the prompts or how rich the skill library, if the underlying harness breaks down, the agent is helpless. Existing self-evolution methods mostly tinker with "what the agent thinks" and "what it calls"—but true self-improvement requires touching the source code itself. This is the premise of MOSS.
> Note (Harness): The underlying code that supports an agent's operation, managing lifecycle, tool invocation, and state transitions—essentially the agent's "skeleton and meridians."
From Prompt Patching to Source-Level Rewriting
Previous self-evolution methods are "text adapters": the model edits prompts or adds API calls when performance degrades. The MOSS authors argue this treats symptoms, not causes. MOSS opens the door to source-level rewriting, directly performing surgery on the agent's own driver code.
| Dimension | Traditional Self-Evolution (e.g., Voyager) | MOSS | | :--- | :--- | :--- | | Modification target | Prompts, tool descriptions, task flows | Harness source code, routing logic, hook ordering | | Theoretical ceiling | Bounded by preset framework | Turing-complete (any logic can, in principle, be modified) | | Stability | Prone to context drift | Highly deterministic—code is truth | | Evolution depth | Cosmetic fixes | Marrow-level reconstruction |
> Note (Turing-completeness): Any computable logical change can be expressed via code, so MOSS can in principle implement any such modification.
MOSS's Seven-Stage Evolution Pipeline
MOSS follows a strict deterministic state machine:
1. Failure Anchoring — Collect evidence of real-world failures:
\(E_{fail} = \{(\text{Input}, \text{Trace}, \text{Error})\}\)
It traces errors back to the specific lines of harness logic responsible.
2. External Delegation — An Evo-Agent runs on the host machine with high privileges (file read/write, code compilation), keeping the main agent's context clean.
3. Evolution Planning — The Evo-Agent drafts a fix plan: reversed message routing? mismatched async locks?
4. Diff Generation — Produces a real code patch, like a git diff.
5. Ephemeral Verification — The patch is tested in a temporary container against the previously failed cases. It passes only if \(R_{fix} = 100\%\) with no regressions.
6. Human Audit — All modifications are transparent; humans can review exactly what the agent changed via the interface.
7. In-place Swap — A daemon smoothly replaces the old container with the new one:
\(C_{old} \xrightarrow{\text{health-check}} C_{new}\)
If the new version fails health checks, rollback is triggered automatically.
Results: A Striking Leap on OpenClaw
On the OpenClaw benchmark (a production-grade agent evaluation harness), measured by a utility function \(G = \frac{S_{post} - S_{pre}}{T_{cycles}}\):
- Initial score: 0.25 (broken routing logic throughout)
- After evolution: 0.61 — a single self-rewrite cycle dramatically transformed the agent.
- Title: MOSS: Self-Evolution through Source-Level Rewriting in Autonomous Agent Systems
- arXiv ID:
2605.22794 - Release date: May 21, 2026
- Authors: Qianshu Cai, Yonggang Zhang, Xianzhang Jia, Wei Xue, Jun Song, Xinmei Tian, Yike Guo
- Institutions: University of Science and Technology of China (USTC), Hong Kong University of Science and Technology (HKUST), Hong Kong Baptist University (HKBU)
Discussion: When AI Can Revise Its Own Contract
MOSS marks a shift from agents that "obey the contract" to agents that "revise the contract"—a precursor to self-organizing systems. To prevent misuse, MOSS introduces a Syntax Barrier and human gating, ensuring evolution stays on course and remains fully auditable.