Skip to content

exec: a leaf's landing reserve is bounded in tokens, not just turns - #624

Merged
AbirAbbas merged 8 commits into
devfrom
fix/541-the-token-budget-is-a-wall
Sep 8, 2026
Merged

AbirAbbas merged 8 commits into
devfrom
fix/541-the-token-budget-is-a-wall

Conversation

@AbirAbbas

@AbirAbbas AbirAbbas commented Sep 4, 2026 •

Copy link
Copy Markdown
Collaborator

The token-budget landing now stops after four turns or a fifth of the grant, whichever is exhausted first, while retaining at least one complete landing turn.

Review corrected the documented ceiling: both the budget-crossing turn and the final landing turn can overshoot their respective limits because usage is known only after a call. PERF.md, the headless guide, and the manual now state both overshoots.

Validation: focused budget/no-progress tests passed three repetitions; full exec recheck passed in 62.645s; full clean baseline passed in 60.182s; manual tests and canonical make build passed. One initial heavily concurrent run hit the spinning-leaf test's one-minute deadline; it was not reproduced by the subsequent baseline and modified runs. No skip or threshold was changed. No private model trial was replayed.

Closes #541

AbirAbbas and others added 4 commits September 4, 2026 09:34
…541)

The reserve granted when a leaf spends its grant was four turns and nothing
measured what those turns cost. On a leaf whose turns bill 30-39k tokens that
bought a second grant: measured on the worker trial of 2026-09-03, four landing
turns billed 122,392 tokens against a 150,000-token grant, and four leaves
reached 1.18x, 1.28x, 1.74x and 2.04x of what they were given.

The reserve now ends on whichever of its two halves arrives first —
landingTurns, or landingTokenShare of the grant measured from the spend at the
crossing. The reading is taken after a turn is billed rather than before one is
bought, so a landing always gets the one whole turn that leaves the workspace
consistent, and never four turns of a grant already declared spent. The
deadline landing is untouched: it is bounded by its own clock.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
PERF.md's leaf-bounds table carries the landing reserve and both of its halves,
and says what a caller actually gets: the grant, plus landingTokenShare of it,
plus the one turn already in flight when the ceiling is crossed. HEADLESS.md
says the same about --token-budget in the words of somebody driving the binary.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
The page said a worker that crosses its budget is given a few final calls. It
is, and those calls are now also bounded by a slice of the budget — whichever
runs out first ends the landing, and a worker always gets at least one whole
landing call.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Co-Authored-By: Claude Fable 5.1 <[email protected]>
@AbirAbbas
AbirAbbas merged commit 65f060d into dev Sep 8, 2026
3 checks passed
@AbirAbbas
AbirAbbas deleted the fix/541-the-token-budget-is-a-wall branch September 8, 2026 14:26
@santoshkumarradha santoshkumarradha added the area:headless codeaf do and codeaf exec, runs with no screen label Oct 3, 2026
@santoshkumarradha santoshkumarradha added this to the Reliable agent milestone Oct 3, 2026
santoshkumarradha pushed a commit that referenced this pull request Oct 24, 2026
…ent it

#624 was the last merge that weighed in under the cap. By dev@5b60def7 the
binary had grown 1,908,736 bytes and crossed a number nobody moved, so `make
check` — the ritual CLAUDE.md sends everybody to — stopped at its last step for
every change on dev, whatever that change touched. Nobody caused it and nobody
could clear it from inside their own work.

The first of the two honest moves was looked for and is not there. The range
added no dependency; the only embed that grew is the chat manual's own pack,
already gzipped and required by the manual law. What is left is compiled
first-party code — .text +1,030,464 and .gopclntab +592,718 of the 1,908,736,
against +26,203 net non-test lines in internal/tui3 and +13,011 in
internal/session. Of the dependencies, the three that weigh anything sit behind
the store and behind the JavaScript a saved program is written in; dropping
either is a product decision and not a size fix, and taking all of goja and its
collation tables would still leave darwin/amd64 over the old cap.

So the number rises, with its measurement beside it, which is that section's
own standing rule. 57,488,000 is two percent above darwin/amd64 at 56,360,432 —
the heaviest of the four platforms, each built with its own furrow staged — the
same headroom every figure in that section was given.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:headless codeaf do and codeaf exec, runs with no screen

Projects

None yet

Development

Successfully merging this pull request may close these issues.

do: the token budget was overrun 1.7x with no stop and no line

2 participants