Seven green pull requests merged in two minutes and broke main
Our AI coding agents open pull requests faster than we merge them. On 30 November 2026 we cleared a backlog: seven pull requests, every one green, every one shown as clean by GitHub. We merged them one after another in u
Our AI coding agents open pull requests faster than we merge them. On 30 November 2026 we cleared a backlog: seven pull requests, every one green, every one shown as clean by GitHub. We merged them one after another in under two minutes. The next run on main failed.
What happened
All times are UTC, from GitHub.
| Time | Event |
|---|---|
| 00:52:45 | First pull request merges |
| 00:54:42 | Seventh pull request merges |
| 00:54:45 | CI starts on main. Lint fails |
| 01:35:31 | The fix merges |
| 01:35:33 | CI starts on main again, and passes |
Our lint step has a size rule: no source file over 500 non-empty lines. One file of database table definitions now had 501.
Typecheck passed. Lint failed, and the eight jobs behind it were skipped, every test job among them. So for 41 minutes main was red, and it had no test results at all for seven freshly merged changes.
How a green pull request does that
Here is the history of that one file on main:
| When | What happened | Non-empty lines on main |
|---|---|---|
| 24 November | Before either change | 499 |
| 24 November, 13:48 | Pull request A passes lint for the last time. It adds one line, which makes 500 on its branch | 499 |
| 25 November | Pull request B merges. It adds one line | 500 |
| 30 November, 00:54 | Pull request A merges, with its tick from the 24th | 501 |
Two changes, one line each, in different parts of the file. Git saw no conflict, because the lines did not overlap. Each change was inside the limit on the main it was tested against. Together they were over it.
GitHub showed all seven as clean because our main branch did not require a branch to be up to date before merging. A green tick means the change passed against the main that existed when the check ran. It says nothing about the main of today.
We looked at the last lint run on three of the seven. At the moment of merge those ticks were 15 hours, two and a half days, and five days and eleven hours old. The oldest one was the one that broke main.
The fix was mechanical: split the file in two, 110 lines added and 104 removed. It merged 41 minutes after the red run started.
Not the first time
On 4 November the same size rule caught the same shape on a branch. A local check said the branch merged cleanly. After merging main in, lint failed on a different file with 501 non-empty lines. Each side had added one line to a 500-line file.
On 9 September, in another repository, two pull requests each added a type with the same name to the same file. They merged 1 minute 52 seconds apart with no conflict, and main stopped compiling. The fix merged 44 minutes later. Our notes record a second pair the same night, that time two functions with the same name.
Every one of these has the same cause. Git checks whether two changes touch the same lines. The linter and the compiler check the whole file and the whole program. Two changes can each be fine alone and broken together, and nothing looks at them together until they are both on main.
Agents make this more likely in two ways. They work in parallel, so pull requests queue up waiting for a person to review them, and the ticks age while they wait. And they tend to add to the same shared files: a list of tables, a list of routes, an index of exports.
What we do now
Before merging a batch, we merge the batch together locally on top of the current main and run lint and typecheck on the result. Roughly:
git fetch origin
git switch --detach origin/main
git merge --no-edit origin/branch-a origin/branch-b origin/branch-c
Then lint and typecheck. It takes about two minutes. If the batch is red together, we find out before main does.
The slower option is to merge one, wait for CI on main to finish, then merge the next.
GitHub can enforce this for you. The branch setting "Require branches to be up to date before merging" makes every pull request re-run its checks on the current main. A merge queue tests each pull request on top of the ones ahead of it. We had neither switched on for this repository. With a deep backlog of agent pull requests the first setting means a lot of re-running, so the merge queue looks like the better fit.
Splitting work so fewer agents touch the same shared files in the first place is in our guide, How to stop AI coding agents editing the same files.
Disclosure
We build KoalaFix, a tool for coordinating a team's AI coding agents, so we have an interest in this topic. Weigh what we say with that in mind.
This post was drafted with AI assistance and checked by a founder.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.