Repository navigation
fix(band): book each turn's cost on the task, so a reload or /clear keeps the total right - #1402
Open
dev-tembang wants to merge 1 commit into
Open
dev-tembang wants to merge 1 commit into
dev-tembang wants to merge 1 commit into
Conversation
…eeps the total right The band set a task's cost to the engine's running total. That total goes on across /clear, so a new task started with every earlier task's cost (DietrichGebert#1343), and it starts over in a new process, so after an IDE reload the band showed $0.00 and the next turn wrote the smaller number over the task's ledger row. Each turn now adds its own share (the engine total minus the baseline) to the task, a band that starts again takes the cost back from the task's row, and /resume or /branch to another session starts that session's own counters. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1343. Also fixes the "band shows $0 after a resume" part of #1188 (not the day bucketing, which is a separate change).
Problem
turn.completeset the task's cost to the engine's running total:Because
usage.cost.usdis always set, the per-turn fallback never ran. That total is wrong in two directions:/clear: the engine total goes on, so a new task starts with every earlier task's cost (Task Cost Isolation Broken Across/clearvia Nullish Coalescing Fallback #1343).--resume): the engine total starts over at zero.resume()brought back agent time, tokens and the name from the ledger row, but not the cost. The band showed$0.00, and the next turn wrote the smaller number over the task's row. The board then lost the money the task had already cost.Seen on Windows in the VS Code-style extension: a task with
11.62in its row showed$0.00next to its restored33m 12sof agent time.Fix
turn.complete:spent: b.spent + turn. Each turn adds its own share, the engine total minus the baseline, which already handles a total that drops.resume(): also takes the cost back from the task's row (Math.max, like agent time).start(): when the session id changes (/resume,/branch), the band resets the task counters beforeresume(). Until now the engine total covered this up, so the old session's cost doesn't carry over.Tests
resume()test: checks the cost comes back, and that a band already ahead keeps its own number.11.62booked, engine0 → 0.5, row shows12.12), and a task after/clear(engine0.5 → 0.55, no row, row shows0.05). Both fail onmainand pass here.claude plugin test .: 27 pass, 7 fail. The same 7 also fail onmainon this Windows machine (bodyColumns,/ponytail band,/clear//resume//branchlevel, transcript lookup), so they're unrelated to this change.node scripts/check-rule-copies.jsandnode scripts/check-versions.jspass.npm test(thenode --testsuite). It doesn't touchhooks/band/.🤖 Generated with Claude Code