# Cyclomatic complexity feedback makes coding agents write simpler, not more correct, code

A preprint tests short code-quality reports injected into coding agents' context during long runs on Commit0, SlopCodeBench and SWE-EVO. The agents produced structurally simpler code, but held-out tests did not show more correct code.

- Category: Code
- Readiness level: II (Benchmarked) on Science Underway's four-step scale, as proposed
- Published: 2026-11-19
- Editor: Stefan Perdal
- URL: https://scienceunderway.com/articles/cyclomatic-complexity-feedback-makes-coding-agents-write-simpler-not-more-correc

## The study

Metrics-in-the-Loop: Complexity Feedback Reshapes Agent-Written Code (preprint, not peer reviewed). arXiv 2611.23817. https://arxiv.org/abs/2611.23817

## At a glance

- What it shows: When a coding agent is told, after each edit, which functions it just made too tangled, it fixes most of them. On two of three test sets the leftover complexity drops sharply. Correctness does not change in any way the study could detect.
- What it does not show: It does not show that the simpler code is more correct, cheaper to maintain or easier to extend later. It does not show the effect on large real codebases or in real software teams.
- Why it matters: Coding agents now write large amounts of code that nobody reviews line by line. A cheap, automatic check that keeps that code tidier during the run could limit the mess teams inherit later.

## What the study shows

Coding agents now work for hours on their own, and they mostly judge success by whether tests pass. Passing tests say little about structure. An agent can pile logic into a few huge functions and then keep building on them. The authors, from Nera Software, Cohere Labs and Mila, test a simple fix. After every turn in which the agent changes code, a tool measures the changed functions and adds a short report to the agent's context before it continues.

The report uses cyclomatic complexity, a decades-old measure that counts the independent paths through a function. More paths means code that is harder to follow and test. The report names every changed function above a limit of 6 and asks the agent to bring it down. A second report lists changed lines that the agent's own tests never run. The tool needs no training, no reference solution and no access to the hidden tests.

The design is careful about one trap. A message after every edit might change behaviour whatever it says. So the main comparison is against a reminder arm that gets the same refactoring instructions on the same schedule, but no measurements. A fifth arm gets no message at all. Four models were tested: DeepSeek V4.1 Flash, GLM-5.3 Flash, Claude Haiku 5.5 and GPT-6 Luna. The three benchmarks ask agents to rebuild Python libraries (Commit0), extend a program over several rounds of changing specifications (SlopCodeBench), or update a real project to its next release (SWE-EVO).

The main outcome is erosion: the share of a codebase's complexity that sits in functions with complexity above 10. The authors report that complexity feedback cut erosion for all four models on Commit0 and SlopCodeBench. On SlopCodeBench it removed nearly all of it, holding erosion at about 2% or less at every checkpoint. On SWE-EVO, where agents edit mostly existing code, the drop was small and clear for only two of four models.

Agents did act on the reports. Under complexity feedback they reworked most flagged functions, and on SlopCodeBench well over 90% ended under the limit. With the reminder alone, only 1 to 18% of over-limit functions ended under it.

Correctness, measured on tests the agent never saw, showed no detectable change for any model. Pooled estimates leaned slightly positive on Commit0 and SWE-EVO and slightly negative on SlopCodeBench. All their ranges included zero. One extra analysis on SlopCodeBench suggests a small cost cannot be ruled out. The paper is a preprint and has not been peer reviewed.

## Our reading

In our reading, the strongest result is behavioural. Agents read the reports and followed them, and the gap over the reminder arm is large and consistent on two benchmarks. A mechanical number, delivered at the right moment, steered models from four different developers. That is useful evidence that in-run feedback works as a control lever, not just end-of-run grading.

The weaker part is what the lower number means. The agent is steered towards complexity, and erosion is measured on complexity. Splitting a big function into helpers lowers the score without removing any branching logic. The authors check this. When they fold single-use helpers back into their callers, much of the gain disappears: between 3 and 46% of it survives on Commit0. On SlopCodeBench the total amount of branching did fall, by about 14 to 21% for three models, which points to some real simplification there.

A practical example: a team that lets an agent build an internal library overnight could add a complexity check after each edit at little cost. The feedback text was about 1% of tokens or less. The study suggests the morning's code would have fewer sprawling functions. It does not yet show that the code would have fewer bugs. On our readiness scale this is level II, benchmarked: public benchmark results, but no released code for the measuring tool and no documented production use.

The rest of the article (what it means, limits, what to watch) is free for members: https://scienceunderway.com/articles/cyclomatic-complexity-feedback-makes-coding-agents-write-simpler-not-more-correc

## How this was made

An AI model read the study and wrote this article in the structure Science Underway uses. An editor reviewed it and approved it for publication. Check the original study before you rely on the details.

---
Source: Science Underway, https://scienceunderway.com/. Please link to the article when you cite it.
