How can engineering organizations prevent autonomous coding agents from turning software repositories into unmaintainable, monolithic liabilities? Autonomous coding agents write whole codebases in long runs, guided mainly by whether their tests pass. Because test suites verify functional execution rather than code architecture, software systems silently accumulate internal complexity. As researcher Nicolas Chapados of Nera Software and Mila, Jean-François Gagné of Nera Software, and Nouha Dziri of Cohere Labs, Mila, and ELLIS Institute Tübingen report, autonomous agents write code faster than humans can review it, yet their output departs from well-engineered patterns, favoring large, monolithic, single-file implementations.
Deploying autonomous systems directly into engineering pipelines exposes the operational friction of code review at scale. However, passing tests alone does not reveal accumulating complexity or gaps in test coverage, which persist as agents extend their own code across long trajectories.
Intercepting Structural Erosion at Inference Time
The solution demonstrated by Chapados, Gagné, and Dziri relies on metrics-in-the-loop, an inference-time intervention that delivers cheap, automatically computed code metrics into the agent's context during execution.
"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."
MITL functions as a lightweight plugin that measures the code an agent has just changed and provides feedback as a short report before the agent continues. The mechanism requires no model training, no reference solution, and no access to held-out tests. In practice, cyclomatic complexity measures the number of independent paths through a function, flagging every modified function where complexity exceeds a threshold set to 6. Alongside complexity, the plugin tracks test coverage, counting for each modified function the lines that the agent's own tests fail to execute.
After each code-changing turn, short feedback messages name the changed functions that breach the complexity limit or note the lines skipped by unit tests. Audits of agent traces reveal that models act directly on this injected feedback by reworking most of the functions named in the reports before continuing their long-horizon tasks.
Complexity Feedback Preserves Functional Correctness
A common assumption among software teams is that injecting automated constraints into agent trajectories will disrupt reasoning or reduce execution success. The experimental data shows this assumption is incorrect. The authors evaluated MITL across three long-horizon coding benchmarks—Commit0, SlopCodeBench, and SWE-EVO—using four models: DeepSeek V4.1 Flash, GLM-5.3 Flash, Claude Haiku 5.5, and GPT-6 Luna. The evaluation compared complexity feedback, coverage feedback, and both combined against a reminder-only control and a baseline without messages.
"We find that complexity feedback significantly reduces erosion, a measure of complexity concentration of code, without affecting held-out correctness of the code."
Across these benchmarks, complexity feedback, alone or combined with coverage feedback, systematically lowers erosion, defined as the share of complexity concentrated in functions with cyclomatic complexity above 10. The reduction in erosion proved statistically significant for all four models on Commit0 and SlopCodeBench. On SWE-EVO, the reduction in erosion was smaller and remained significant for two of the four models.
Controlling complexity at inference time resolves the balance between agent autonomy and structural software decay. Because models refactor monolithic functions without dropping held-out test scores, automated code health checks turn agentic pipelines from unreviewable black boxes into maintainable assets. Deploying autonomous developers into production environments will require continuous structural constraints rather than passive reliance on green test suites, returning engineering organizations to the core operational question of how to prevent agent-generated code from turning into long-term financial liabilities.
For comparison
What price does an engineering team pay for green test suites that actually mask architectural rot? When left to their own devices, autonomous coding models generate monolithic, single-file sprawls simply because test pipelines verify output without checking how convoluted the internal branches have become. By contrasting passive text reminders with real-time complexity metrics inside the context window, researchers from Nera Software, Mila, and Cohere Labs demonstrated that models only refactor bloated logic when confronted with concrete measurements after each iteration. While autonomous agents easily satisfied functional tests, they steadily built repositories that humans could no longer maintain.