Mariano Cavallo

Coding agents need CI that is fast and trustworthy

By Mariano Cavallo 6 min read

When I give a task to a coding agent, writing the code is the short part. Picture a change the agent writes in under a minute, checked by a pipeline that takes eight. If it needs four attempts to go green, it spends about four minutes writing and more than half an hour waiting for checks, reading their output and trying again.

CI speed sets the speed of the agent loop

I batch my work: write for an hour, push, go to a meeting, read the results later. An agent does not batch. It changes something, runs the checks, reads the failure and changes something else, and it keeps going until the checks pass or it gives up. Every minute of CI is added to every iteration.

Tiers help. Mark Watson describes a setup with a quick check under 5 seconds, a broader one under 30 seconds and the full suite at the end. The agent runs the fast tier after every edit and the full suite once. Test selection does the same job inside CI: run the tests the change can affect, not all of them.

I have been experimenting with this, and I have had some success finding the right slices. There is no prescription that fits every project or codebase, though. The method only delivers what it promises when you get the nuance right: which checks earn a place in the fast tier, and which can wait for the full suite.

The cheapest tier runs before CI at all. Agents sometimes report a task as done without running the checks they were told to run, and Flemming Bakkensen puts the reason plainly: prompt instructions are suggestions, not constraints. His fix is a hook that runs when the agent tries to finish and blocks it until it has validated its work. He is clear that this is not a replacement for CI, because the hook does not verify anything itself. It makes sure the agent asks the question before the pipeline has to.

Agents cannot tell a flaky failure from a real one

When a test fails because a container did not start in time, I recognise it, sigh and press retry. An agent reads the same red output as evidence about its change. It rewrites working code, adds a timeout or loosens an assertion until the build goes green, and the diff that comes back is worse than the one that failed.

Picture the package registry timing out halfway through the install step. An agent sees a failed build after its change, so it upgrades a dependency until the install resolves, regenerates the lockfile and pushes again. The retry goes green, as it would have anyway, and the review now has a dependency upgrade nobody asked for.

Anthropic makes the same point in their post on scaling test impact analysis: humans can ignore failures that do not concern them, but agents need a precise, valid set of tests to check their own work. The same post shows what happens to load. Their CI jobs grew 25x in six months. Agents also start work whenever someone gives them a task, so load arrives in spikes, and a pipeline sized for the average day becomes flaky exactly when the most agents are waiting on it.

Flaky tests are not the only way a pipeline lies. Anthropic’s trouble was in the service that picks which tests to run. When the part that records test results fell behind, 20 minutes of lag meant tens of thousands of updates had not reached the selector, so it chose tests from stale data. Fixed and new tests did not run until it caught up, and at its worst the selector kept picking tests that were already flaky or failing everywhere. A human might notice that the failing test has nothing to do with the change. An agent gets a red build and a reason to start editing.

Design CI for the load agents will bring

Anthropic’s fixes show how fast this load outgrows a patch. Doubling the cores bought them 70 days, sharding the work bought 29, and daily restarts bought less than one. They ended up redesigning the service, and their advice is to plan for the exponential: assume a 25x load within two quarters, and size a first version for 10 to 20 times the scale you expect if you can afford it.

Nothing I run comes close to that scale. Every metric I track on my team, and the ones I see from other teams around me, points in the same direction, though. Our use of AI-assisted tools will only grow over the next few years, so I expect CI load to outgrow most pipelines sooner than their owners plan for. Building for a multiple of today’s load costs less now than three rounds of patches later.

Speed is necessary, not sufficient

A fast pipeline that checks the wrong things gives the agent a quick, confident wrong answer. The 2025 DORA report found that AI adoption now goes with higher throughput but still with lower stability, and lists strong automated testing and fast feedback loops among the practices that keep more change from turning into instability.

That is a change from the year before. In the 2024 report, more AI adoption went with an estimated 1.5% drop in throughput and a 7.2% drop in stability. A year later throughput had turned positive and stability had not. Teams got faster at producing change before they got better at absorbing it.

There is a second problem: agents write many of the tests they are checked against. A test written after the code tends to assert what the code does rather than what it should do, so it passes on the first run and proves little. Watson adds mutation testing to his slowest tier for this reason. It breaks the code on purpose and checks that at least one test fails. If the code can be broken and the suite stays green, the suite is fast and tells the agent nothing.

Fix the flaky failures before adding agents

Before rolling agents out to more of your team, measure two things on your main pipeline: how long a typical run takes, and how often it fails for reasons unrelated to the change. Fix or quarantine the second group first, because an agent will treat every one of those failures as its own bug.

Retries and quarantine need a policy, not a habit. My rule is to retry automatically only when the failure is in the infrastructure, such as a runner that died or a registry that timed out, and never when an assertion fails. A test that fails and then passes on retry goes into quarantine with an owner and a date, and it stops counting towards the result the agent sees. Without that rule, retries hide flakiness from people while agents still trip over it.