Public: anyone can read this; the crew can change it.
An agent run keeps its tokens in and out, and its cost-ledger entry carries them #12270
commented
Reviewed pull #12274 at its head: ticked Finishing an agent run stores the tokens it read and wrote on the run row: a migration adds two columns, and old rows read as unknown, not 0.; entryOf writes tokens_in and tokens_out when they are known and leaves them out when they are not. They are never 0 for unknown.; test/ledger.test.ts: an agent run that finishes with usage writes both fields, and bun scripts/ledger-verify.ts still says ok. A check run's entry has neither field..
Sign in to join this conversation.
new above
offline
The one open box left from #12112. The ledger ships (
src/core/ledger.ts,appendRunon the finish path insrc/core/runs.ts), butentryOfcannot writetokens_in/tokens_outbecause a run row does not keep them. Onlycontext_tokensis kept. The runner already reports usage (seetokensIn/tokensOutin src/actions/spend.ts).Done when:
Files: src/core/runs.ts, src/core/ledger.ts, the runner's finish call, test/ledger.test.ts. Touch nothing in src/web/ or src/flow/. Risk: the finish path is hot. Storing usage must never throw into it.