How long does your agents' code survive?
· 5 min read
In September I measured how many lines of my agents’ code survived over time in a production repository, and got 85.9%. Two days earlier it had been 92.7%. A single percentage depends on the day you take it. Measured week by week, though, it tells you how much of your code gets replaced quickly and how much survives. Here is how I ran the thirteen-week measurement and what I concluded.
The recipe
It is a survival table: you group what was written each week into a cohort and look at each cohort at different ages.
- One snapshot per week: the last commit of each Sunday on the branch where work is integrated.
- In each snapshot,
git blamesays which commit wrote each line that is still there. git log --numstatsays how many lines each commit added.- For each cohort and each snapshot: lines alive divided by lines added.
The script that does all four steps is in my resources repository, with its README. It needs Python 3 and git, nothing else. Before running it, check three things:
- The branch. The one that gets work day to day, not the one that only gets releases.
- The extensions that count as code. Add your language’s if they are missing.
- What counts as a test. By default, the
test/,tests/andspec/folders and.test.or.spec.files. They are left out unless you ask to include them.
Then give it the repository, the branch and the date to measure from:
python3 survival.py ~/my-repo develop 2026-08-24
You get one row per week with the lines written and the share still alive when that week closed
(wk1), a week later (wk2) and so on until today. To compare weeks, look at them at the same age:
recent ones have not had time to be rewritten. With thirteen weeks and about a thousand files it takes
under three minutes. My own output is in the same repository.
What moves the number
Age. Yesterday’s lines have not had time to be rewritten. If you add everything into one percentage, the number goes up every time new code comes in:
| Snapshot | Lines added since 24 Aug | Still alive | Survival |
|---|---|---|---|
| 30 Aug | 8,842 | 8,726 | 98.7% |
| 6 Sept | 28,967 | 26,998 | 93.2% |
| 4 Oct | 56,122 | 47,348 | 84.4% |
| 1 Nov | 87,214 | 75,179 | 86.2% |
| 22 Nov | 119,171 | 105,465 | 88.5% |
TABLE 1 · Overall survival in five of the thirteen snapshots. Between 15 and 22 November, 30 thousand new lines came in and the total rose two and a half points.
The branch. My repository integrates on develop and reaches the main branch through releases.
Measured on main, 4 October gave 88.0% instead of 84.4%. Code that had not reached a release yet did
not count.
Tests. They are 57% of the lines I added in these thirteen weeks, and in the week of 16 Nov they
were 16,480 of 22,741. Here they survive almost like the rest (80% against 79% at twelve weeks), but a
month with many tests moves the total. The script leaves them out unless you pass --with-tests.
The author. In September my agents signed commits with my name, so the git author did not say who wrote what. If you want to split by agent, check how they sign first.
The date. Each commit goes to the cohort of the week of its author date. A branch integrated a week later adds lines to an old cohort, and the latest cohort can keep growing until the last branch of that week lands.
What it gave me
The code my agents write gets rewritten less and less
Each line is one week of work. It starts at 100% and drops when that code is rewritten or deleted.
FIG. 1 · One production repository, integration branch, one snapshot per Sunday from 30 Aug to 22 Nov 2026. Code only, no tests.
The same weeks, on the calendar
Each line starts at 100% on the Monday of the week it was written and follows each Sunday snapshot.
FIG. 2 · Same data as figure 1. Each week of writing starts where it began, so you can see when each one lost lines.
Rewriting happens early. What was written in the week of 24 Aug had 91% alive at eight weeks and 89% at twelve, and the week of 31 Aug, 77% and 74%. What was not rewritten in the first month or two mostly stayed. Human-written code behaves the same way: across 89 repositories, young lines are the ones most likely to change or be deleted (Spinellis et al., 2021). And in public repositories, agent code is rewritten more than human code in its first weeks (Popescu et al., 2026).
From October on, at the same age, much less gets rewritten. At four weeks, the August and September cohorts had between 70% and 93% alive, and the October ones between 93% and 99%.
The change lines up with how work comes in. Until mid-September, about 90% of commits went straight to the integration branch, with no branch of their own and no review. In the week of 5 Oct that dropped to 3%, because work started coming in through pull requests, and since the engine change on 12 Oct it is 0%. The 5 Oct cohort, the first to come in almost entirely through pull requests, is also the first with 96.5% alive at four weeks.
How work reached the integration branch, by week
Merged branches by kind. Below, the share of commits that went straight to the branch, lines added and active agents.
FIG. 3 · Same repository. Until 5 Oct, roles with turns in the first engine; from 12 Oct, agents with runs in the second. Syncs and releases are left out.
Volume alone does not explain it. The weeks of 31 Aug and 16 Nov added almost the same, about 22,700 lines counting tests. In its first week, the code from the November one lost 4% and the code from the August one, 7%. Active agents ranged between 5 and 10 per week, while merged branches went from a handful a week to 94 in the week of 16 Nov.
The big drops come from a few commits. The week of 28 Sept lost over a quarter of its code before it closed, and more than half of that loss is three commits from 2 and 3 October that were redone within days. The worst commit is still the one from 4 September, which added 2,408 lines and has none alive.
Next is separating the causes: running the same recipe on the other repositories of the new engine, measuring how much is redone inside each branch before it is merged, and splitting it by agent, now that each one signs its commits.
How this was measured. git blame over every code file in 13 weekly snapshots (each Sunday, 30 Aug to 22 Nov 2026) of the integration branch of a production repository written by agents, plus the lines each commit added since 24 Aug according to git log. Each commit counts in the week of its author date. Tests are split out by path. 119,171 lines added over thirteen weeks. A line counts as alive if git blame still attributes it to its original commit, so moving or reformatting code also counts it as rewritten. Task branches are merged with a merge commit, not squashed, so what was redone inside a branch is counted; what an agent redid before committing is not visible. It is a single repository, and in October the way work was integrated, the engine and the age of the product all changed at once. Code quality is measured separately.
Related
- 86% of my agents' code is still there, and most of the drop came from one week Line survival on a production repository written by agents: 85.9%, down from 92.7% two days earlier. Most of the lines lost in between belong to one week and one 2,408-line commit that survived at zero.
- The nine-role team costs 3.5× more per verified task than the four-role one I compared eight agent teams on cost per verified task. The gap follows tool calls per turn, and splitting the large team would not change what its two most expensive roles do.