cache-tax 1.0.2: price the carried summary after a compaction - #62
Merged
Merged
Conversation
…he context it replaced
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.
Summary
readLastUsagenow notices acompact_boundarysystem row that is newer than the last usage block. Compaction writes that row and no usage row, so before this the status line, card, guard and resume fallback all kept pricing the pre-compaction context.compacted: context iscompactMetadata.postTokens, the cost is a floor at the 1h write rate,lapsedis false. Guard and resume stay silent; status line readscache reset by /compact · 17k carried · next msg writes ≥ $0.34(orauto-compact); the card explains the reset. A usage row newer than the boundary takes over, so the state heals on the first real turn.Details
On a real 562k session,
/compactat 19:42 IST left the row atLAPSED 5h20m ago · next msg re-writes 562k = $11.23while the context bar read 0%. The first message after that compaction wrote 39,967 tokens ($0.80) against a 30k cache read. Replaying 1.0.1 on that transcript truncated at the boundary row, inCACHE_TAX_BLOCK=1mode, refuses the prompt with exit 2 for $11.23; 1.0.2 exits 0 and prints nothing.parseBoundaryLinereadstype: system, subtype: compact_boundaryand itscompactMetadata(trigger,preTokens,postTokens). All 91 boundary rows on this machine carrypostTokens; 89 are manual, 2 auto. The block before the boundary is kept only for the model, so pricing still works. A boundary with no usage row before it rendersnext msg writes the summary fresh.README: the slash-command paragraph now says what the row shows after a compaction; Limits gains two bullets, the floor (system prompt and tools are not in the transcript) and the fact that the compaction request itself re-sends the whole context and is not written to the transcript, so
/clearplus a handoff note remains the cheap exit from a cold cache. The old "or a compaction" clause in the newest-turn bullet is gone because it is now handled.Test plan
node --test plugins/cache-tax/tests/cache-tax.test.js32/32npm test1928/1928LAPSED ... 562k = $11.23and blocks (exit 2); 1.0.2 printscache reset by /compact · 17k carried · next msg writes ≥ $0.34and exits 0claude plugin update cache-tax@claude-code-hooks, then/compactin a live session and check the 🧊 row before the first new turn