MOSS: Self-Evolution through Source-Level Rewriting in Autonomous Agent Systems¶
🕒 Published (v1): 2026-05-21 17:48 UTC · Source: Arxiv · link
Why this paper was selected
MOSS: runtime self-evolution via source-level agent code rewriting without weight updates
Ask a follow-up
Open an assistant pre-loaded with this paper's context.
💬 Ask ChatGPT✦ Ask Claude
TL;DR¶
MOSS is a system that closes the "harness gap" in self-evolving agents by performing source-level rewriting on the agent harness itself—routing, hooks, state management, dispatch—rather than being limited to text-mutable artifacts like prompts or skills. It uses a production-failure-evidence-driven, multi-stage pipeline with ephemeral trial workers for runtime verification and an in-place container swap for deployment. On OpenClaw, a single evolution cycle raises the claweval mean grader score from 0.25 to 0.61.
Problem¶
All prior self-evolving agent systems (Hermes Agent, SkillClaw, GenericAgent, EvoAgentX) restrict evolution to text-mutable artifacts—skill files, prompt configurations, memory schemas, workflow graphs—and leave the agent harness untouched. Structural failures originating in routing logic, hook ordering, session lifecycle, or concurrent state invariants live entirely in code; they are physically unreachable from any text-layer edit. This gap widens as harness complexity grows, and text-mutable fixes additionally erode under long-context drift as accumulated patches compete for the model's attention.
Method¶
MOSS wraps a production agentic substrate (OpenClaw) in a four-component topology: a moss-gateway container hosting the user-facing agent and an in-container evolution service; a persistent host-daemon (asyncio) for container lifecycle, coding-agent CLI dispatch, trial-worker orchestration, and auto-scan; an external coding-agent CLI (pluggable: Claude Code, Codex, DeepSeek-TUI, OpenCode) that performs all actual edits; and ephemeral trial workers for runtime verification.
Evolution is directed: failure evidence enters a batch via two paths—a periodic moss evo catch-up cron that scores session JSONLs and flags weak/missing keypoints, and user-triggered moss evo flag. Each batch (default threshold: 8 chunks) anchors the entire downstream pipeline to fixing those specific failures rather than a synthetic benchmark.
Each iteration runs a fixed seven-stage pipeline: (1) Locate — diagnosis from baseline traces; (2) Plan — root-cause and fix specification; (3) Plan-Review — first quality gate with multi-round plan-loop; (4) Implement — single git commit in the substrate repo; (5) Code-Review — diff review against the plan with multi-round code-loop and hard-reset between rounds; (6) Task-Evaluate — scores 4–7 keypoints per task on a four-level qualitative scale (strong/adequate/weak/missing) by replaying against the candidate image in ephemeral trial workers; (7) Verdict — emits one of CONVERGED, NEED_MORE_WORK, FUNDAMENTAL_LIMIT_MODEL, or FUNDAMENTAL_LIMIT_ARCHITECTURE, with a plateau guard forcing convergence if no keypoint improves across a depth-dependent window.
Promotion requires explicit user authorization (moss evo apply); the host-daemon then performs an in-place container swap with a 90-second health-probe window (4 checks, 3 consecutive passes to commit) and automatic rollback to a stored last-known-good image on failure. User-state volumes (sessions, memory, credentials) are mounted from the host filesystem and survive the swap intact.
Key Contributions¶
- First self-evolving agent system to include the harness layer (routing, hooks, dispatch, session lifecycle) in its evolution scope, achieving Turing-complete coverage as a strict superset of all text-mutable approaches.
- Directed evolution paradigm: evidence-anchored batches from production session JSONLs replace random mutation and synthetic benchmark fitness signals.
- Pluggable external coding-agent CLI abstraction: a four-method runner interface decouples evolution machinery from any specific model provider; four runners ship in-tree.
- Ephemeral trial workers: runtime verification on candidate container images against the original failure-producing prompts, not unit tests or synthetic harnesses.
- Consent-gated in-place container swap with health-probe-driven rollback and state-volume preservation, enabling zero-downtime harness-level upgrades of single-instance production agents.
- Full evolution lifecycle surfaced to the agent via a
moss evoCLI injected into the system prompt, making evolution conversationally accessible without a separate UI.
Results¶
- On OpenClaw with DeepSeek V3.2 as the underlying model, a single MOSS evolution cycle lifts the claweval four-task mean grader score from 0.25 → 0.61 (baseline range 0.21–0.33; pass threshold 0.75), measured on the same four compliance-audit/restock-chain tasks used as the failure batch.
- Baseline failure modes—partial ticket enumeration, missing inter-service chain links, occasional customer-name misattribution—are qualitatively resolved in the post-evolution candidate transcript.
- No other reported numeric benchmarks or multi-cycle results are provided in the available text.
Limitations¶
- Case study uses the same four tasks as both the failure batch and the evaluation test set, trading ecological validity for reproducibility; a held-out evaluation is absent.
- The 0.61 post-evolution score still falls below the claweval 0.75 pass threshold.
- Only a single evolution cycle is demonstrated; multi-cycle stability, compounding effects, and regression risks over many swaps are uncharacterized.
- Verification is bounded to the batch tasks in isolation without live user state or production traffic; trial-verified candidates can still regress on live traffic (acknowledged in §3.5).
- The system is currently demonstrated on OpenClaw only; generalization to other substrates is asserted but not empirically validated.
- No ablation isolates the contribution of harness-level editing versus text-layer editing within MOSS's own pipeline.
Relevance to Harnesses / Meta-Harnesses¶
MOSS is directly constitutive of this research thread: it is the first system to apply self-rewriting to the agent harness itself rather than only to the artifacts the harness manages, establishing that harness-level code is a valid and necessary target for meta-level adaptation. The paper's explicit taxonomy (Table 1) frames prior work—including Meta-Harness [Lee et al., 2026], which it cites as demonstrating that execution-trace feedback drives iterative improvement more strongly than benchmark scores—as occupying a strictly narrower evolution scope, positioning source-level harness rewriting as the logical completion of that line. For researchers tracking harnesses/meta-harnesses, MOSS provides a concrete production-grade architecture showing how a meta-harness can observe, modify, verify, and promote changes to its own substrate, with all the engineering constraints (large codebase, live user state, no global fitness signal) that minimal-scaffold academic systems elide.