TL;DR
Standard AI coding benchmarks only measure whether an agent's code passes tests, completely ignoring the messy, unmaintainable "code slop" left behind. This paper introduces static-analysis metrics to quantify this hidden technical debt and demonstrates that an adaptive, monitor-triggered cleanup policy can drastically reduce code bloat and complexity without sacrificing functional correctness.
What Problem Does This Paper Address?
When evaluating AI coding agents, the standard industry metric is functional correctness—usually measured by whether a generated patch passes a suite of unit tests (e.g., SWE-bench). However, in real-world software engineering, code is read, reviewed, and maintained far more often than it is initially written.
If an AI agent successfully fixes a bug but leaves behind tangled control flows, duplicate logic, or leftover debug scripts, it introduces significant technical debt. The authors term this footprint code slop: the unnecessary code volume, control-flow complexity, and maintainability debt introduced beyond what the task strictly requires. This issue is particularly critical for long-horizon tasks, where messy intermediate code becomes the shared, confusing state that a human collaborator or another agent must inherit.
Methods
To understand and mitigate code slop, the authors introduce a specialized "cleanup sub-agent" into a standard ReAct execution loop. They test four distinct policies to determine exactly when cleanup should occur:
- Base: No cleanup intervention (the standard baseline).
- One-shot: A single cleanup pass executed only after the entire task trajectory finishes.
- Periodic-N: Automated cleanup triggered strictly every $N$ steps.
- Monitor: An adaptive policy where a trajectory monitor asks the LLM at each step if it has completed a meaningful subtask or reached a "natural breakpoint." Cleanup only fires if the answer is yes.
The cleanup sub-agent is strictly constrained: it can remove bloat (like temporary logging, formatting anomalies, and redundant files) and simplify code structure, but it is forbidden from rewriting the core fix logic or adding new features. To quantify slop, the authors use SonarQube to track three static-analysis metrics before and after the agent's run: lines of code ($\Delta$LOC), cognitive complexity ($\Delta$Cog), and maintainability remediation effort ($\Delta$Rem).
Datasets
The approach is evaluated using SWE-EVO, a benchmark consisting of real-world, release-to-release software evolution transitions across open-source Python repositories (including dask, dvc, conan, and modin). The authors evaluate 42 long-horizon tasks across three LLMs (Claude Sonnet 4.6, DeepSeek V3.2, and Qwen3-Coder 480B).
Key Insights and Ideas
- Success Metrics are Blind to Slop: The paper's headline finding is a stark dissociation between test success and code quality. Across all six cleanup settings, fractional test utility remained tightly bound between 70% and 76%. Yet, the code slop left behind varied by more than a factor of five! Evaluating agents purely on test passes completely misses how clean or maintainable their work actually is.
- Post-Hoc Cleaning Fails: Waiting until the very end to clean code (
One-shot) does almost nothing to reduce slop. This is because the agent spends its entire trajectory building on top of its own messy intermediate code, compounding errors and complexity along the way. - Slop is Highly Model-Dependent: Stronger frontier models (like Claude Sonnet 4.6) naturally write compact code and generate very little slop to begin with. Conversely, weaker open-weight models tend to produce massive amounts of structural bloat, making them the primary beneficiaries of trajectory-time cleanup.
Key Results
- The Monitor Policy Wins: The adaptive
Monitorpolicy achieved the single best reduction across all three slop metrics. It drove the code volume delta ($\Delta$LOC) down to -79.3 lines (compared to -20.3 for the Base condition) and slashed cognitive complexity ($\Delta$Cog) to -13.4. - High Efficiency: While fixed periodic cleaning (
Periodic-10) also successfully reduced slop, it doubled the monetary cost of running the agent ($1.21 per instance). TheMonitorpolicy achieved even cleaner code for just $0.91 per instance—a 25% savings over periodic scheduling—by intelligently skipping unnecessary cleanup passes.
Limitations and Future Work
The primary limitation acknowledged by the authors is that this study uses end-of-run codebase states as a proxy for maintainability. Because they evaluate single-turn agent trajectories, they do not directly test the "downstream payoff"—i.e., whether a cleaner intermediate state actually makes the next turn easier for a human or a secondary agent.
Additionally, the benchmark is currently limited to Python repositories within SWE-EVO and evaluates a single agent harness (mini-swe-agent). The authors suggest that future work should explore multi-turn evaluation setups to directly measure downstream human effort, and expand slop metrics to capture higher-level architectural design and naming quality.
Summary updated