TRIM: Reducing AI-Generated CodeSlop via Agent Trajectory Minimization
- URL: http://arxiv.org/abs/2607.18161v1
- Date: Mon, 20 Jul 2026 17:06:19 GMT
- Title: TRIM: Reducing AI-Generated CodeSlop via Agent Trajectory Minimization
- Abstract summary: Coding agents are increasingly used to accelerate code generation in many downstream tasks.<n>Despite their value, agent-generated code tends to be larger and more verbose than the corresponding human-written implementation.<n>We show that the cause lies in the agent's own search process.
- Score: 57.14479960309637
- License: http://creativecommons.org/licenses/by/4.0/
- Abstract: Coding agents are increasingly used to accelerate code generation in many downstream tasks, such as fixing bugs, building applications, and prototyping. However, despite their value as coding assistants, agent-generated code tends to be larger and more verbose than the corresponding human-written implementation. In this work, we show that the cause lies in the agent's own search process: while iterating toward a passing solution, an agent accumulates speculative edits, abandoned hypotheses, and temporary changes that persist into the final patch. This may seem harmless for a single patch, but the problem compounds as agents take responsibility for ever-larger portions of a codebase-a codebase that was once minimal and well-maintained slowly accumulates redundancy faster than it can be cleaned up, drifting to a state that is harder to maintain. Given the magnitude of this problem, we take a step towards alleviating this issue. First, we formally define this phenomenon as CodeSlop-the residual and functionally unnecessary edits commonly seen in AI-generated code. We then introduce our algorithm TRIM (Trajectory-guided Redundancy Identification and Minimization). Rather than minimizing CodeSlop directly, TRIM instead minimizes agent trajectories. As we show empirically, this indirect technique of minimizing CodeSlop is highly effective: TRIM cuts CodeSlop by 17.9%-32.9% across agentic scaffolds, with negligible performance regression. TRIM is also highly efficient, requiring roughly half the validation cost of algorithmic baselines such as Delta Debugging.
Related papers
- Coaching Qwen3 Coder 30B to Think Like a CodeClash Arena Agent [0.0]
We show that Qwen3-Coder-30B is not well optimized for arena-style interaction.<n>We propose ReAct SFT, which rewrites teacher trajectories into explicit [obs]. chains, and trajectoryquality weighted SFT, which reweights samples to encourage post-edit checking.
arXiv Detail & Related papers (2026-09-14T14:50:05Z) - Is Agent Code Less Maintainable Than Human Code? [17.226150835020146]
We investigate how agent code compares to human code in maintenance settings.<n>We find that agents are less effective at resolving tasks when building on agent code compared to human code.
arXiv Detail & Related papers (2026-06-19T23:56:14Z) - Does Code Cleanliness Affect Coding Agents? A Controlled Minimal-Pair Study [0.18907108368038217]
We show that code cleanliness affects an agent's ability to navigate and modify it.<n>Our findings suggest that traditional maintainability principles remain highly relevant in the era of AI-driven development.
arXiv Detail & Related papers (2026-05-19T16:06:26Z) - From I/O to Code with Discovery Agent [103.88427301265669]
We propose DIO-Agent, a discovery agent for IO2Code.<n>Our method frames IO2Code as an evolutionary search over discrete program space.<n>Extensive experiments show that DIO-Agent consistently outperforms both traditional program-by-example method and SOTA evolution-agent baselines.
arXiv Detail & Related papers (2026-05-14T18:57:32Z) - Coding Agents Don't Know When to Act [3.2610504259514754]
Coding agents are increasingly deployed to autonomously maintain software.<n>In any real-world deployment, they will encounter stale bug reports about issues that have already been resolved.<n>We show that even state-of-the-art models fail, proposing undesirable changes in $35$ to $65%$ of cases.
arXiv Detail & Related papers (2026-05-08T14:10:00Z) - Why Agentic-PRs Get Rejected: A Comparative Study of Coding Agents [0.0]
We show that Pull Requests produced using coding agents (Agentic-PRs) are accepted less often than PRs that are not labeled as agentic (Human-PRs)<n>A large proportion of rejected PRs lack explicit feedback, making their rejection reasons difficult to determine.
arXiv Detail & Related papers (2026-02-04T05:24:18Z) - ET-Agent: Incentivizing Effective Tool-Integrated Reasoning Agent via Behavior Calibration [68.89572566071575]
ETAgent is a training framework for calibrating agent's tool-use behavior.<n>It is designed to progressively calibrate erroneous behavioral patterns to optimal behaviors.
arXiv Detail & Related papers (2026-01-11T11:05:26Z) - Diffusion Language Models Know the Answer Before Decoding [56.96815863705218]
Diffusion language models (DLMs) have emerged as an alternative to autoregressive approaches.<n>Our work highlights and leverage an overlooked property of DLMs early answer convergence.<n>We introduce Prophet, a training-free fast decoding paradigm that enables early commit decoding.
arXiv Detail & Related papers (2025-08-27T15:40:25Z) - Runaway is Ashamed, But Helpful: On the Early-Exit Behavior of Large Language Model-based Agents in Embodied Environments [54.67512489842682]
Large language models (LLMs) have demonstrated strong planning and decision-making capabilities in complex embodied environments.<n>We take a first step toward exploring the early-exit behavior for LLM-based agents.
arXiv Detail & Related papers (2025-05-23T08:23:36Z) - Towards Adaptive Software Agents for Debugging [0.40964539027092917]
We propose an adaptive agentic design, where the number of agents and their roles are determined dynamically.<n>Our initial evaluation shows that, with the adaptive design, the number of agents that are generated depends on the complexity of the buggy code.<n> Regarding the effectiveness of the fix, we noticed an average improvement of 11% compared to the one-shot prompting.
arXiv Detail & Related papers (2025-04-25T12:48:08Z) - Let the Code LLM Edit Itself When You Edit the Code [50.46536185784169]
underlinetextbfPositional textbfIntegrity textbfEncoding (PIE)<n>PIE reduces computational overhead by over 85% compared to the standard full recomputation approach.<n>Results demonstrate that PIE reduces computational overhead by over 85% compared to the standard full recomputation approach.
arXiv Detail & Related papers (2024-07-03T14:34:03Z)
This list is automatically generated from the titles and abstracts of the papers in this site.
This site does not guarantee the quality of this site (including all information) and is not responsible for any consequences.