Repository navigation
Name the reason when the mod says the cache broke - #16
Merged
Merged
Conversation
The toast said "cache expired after N min idle" for every cache loss after a 5 min gap. After a /clear-tools or /compact it blamed the clock, and in sessions with a 1-hour cache it said "expired" for gaps the cache outlives. A loss with no pause gave no toast at all, though a change at the start of the request is the case worth a look. The mod now checks the reasons in the engine's order: compaction, model switch, idle past the lifetime, else a prefix change. It cannot ask the engine: the engine runs only while the viewer is open. Claude Code's TurnUsage has no 5 min / 1 h split, so the mod learns the 1-hour lifetime when the cache holds over a pause longer than 5 min; until then a 5-60 min gap names both causes.
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
The mod's cache toast now names why a Call lost the cache, in the same order as the engine's cache breaks.
TurnUsagehas no 5 min / 1 h split. The mod learns the 1-hour lifetime when the cache holds over a pause longer than 5 min. After that, the cost uses the 1 h write price (2×).Livefields:compacted(set bysession.compact, but not forprecompute; cleared by the next Call) andhourCache.Evidence
/clear-toolscame after a 41 min pause. The toast said "cache expired after 41 min idle". The engine'sv_cache_breaksgivesreason = compactionfor that Call, and the Calls before it wrote 1 h cache entries.After:
packages/mod/test/nudges.test.ts, one test per reason (red before the change, 57/57 green after):pnpm checkpasses.Merge Danger
Door: two-way
Only the toast text and when it shows change. No stored data changes.
Blast Radius: toasts
A cache loss with no pause now gives a toast, where before it gave none. If the 50 % read share gives a false positive (for example, a Call right after a large re-measure), the person sees a toast that is not needed.