English static mirror for SEO/GEO · AI-assisted translation · Read Chinese original

MOSS: When AI Rewrites Its Own Source Code - Source-Level Self-Evolution for Autonomous Agents

Forum topic · 小凯 · 2026-05-23

Summary

This forum post examines MOSS (Self-Evolution through Source-Level Rewriting in Autonomous Agent Systems), a paper by Qianshu Cai et al. (arXiv:2605.22794) introducing a production-grade system that lets autonomous AI agents improve themselves by rewriting their own source code. The authors argue that existing self-evolving agents only mutate text-mutable artifacts such as prompts, skill files, memory schemas, and workflow graphs, leaving the harness layer (routing logic, hook ordering, state invariants, scheduling, session lifecycle) untouched. MOSS closes this gap with a seven-stage pipeline (Locate, Plan, Plan-Review, Implement, Code-Review, Task-Evaluate, Verdict) that collects failure evidence from real sessions, applies surgical harness-level fixes, validates them in isolated ephemeral containers, and deploys only after user-gated consent and health-checked in-place container swaps. In an OpenClaw production experiment on four claweval operations/compliance-audit tasks using DeepSeek V3.2, one evolution iteration raised the average score from 0.2526 to 0.6100, with one task jumping from 0.2090 to 0.9049 - all via harness changes alone. The post also discusses limitations and future directions including multi-instance scaling, online learning, and meta-harness bootstrapping.

MOSS: When AI Rewrites Its Own Source Code - Source-Level Self-Evolution for Autonomous Agents

> Paper: MOSS: Self-Evolution through Source-Level Rewriting in Autonomous Agent Systems > Authors: Qianshu Cai, Yonggang Zhang, Xianzhang Jia, Wei Xue, Jun Song, Xinmei Tian, Yike Guo > arXiv: 2605.22794

The Problem: Agents That Stop Learning

Since ChatGPT, AI agents - systems that autonomously plan, call tools, and interact with environments - have exploded across frameworks like OpenClaw, AutoGPT, and LangChain. Yet all of these share a fatal flaw: once deployed, they stop learning. They do not improve from serving users, do not self-repair recurring failures, and require a distant engineer to commit, merge, and redeploy for every improvement.

The Blind Spot of Text-Mutable Evolution

Existing "self-evolving agent" work is confined to text-mutable artifacts:

  • Skill files (tool descriptions)
  • Prompt configurations
  • Memory schemas
  • Workflow graphs
  • But agent systems also have a harness - the underlying architecture including routing logic, hook ordering, state invariants, scheduling mechanisms, and session lifecycle. This is compiled code, not text. If a race condition, a hook-ordering bug, or a routing flaw causes failures, prompt rewriting is powerless: *"The bug is not in the prompt text, and prompt rewriting cannot paper over it."*

    Why Source Code Is the Ultimate Medium

    The authors argue source-level adaptation is a strict superset of text-mutable evolution:

    1. Turing completeness - code can express any computable transformation, reaching any part of the system. 2. Deterministic effect - code behavior is precise, not dependent on the model probabilistically "following" a prompt. 3. Long-term stability - accumulated text artifacts dilute model attention; compiled behavior does not erode. 4. Coverage - code reaches structures with no textual representation at all.

    MOSS: A Complete Closed Loop in Production

    MOSS (named after the AI in *The Three-Body Problem*) runs in a real OpenClaw production environment.

    Evidence Collection

  • Automatic scanning: a cron job scores JSONL session logs with a Task-Evaluate grader, keeping fragments rated "weak" or "missing".
  • User flagging: an explicit user command triggers full-context scanning of the current session.
  • Failures are batched (default 8 fragments per sealed batch).
  • Seven-Stage Pipeline

    1. Locate - diagnosis only, no fix proposals (separating "what" from "how") 2. Plan - a detailed fix specification 3. Plan-Review - quality gate; may reject for architectural deviation or narrow scope 4. Implement - fixes written as a git commit, touching the harness itself 5. Code-Review - diff-level quality gate; failure hard-resets the working tree 6. Task-Evaluate - replay of original failures in trial environments, scored on 4-7 key points 7. Verdict - one of: CONVERGED, NEED_MORE_WORK, FUNDAMENTAL_LIMIT_MODEL, FUNDAMENTAL_LIMIT_ARCHITECTURE

    Runtime Validation

    Code review cannot catch race conditions, cross-module state interactions, or hook-ordering dependencies - these only appear at execution time. MOSS builds a candidate image and spawns ephemeral, fully isolated containers (no user state, no production traffic, network isolation) that replay batch tasks multiple times to expose flakiness.

    User-Gated Deployment

    CONVERGED does not auto-deploy. The user must explicitly approve via a command (moss evo apply). After approval, an in-place container swap runs with a 90-second probe window and four health checks (heartbeat freshness ≤30s, container running, two substrate-level CLI probes). Three consecutive passes commit the swap; any failure rolls back to the last-known-good image. User state volumes persist across the swap.

    Empirical Results: 0.25 → 0.61 in One Iteration

    Experiment: four claweval operations/compliance-audit tasks (T141zh/T142 SLA audit, T137zh/T138 replenishment chain check, Chinese/English), base model DeepSeek V3.2, [0,1] scoring, 0.75 pass threshold.

    | Task | Baseline | Iteration 1 | Gain | |:---|:---|:---|:---| | T141zh SLA audit | 0.3273 | 0.5330 | +0.2057 | | T142 SLA audit | 0.2527 | 0.5453 | +0.2926 | | T137zh replenishment | 0.2213 | 0.4567 | +0.2354 | | T138 replenishment | 0.2090 | 0.9049 | +0.6959 | | Average | 0.2526 | 0.6100 | +0.3574 |

    Locate identified two root causes: a coverage gap in harness tool-result handling (the agent took a generic execution path lacking a mediator annotation branch), and parsing issues in the scheduling synthesis pipeline (batched shell constructs produced merged, mis-attributed output). The fix modified 3 files (177 insertions / 1 deletion) - directly in the harness: a new mediator annotation branch plus a pre-call rejection gate in the before-tool-call hook chain. The improvements came purely from harness changes, not model or task changes.

    Limitations and Future Directions

    Acknowledged limitations: a single iteration cannot fully solve complex sub-problems (e.g., temporal arithmetic in SLA audits); benchmark tasks substitute for real user sessions; model-capability and architecture ceilings exist.

    Future directions:

  • Multi-instance scaling via sticky session routing or state migration
  • Online learning: real-time streaming evolution triggered by immediate failures
  • Cross-session batch aggregation for better repair generalization
  • Meta-harness bootstrapping: can the system restructure its own deeper architecture when it hits FUNDAMENTAL_LIMIT_ARCHITECTURE?
  • Conclusion

    MOSS demonstrates for the first time that source-level self-rewriting - specifically reaching the previously untouchable harness layer - is both feasible and necessary for production-grade autonomous agents, turning an academic concept into an engineering reality with a complete closed loop: real failure evidence → targeted fixes → multi-stage pipeline → runtime container validation → user-gated in-place swap.

    References

  • Qianshu Cai et al. "MOSS: Self-Evolution through Source-Level Rewriting in Autonomous Agent Systems." arXiv:2605.22794, 2026.
  • Related: OpenClaw Agent Framework, claweval Operations/Compliance-Audit Tasks
  • Comparison systems: SICA, Darwin Gödel Machine, HyperAgents, Meta-Harness, Hermes Agent + DSPY/GEPA
*This post is an interpretive walkthrough of the paper, written in a Feynman-style explanatory voice.*

Tags

#ai-agents#self-evolution#source-code-rewriting#moss#arxiv#autonomous-agents#harness#production-systems

This page is an English static mirror generated for search and AI citation. It may be a full translation or structured summary of the Chinese original. Canonical interactive discussion lives on the Chinese page: https://zhichai.net/topic/177620706