#118 - 3 Bottlenecks After AI Writes the Code
Reviews, test runs and CI/CD queues set the pace when agents produce code faster than teams can merge it.
18 min read
Adding more coding agents can mean more conflicts instead of more completed work. Paulina Dubas and Mattias Hemmingsson discuss agents stepping on each other’s changes and choosing how many a workflow can support.
Coding got fast, the rest of the week didn’t
Coding agents removed the step everyone used to measure. Writing the code isn’t where the week goes any more. The week goes on waiting. Someone has to review a pull request nobody can hold in their head. A test suite takes a few hours to finish. The pipeline hasn’t been idle since Tuesday. More code is arriving. The amount of finished, deployed change hasn’t moved nearly as much.
That’s three bottlenecks, and they queue up in that order: reviewing the change, testing the change, and CI/CD sitting behind both. None of them is new. What’s new is the arrival rate. The 3,000 line pull request everybody used to complain about is now on the small side. On greenfield work we see pull requests of a thousand files and 10,000 to 20,000 lines. At that size the tooling gives up before your reviewers do. GitHub stops at 300 files in a single diff, and caps a pull request diff at 20,000 loadable lines or 1 MB of raw diff. Per file, the caps are 20,000 lines or 500 KB, and only the first 400 lines and 20 KB load automatically. Portions of a limited diff still display, so the page can look complete with part of the change missing.
The reflex is to buy more capacity: faster runners, more parallel test shards, a bigger plan. The thing that holds up better is less exciting. It’s about deciding what runs where, how often each test gets to run, and how many agents your merge path can actually clear.
The bottleneck moved, it didn’t disappear
Start by naming where it landed, because the answer has stayed stable for a while now.
Where did the bottleneck go when coding stopped being one?
Straight into review and testing, with CI/CD jammed in behind them.
Most teams still use AI in one place. Agents run in the IDE, they help with the coding and the problem solving, and that’s where it stops. Maybe something on GitHub does a review pass at the end. The output of that one accelerated step lands on a review and test process sized for human typing speed. Now a human genuinely can’t read the change, so verification has to come from somewhere, and that somewhere is tests you have to run.
The answer DevOps already gave us still applies: small changes in batches, so you can test the section you touched instead of the whole system. We don’t see many teams doing it. On mature products, yes. On anything being built now the pull requests get bigger, not smaller, and a 3,000 line pull request counts as small when an agent wrote it. The correct practice is well known, and the arrival rate is pushing the other way.
The second-order effect is the one that catches people. Your tools inherit the size. When the diff view gives up, the review conversation moves to “the tests passed”. That puts the entire weight of verification on the test suite you were already waiting on.
Tests got cheap to write and expensive to run
So the suite carries the load. Which raises a question teams who did the DevOps work a decade ago assumed they’d already answered.
Does good test coverage from the old days make you ready for this?
Partly. It helps you write the tests, and it makes the run longer.
The excuse for skipping tests is gone. You’re not writing the change and you’re not writing the test, so there’s no reason left to merge without one. Coverage genuinely has improved where teams took that seriously. The catch is a domino effect. Every small change now brings its own tests, the suite grows with every change, and more changes mean more tests mean a longer run.
On one project we’re involved in, a full test run takes a few hours. The work there went into exactly what you’d expect: parallel testing, choosing tests based on where the change landed, anything to shorten the feedback loop. After a lot of improvements, it still isn’t good enough. That’s worth saying plainly, because the usual advice stops at “parallelise it” and the teams who did are not finished.
Research backs the shape of this, with a caveat. The 2025 DORA report found AI adoption associated with higher software delivery throughput, unlike the year before. The same report says AI adoption “does continue to have a negative relationship with software delivery stability”. Its own framing is that AI accelerates software development and that the acceleration exposes weaknesses downstream. The gains land for teams on loosely coupled architectures with fast feedback loops. None of that tells you which tests to cut. It does say that without strong automated testing and fast feedback loops, more change volume leads to instability.
Run the tests that match the change
If you can’t make the whole suite fast, the next question is which parts of it have to run at all.
How do you decide which tests run where?
By what the change touches, with the full suite moved to a gate further down the promotion path.
Change one file, and running three or four tests locally is often enough. The full run belongs around the merge into dev, either just before it or just after. Which side it sits on depends on the change and on what a broken dev branch costs the people working off it. On the pull request you want the tests that correspond to the change, not a thousand tests for a one-liner. The end-to-end validation then sits at a promotion step, covering the integrated result.
Ordering matters as much as selection. Run the tests that fail most often as early as you can. Three tests passing and the fourth failing means you spent the first three for nothing, and after the fix you pay for all four again.
Tools exist for the selection step, and they ask different things of you. Nx affected reads the changed files from git and runs only the tasks those files reach, as in nx affected -t test --base=origin/main --head=$PR_BRANCH_NAME. What counts as reached changed in Nx 24. Nx 23 and earlier select per project, where a change runs every task of that project “and of every project that depends on it”. The current default selects per task: Nx picks a task when your change touches one of its declared inputs, and “dependsOn alone doesn’t make a task affected”.
Neither model is a free win. For Nx, a project graph that matches your imports isn’t enough on its own. Selection reads each task’s inputs instead: if app:test lists only {projectRoot}/**/*, a change to the ui source doesn’t select it, even though app imports ui. Declare inputs and outputs even on tasks you don’t cache, and check any target whose inputs you wrote by hand. An upgraded workspace also starts out project-based, because nx migrate sets affected.legacy to true in nx.json. Develocity’s Predictive Test Selection trains on your build history instead. Its docs are specific about placement: the predicted subset in the early, frequent stages, local pre-commit checks and pre-merge CI. The rest goes in a later stage such as post-merge or nightly. That, in their words, “avoids executing any given test more than once for a given change”.
Stop running the same test three times
Selection shrinks each run. There’s a cheaper saving available first, and it costs nothing but a paragraph of instructions.
Why does the same test run three times for one change?
Because nobody told the agent where each test belongs in the workflow.
Watch an unsupervised agent work and the pattern is obvious. It runs the tests while it’s iterating, which is correct. You tell it to commit and push, and it runs them again. The pull request opens, and CI runs them a third time. We’ve seen this in organisations.
Once is often enough. The instruction you want in the agent’s configuration says which tests run while it works, which run before the push, and which are CI’s job. Add the rule that it shouldn’t repeat a run when nothing changed in between.
Be strict about what “nothing changed” means. Skip a rerun only when the source, the dependencies, the configuration and the environment all match the previous run. Keep the CI run in particular. GitHub’s pull_request event sets GITHUB_REF to the merge branch, so actions/checkout gives you the merge commit rather than your branch tip. The suite runs against an integration your laptop never had. The duplication worth deleting is the agent running the same suite against the same tree twice in a row.
You already decide what runs on the pull request and what runs post-merge. Now there’s a third actor in the loop with its own opinion about when to run things, and it won’t infer your pipeline design from the repository.
Testing Terraform is a plan, an account and some drift
Application tests are the easy case to reason about. Infrastructure changes have the same bottleneck with fewer options.
What does testing infrastructure code actually look like in practice?
terraform validate and terraform plan in CI, sometimes against a test account before anything reaches dev.
The common shape is a plan run locally to check the change does what you meant, then a second plan in the pipeline once everything’s integrated, then apply. Variations show up around the edges: a dedicated test account you run against before anything touches dev, or a platform team that applies to dev environments from their laptops. None of this is new. What AI changed is how often it happens.
Plan output is where it hurts. With 20 development teams on one system, plans get genuinely unmanageable, and the usual fix is splitting state into layers so each plan covers a slice. You’ll still get drift. We haven’t seen a setup that eliminates it, and you can close most of the gap without closing all of it. Treat a small amount of drift as a thing to detect rather than a bug to finish fixing.
There’s more tooling here than the plan-and-eyeball loop suggests. terraform test has been in Terraform since v1.6, running .tftest.hcl files and checking assertions, with -filter for running a subset. What it costs depends on the mode you pick. A run block defaults to command = apply. The language docs say that by default “tests within Terraform create real infrastructure”, short-lived resources Terraform then “attempts to destroy” at the end of the file. Set command = plan and it creates nothing for that block, which the docs describe as analogous to unit testing.
Provider mocking is a different thing from a test account, and the two get mixed up because both keep you out of production. Added in v1.7, a mock_provider returns the real provider’s schema and generates fake data for computed attributes, so a test runs “without creating infrastructure or requiring credentials”. A test account is the opposite trade: real provider, real calls, real resources to clean up. Creating nothing doesn’t make a run quick, either: Terraform queries data sources during the planning phase, so an unmocked plan is still calling the provider.
When the pipeline never stops running
Testing is the bottleneck you can see. The third one shows up as a pipeline that’s simply never idle.
What happens when pull requests arrive faster than the pipeline clears them?
The queue becomes the product, and one broken pipeline blocks everything stacked behind it.
A colleague described the failure mode to us. Pull requests were arriving so quickly that CI was running continuously, and then something broke the pipeline. Fixing it means committing a change. That change goes to the bottom of the queue, behind every pull request that’s going to fail for the same reason. So you’re manually promoting your own fix to the top of the queue just to unblock the rest. Everything after that works fine, which is what makes the story easy to dismiss until it’s your Thursday.
The capacity side of this is an old argument with a new deadline. We remember a company planning an on-prem to cloud migration, carefully sizing CPUs for production load. Production is the easy part, because you know what your load looks like. The integration environment is where elasticity actually pays, because that’s where demand scales with how many changes your team produces, and agents just multiplied that number. Fixed capacity means a fixed ceiling on throughput, and more changes only make the queue longer.
The hosted limits are worth knowing before you design around them. GitHub’s Actions limits put standard runner concurrency at 20 total jobs on Free, 40 on Pro, 60 on Team and 500 on Enterprise. Execution time is capped at 6 hours for a GitHub-hosted job and 5 days for a self-hosted one. A self-hosted job that’s waited in the queue for 24 hours gets cancelled. With queue: max in a concurrency block, up to 100 runs can wait per group. Those numbers settle what the platform does. They don’t settle what your own runner fleet or your test infrastructure does, which is usually the real ceiling.
How many agents your workflow can carry
The queue question has a direct consequence for the thing everyone wants to do next, which is run more agents at once.
What breaks first when you add a second agent?
The merge path, usually well before the code does.
One agent running end to end works, and on a personal project with no external users it works well. The loop runs from the command line, no IDE. We ask for a feature, the agent plans it, builds it, and starts Docker locally to check it runs. It pushes, opens a pull request, merges it, unit tests fire and the change deploys. Then it polls production. We’re already logged into the portal, so it opens that link in Chrome, checks the change is live, and reports back that the change is complete. You start it in the morning, go to work, and check the result later. The constraint that makes it work is that it takes one issue at a time.
Add three or four workers to that same factory and you get three or four agents committing code into the same repository. Pull requests stack up, and merging gets complicated fast. Run several agents in parallel on a setup that wasn’t built for it and they start going over each other. You get conflicts, agents stepping on each other’s changes, and work that needs untangling instead of reviewing. The useful skill is working out how many agents your setup can actually sustain, and that number is set by your merge path rather than your budget.
Control is also much easier alone than with even one more person in the repository. git worktree add gives each agent its own checkout against shared repository data, with its own HEAD and index. That’s the standard way to stop them colliding on files. Be clear about what it buys you: it separates the working directories, and it does nothing about two agents changing the same lines on two branches. That conflict still lands on whoever merges.
How much can you trust it without testing
Which leaves the question the whole argument has been circling. If the output is good, how much of this verification do you still need?
Can you skip tests when the agent is reliably good?
For small, standard things, people already are, and we disagree about where that stops.
Mattias Hemmingsson shipped a service with Stripe payments connected and didn’t test the payment path, on the reasoning that it’s a well-trodden integration and the tooling is good. His Kubernetes agent went further. It noticed a storage change and proposed moving a workload to cheaper storage, then copied the data and did the migration. By his account it checked things he wouldn’t have thought to check himself. His conclusion is that he trusts it with more, including his production cluster. He qualifies that himself: he doesn’t have a lot of clients on it, and maybe he shouldn’t do that for business.
Paulina Dubas’s line sits earlier. A simple website, fine, don’t care. Once you’re into a more complex project with a lot of modules, the complexity is still too high for what AI can do today. The model isn’t dependable at holding the full scope of a large system in view. Her own projects run high coverage, limited by the token budget rather than by effort. There’s also a human in the loop in most organisations, and how people operate is part of what sets the limit.
Both positions come from the same evidence. The disagreement is about where the complexity line sits. Put your own line somewhere explicit, rather than letting it drift upward every time the agent impresses you. If the excuse is that testing it means waiting for real time to pass, check first. Stripe’s test clocks simulate time moving forward in a sandbox, so renewals, trials, prorations and retries fire without the wait.
Key numbers
| Figure | Source |
|---|---|
| 300 files, the maximum in a single GitHub diff | GitHub repository limits |
| 10,000 to 20,000 lines, the greenfield agent pull requests we see | This episode |
| A few hours, a full test suite run after optimisation work | This episode |
| 20 to 500 concurrent Actions jobs, by GitHub plan | GitHub Actions limits |
What this means for teams
The bottlenecks don’t disappear, they move to the next station. How we’ve operated for years doesn’t automatically support an AI workflow, and the piece that needs the most attention isn’t the coding step everybody optimised first. It’s the workflow around it, which most teams have never written down in enough detail for an agent to follow.
Four things worth doing this week:
- Time the gap between “agent finished” and “deployed.” Measure review wait, test wait and queue wait separately. One of them dominates, and it’s usually not the one you’ve been tuning.
- Write the test map into your agent instructions. Which tests run during iteration, which before the push, which are CI’s job. Add the rule that it doesn’t rerun a suite when the source, dependencies, configuration and environment are unchanged.
- Pick a side of the merge for the full suite, and write it down. Pull requests get the tests that match the change. Whether the slow end-to-end run goes just before the merge into dev or just after is your call. It turns on what a broken dev branch costs the people working off it.
- Add agents one at a time and watch the merge path. Give each one its own worktree, then stop adding when conflicts start costing more time than the extra throughput buys.
Common questions, answered
Why can’t I see the whole diff on a large pull request on GitHub?
Split the pull request, because GitHub won’t render past its diff limits. A single diff is capped at 300 files, and a whole pull request diff at 20,000 loadable lines or 1 MB of raw diff. Each individual file has its own ceiling of 20,000 lines or 500 KB. Only the first 400 lines and 20 KB of a file load automatically, so the rest waits on a click. Portions of a limited diff still display, which is the dangerous part: the page looks like a diff with the rest of the change missing. Reviewing locally with git diff gets you the content but not the inline review workflow, so the practical fix is a smaller change.
How do I speed up a CI test suite that takes hours?
Cut what runs before you make what runs faster. Select tests by what the change touched on the pull request. Put the full suite on one gate around the merge into dev, before or after depending on what a broken dev branch costs. Order the remaining tests so the ones that fail most often run first, and failures surface early instead of at the end. Parallel execution helps after that, not instead of it.
How many coding agents can I run on one repository at once?
Start with one, and add another only when your merge path clears faster than the agents fill it. Give each agent its own git worktree so they don’t collide on files, then watch for conflicts between branches, which worktrees don’t prevent. Several agents on a setup that wasn’t built for it go over each other’s changes, and untangling that costs more than the parallelism earned. The sustainable number is a property of your pipeline and review capacity.
Related episodes
- Episode 107, Continuous Integration in 2026: What Still Matters covers where slow tests belong and what a merge queue does when changes arrive faster than tests finish.
- Episode 113, Books, Juniors and Mattias’s Dark Factories examines Mattias’s dark factory workflow and where human approval belongs.
- Episode 94, Small Tasks, Big Wins: The AI Dev Loop at System Initiative goes deeper on running several agents in parallel with git worktrees, and on the test tiers that catch what review can’t.
- Episode 89, Agents, Reviews, and Secrets: Real Talk on AI in Dev covers agents reaching into repositories and pipelines, and what they can read while they’re there.
- Episode 101, Infrastructure as Code in 2026: Still Essential or Already Changing? is the wider IaC picture behind the plan-and-drift problem.
Resources
- GitHub repository limits settles the exact diff caps: 300 files, 20,000 loadable lines or 1 MB per pull request, 20,000 lines or 500 KB per file.
- GitHub Actions limits gives the concurrency numbers per plan, the job execution caps of 6 hours hosted and 5 days self-hosted, and the 24 hour queue timeout.
- Nx affected settles how task-based selection works from each task’s declared inputs, and how
affected.legacykeeps the project-based behaviour of Nx 23 and earlier. - Develocity Predictive Test Selection is the machine-learning approach to the same problem, and its docs put the selected subset early and the remaining tests in a later stage.
- Terraform tests settles what a test actually provisions:
applyby default,command = planwithout creating infrastructure. - Terraform test mocking settles what a mocked provider replaces, and that a mocked test needs no credentials and creates no infrastructure.
- Google Cloud, announcing the 2025 DORA report is the research on AI adoption’s positive relationship with throughput alongside its continuing negative relationship with delivery stability.
- git worktree is the primary reference for giving each agent an isolated checkout against shared repository data.
