Research Published here Reported by arXiv on

Put cyclomatic complexity in the agent's context and it refactors on its own — tests passing was never the whole signal

A paper presented at the Agent Evaluation Science Symposium targets a gap every team running coding agents eventually hits: passing tests alone does not reveal accumulating complexity or gaps in test coverage, so an agent can stay green for an entire session while the code it leaves behind becomes progressively harder to maintain. The proposal, metrics-in-the-loop, is to inject automatic code metrics into the agent's context during development rather than reporting them afterward. After each code modification the harness returns two kinds of feedback: a complexity signal when cyclomatic complexity crosses a threshold, and a coverage signal identifying untested lines. That gives the agent the opportunity to refactor and strengthen tests inside the same run, while the change is still fresh in context. The authors report that the intervention reduces what they call erosion — the buildup of complexity concentration — without degrading correctness on held-out tests, and frame it as a practical form of agent re-railing: redirecting the model before technical debt compounds rather than auditing for it later.

Why it matters

Almost every agentic coding harness in production uses a green test suite as its sole acceptance signal, which encodes the assumption that correct and maintainable are the same property. They are not, and the gap compounds silently across a long session — the agent has no reason to refactor because nothing in its feedback loop ever mentions complexity. The design insight is about timing more than metrics: a complexity report delivered after the run is a code review nobody does, while the same number delivered after the edit is something the model can act on immediately and cheaply. It also costs almost nothing to adopt, since the tools that compute cyclomatic complexity and line coverage already run in your CI; the change is moving them from the end of the pipeline into the agent loop.

What to do

Wire your existing complexity and coverage tooling into the agent loop as post-edit feedback rather than post-run reporting — this is a harness change, not a model change, and the tools are already in your repo. Set a threshold that triggers a message rather than a hard failure, since the goal is to give the agent a chance to refactor in the same turn, not to block it. Track complexity concentration across a session, not just per file, because the finding is about erosion accumulating over a long run. And add these metrics to whatever you use to accept agent output, so "tests pass" stops being the entire bar for merging work you did not write.

Tags: Agents Coding Evaluation Research

More from November 20, 2026

All AI news