# From hours to minutes: one team's month of merges

> One team took its median wait from submit to main from almost eight hours to under three minutes. Here is what it changed, in order.

Gudjon Gudjonsson, Founder and CEO of OZ. 2026-11-25. Source: https://getbay.io/blog/from-hours-to-minutes (HTML).

bay is for teams that run many coding agents in one codebase, often on the same files. Each agent submits once, and a runner merges only what passed on the latest main. One team has merged every change through bay for a month, up to 749 changes in one day. Its median wait from submit to main fell from almost eight hours to under three minutes. This post shows its numbers, and the six changes behind them, in order.

## The numbers

We read the team's main branch and bay's own records, by UTC day. The wait runs from `bay merge` to the change on main.

| Day | Merged through bay | Commits outside bay | Median wait | 85th percentile |
|---|---|---|---|---|
| 26 October | 143 | 67 | 465 min | 960 min |
| 28 October | 504 | 1 | 47 min | 114 min |
| 30 October | 476 | 3 | 8.3 min | 44 min |
| 16 November | 749 | 0 | 35 min | 103 min |
| 24 November | 374 | 0 | 2.4 min | 7 min |

> 16 November was the busiest day: a burst of changes made a line, and it cleared by the next day.
> These are one team's numbers, on its own checks and machines.
> Measure your own before you plan on them.

## 1. Send every merge through bay

On 26 October, 67 commits reached main outside bay. Each one moved main, so every check in flight was stale and ran again. bay's agent hook refuses an agent's own push of main, so the team moved its people and tools too. From 31 October on, no commit reached main outside bay.

## 2. Batch the line

With checks of a few minutes, one change at a time could not keep up. With `batch`, the head's runner checks the head and the changes behind it as one tree. On a pass, they all merge in one push. bay sizes each batch from the recent failure rate, and stops batching above `max_failure_rate`. On 27 October, the team merged 493 changes, more than three times the day before.

```toml
# .bay/config.toml
[runner]
batch = { min = 2, max = 8, max_failure_rate = 0.3 }
```

> Like `ahead`, it needs a key registry that signs everything, or `reuse_unsigned = true` in the policy.

## 3. Skip the checks a change does not reach

Batches still left a long line: on 28 October, the median wait was 47 minutes. That afternoon, the team gave every pre-merge check `when_paths`. A change that touches none of a check's paths skips it, and the result lists it under `not_required`. The team also ran each change's checks side by side, with `parallel_checks = 4`. On 30 October, the median wait was 8.3 minutes.

```toml
# .bay/policy.toml
[[check]]
id = "docs-lint"
environment = "linux-x86_64"
command = "scripts/bay-check docs-lint"
when_paths = ["docs/**"]           # a change elsewhere skips it

# .bay/config.toml
[runner]
parallel_checks = 4                # run a change's checks at once
```

## 4. Move slow whole-tree checks after the merge

Some checks read the whole tree and take minutes. The team runs them as post checks, after the merge, so they never block one. They run in an environment that one machine serves, so the other runners stay on the line. When one fails, main turns red, and bay refuses a change that adds a failure on its paths. A pre-merge check with `commit` or `history` inputs keeps each change it wakes out of a batch. The team runs those after the merge too.

```toml
# .bay/policy.toml
[[check]]
id = "whole-tree"
stage = "post"
environment = "post-checks"        # only the machine for post checks serves it
command = "scripts/bay-check whole-tree"

# .bay/config.toml
[runner]
post = true
bisect_post = true                 # find the merge that turned main red
```

## 5. Check the next batches early

While the head checks, runners that do not hold it check the next entries on the main it will make. When an entry's turn comes and main is as predicted, it merges on that check. The team runs several runners with `ahead = 16`, the most bay allows. Another runner alone did not shorten its line, as When to add another bay runner tells.

```toml
# .bay/config.toml
[runner]
ahead = 16
```

## 6. Let agents wait in the background

An agent that reads `bay status` again and again spends a turn on each read. Since bay 0.7.5, an agent starts one background wait instead, and hears when its change merges. The bay skill teaches it to every agent.

```sh
bay merge c7k2m4qa --wait=3600   # in the background: it returns when the change merges, or after an hour
```

## Read before you change

Each step came from reading why changes waited, not from a guess. A change's `waiting_for` says why it waits, such as `runner`, `worker` or `queue`. `detail.batch.stopped` says why a batch ended, and the runner's journal says why one never formed. Merge more changes a day, in the docs, explains each setting.

```sh
bay queue            # the live line, head first
bay status --all     # each runner: machine, environments, last pass, held change, queue depth
```
