Metrics-in-the-Loop: Complexity Feedback Reshapes Agent-Written Code
Nicolas Chapados, Jean-François Gagné, Nouha Dziri
Abstract
Coding agents now write whole codebases in long autonomous runs, guided mainly by whether their tests pass. Yet passing tests alone does not reveal accumulating complexity or gaps in test coverage, which then persist as agents extend their own code. We introduce metrics-in-the-loop, an inference-time intervention that gives agents in-flight feedback: cheap, automatically computed code metrics injected into the agent's context during the trajectory. After each code-changing agent turn, we insert short feedback messages naming changed functions whose cyclomatic complexity exceeds a limit (complexity feedback) or changed lines that are skipped by tests (coverage feedback), giving the agent the opportunity to refactor code or strengthen tests before continuing. We run extensive experiments and ablations comparing several interventions across three long-horizon coding benchmarks and four strong models. We find that complexity feedback significantly reduces erosion, a measure of complexity concentration of code, without affecting held-out correctness of the code. Broadly, our experiments investigate a practical form of agent "re-railing", where timely, actionable measurements redirect agents before weaknesses become the foundation they keep building on. As agents scale to codebases with millions of lines, such interventions become critical to sustaining effective development and long-term code maintainability.
Create a lesson
Related papers
How Feedback-Free Self-Evolution Reshapes Agent Skills: A Systematic Study
Shared title terminology · Litao Guo, Man Chen, Xinli Xu et al.
RoboBuilder: Agentic Robot Co-Design with Real-world Video Feedback in the Loop
Shared title terminology · Ghadi Nehme, Dahyun Nam, Akshay Govind Srinivasan et al.
Stop Going in Circles:Loop-Triggered Routing for System 1 Decision Agents
Shared title terminology · Zeming Yu, Huamin Ma, Yingyu Chen et al.
Think Offline, Act in Real Time: Self-Improving Visual Game Agents through Code
Shared title terminology · Zipeng Qiu, Shusheng Xu, Jiale Li et al.
Reducing Inference Cost of Coding Agents with Timeout Cascades
Shared title terminology · Boxi Zhou, German Sviridov, Dmitrii Ustiugov et al.
3D GameDev Arena: Benchmarking Coding Agents That Plan, Build, and Playtest extreme Long-Horizon Browser Games
Shared title terminology · Bizhe Bai, Jiliang Jian, Yuqing Yan et al.