Status: done (2026-11-24)
Priority: 3
Size: M
Design ref: docs/review-agent-workflow.md, sections 2, 6 and 8 (the three measures); docs/agents/README.md; .claude/agents/vb-task.md, step 8 (the ceiling); tools/agent-usage.js, tools/usage-page.js, tools/inbox.js (calls)
Goal: Changes to how agents work are judged by comparing periods. A dated log of the changes that may move token use marks where each period starts, and tools/agent-usage.js and tools/usage-page.js compare periods stratum by stratum. Each run records the measures that VB-1616 (adaptive context resets) is judged by, so that its period can be compared with the period before it. Nothing here changes how an agent works: the ceiling, its warning and the continuations stay as they are.
Acceptance criteria:
docs/agents/changes.md: a row per change, giving the date and time (UTC), what changed, the files, the measure it is expected to move, and a ref. Seeded from docs/review-agent-workflow.md and git log: tools/backlog.js (7 Nov), one task a sub-agent (9 Nov), side by side and the inbox (14 Nov), named tools and tools/brief.js (15 Nov), the 120-call ceiling (18 Nov), and each change of the model a size runs on. A line in docs/agents/README.md says that a change to agent instructions (AGENTS.md, .claude/agents/, docs/agents/), agent tools, models or the ceiling adds its row in the same commit.node tools/agent-usage.js --history docs/agents/usage --periods docs/agents/changes.md [--from DATE] [--to DATE] compares the periods between rows. For each stratum (run kind: sub-agent, single-task session, orchestrator; size; model) it gives n, the median and the quartiles of: the weighted cost of a done task, summed over all of its runs, continuations included (as tools/usage-page.js sums them); calls a task; runs a task; the cache-read share; peak context; boot; and the quality measures below. A stratum with fewer than 5 tasks in a period is shown and marked, not compared. --json gives the same.measure()), each tested on a small constructed transcript in tests/agent-usage.js:
context.series: the context at every 5th call and at the last, so that a reset’s counterfactual follows the measured curve rather than a straight line;repeats: count and bytes of reads of something already read in the same run: a file, or a range of one (Read; cat, sed -n, head, grep on a named file), or a document section (tools/doc.js with a heading); and of identical commands run again with no edit between them;tests: runs of npm test, npm run verify and node tests/NAME.js, how many failed, and the longest streak of failures of one script;continuation: whether the run continues a task (its prompt says “continued from”), the bytes of the handover it was given, and its reconstruction: calls and context added before its first edit (boot − first);compactions: the context compactions in the transcript, if any; a run with one is flagged, since that is a reset of another kind.Fix: or Mend and names it; criteria ticked against criteria in its file at the end.node tools/inbox.js calls also works in a single-task session: outside an agent-<id> worktree it reads the session’s own transcript, found as tools/agent-usage.js finds it. Beside the count it prints the context and the weighted cost so far (86 of 120 calls; context 152k; weighted 1.9M). CEILING, WARN and CONTINUATIONS unchanged; tests/inbox.js covers the session case.tools/usage-page.js shows the periods: the log’s rows as marks on its charts over time, and the period comparison of the second criterion as a table. tests/usage-page.js covers the table.docs/review-agent-workflow.md: for the runs since 18 November (the ceiling’s period), the cost a voluntary reset at context T would save against the 120-call ceiling alone, for T of 100k, 130k, 160k and 200k tokens; a handover of 5k, 15k and 30k tokens; and 0, 6 and 15 calls of re-reading. Use context.series where a run has it and the linear fit from first to peak otherwise. Give the share of tasks each T would reset and the value of T it proposes for VB-1616. Say plainly that it is an upper bound on cost and says nothing of quality.docs/commands.md describes the new options. npm test passes; npm run format changes nothing under src/ (none is touched).
Method:calls line, logged as a row of its own.docs/agents/usage, linear context growth). Since 18 Nov there are 108 measured runs (80 of them size S), 78.0M weighted tokens. Context grows a median 1.3k tokens a call (quartiles 1.1k to 1.8k), and cache reads are 60% of the weighted cost. Against the ceiling, resetting on size alone saves at most about 3% at T = 130k to 160k, and loses about 1% at T = 100k. Before the ceiling, runs over 120 calls took 39% of the cost. Long runs are now mostly single-task sessions, which have no counter: 144, 145 and 174 calls on 23 and 24 Nov.inbox.js calls in a session prints its calls, context and cost but no ceiling or hand-over warning (“69 calls (a session: the ceiling of 120 is a sub-agent’s); context 265k; weighted 2.0M”): the ceiling is a sub-agent’s, and this task changes no agent’s behaviour; VB-1616 decides a session’s reset. calls no longer needs an inbox. (2) The comparison reuses the usage page’s task model (a task is all its runs) rather than a model of its own; a task belongs to the period its first run started in. (3) The rows before 24 Nov have commit times from git log (the clone had to be unshallowed); model changes logged are those the docs state (9 and 16 Nov). (4) Repeats count a read again only with no edit to its file between, and any Bash command that may write (sed -i, a redirect, git merge…) clears them all. (5) The reopened proxy is real but loose: a red night’s “Fix:” task names every suspect (VB-1313 names five).docs/review-agent-workflow.md): no run yet has context.series, so all curves are straight lines. T = 160k proposed: 3.9% of the cost since the ceiling at a 15k handover and 6 calls of re-reading, nearly all of it in single-task sessions (5.7% of theirs, 32 of 39 reset; sub-agents 1.1%, 2 of 99); a loss once re-reading reaches 15 calls below T 200k.