In a small test, keeping an agent's thread alive cost less than resetting it
· 4 min read
The thread is the message history a role carries from one turn to the next. Recycling it means starting the next turn from scratch, with less context and, on the face of it, cheaper.
Across production roles, the floor of a turn (the tokens the first call already carries) tracked the recycling interval:
| Recycling interval | Mean floor (tokens) |
|---|---|
| Every turn | 50,104 |
| Every 5 turns | 110,034 |
TABLE 1 · Observed across production roles, nothing controlled.
That suggests resetting often halves the floor. But the roles that keep long threads are also the ones with the biggest jobs, so the table cannot separate the two.
The experiment
One role, one model and one trivial task, in an isolated test team. The only change was the recycling interval: variant A reset the thread every turn, B every five. Of eight rounds I discarded A’s first (round 5), which ran right after an engine change, so it is 3 rounds against 4.
| Variant | Round | Tool calls | Cache read | Cache written | Weighted window |
|---|---|---|---|---|---|
| A · reset every turn | 6 | 5 | 104,020 | 21,284 | 50,013 |
| A · reset every turn | 7 | 5 | 104,325 | 20,905 | 47,532 |
| A · reset every turn | 8 | 6 | 105,101 | 21,435 | 50,257 |
| B · reset every 5 | 9 | 4 | 104,084 | 20,880 | 46,409 |
| B · reset every 5 | 10 | 4 | 141,982 | 8,348 | 40,569 |
| B · reset every 5 | 11 | 3 | 107,933 | 5,314 | 26,029 |
| B · reset every 5 | 12 | 4 | 182,215 | 6,759 | 34,486 |
TABLE 2 · “Weighted window” is the turn’s cost in equivalent tokens: cache writes at 1.25×, cache reads at 0.1×, as the provider bills them.
The mean weighted window was 49,267 for A and 36,873 for B, 25% lower. B also averaged 3.8 tool calls per turn against 5.3.
Cache rebuilt per turn, by variant
Lower is cheaper. A cache write is billed at 1.25× a read.
FIG. 1 · Variant A rebuilds the whole cached prefix every turn. Variant B pays once, then reuses it.
Cache writes
With a reset every turn, the role rewrites its whole cached prefix (instructions, tools, history) every time: about 21,000 tokens in each of A’s rounds, billed at the premium rate. B’s first round does the same because its thread is new. From the second round on, writes drop to 5,000–8,000 tokens. Cache reads go up (141k, 182k), but they are the cheap part.
So a short thread does lower the floor, and pays for it by rebuilding the cache every turn. Reads keep growing while the thread lives, so a longer thread is not free either; I did not measure where the two costs cross.
Why B needed fewer tool calls I don’t know. My hypothesis is that it did not have to re-read files it still had in context.
Next
The test role stayed on B. Next is sweeping the interval from 1 to 10 with the same role, then repeating it with a role that actually uses tools, which accumulates history faster. Production roles change after that, one at a time.
How this was measured. Eight rounds in an isolated test team with no production traffic. Same role, same model, same trivial task; the only variable was the thread-recycling interval. Thread reset between variants so the second could not inherit the first's cache. One round of variant A discarded, so the comparison is 3 rounds against 4.
Related
- The occupancy trigger compacts context without knowing how many calls are left Compaction has a fixed cost and a saving per remaining call. In 13 measured compactions the crossover was around 17 calls left. Occupancy can't see that number; each role's turn history can estimate it.
- 38% of my agents' message deliveries never reached the recipient's prompt 11,845 deliveries in 312 rounds of one team, and 4,445 discarded by the mailbox cap before the recipient saw them. With a fan-out of 3.37×, every role was telling everything to almost everyone.