Skip to main content

Module cache_stats

Module cache_stats 

Source
Expand description

Prompt cache misses: prompt tokens that were in the previous request’s prompt but were billed again instead of read from the cache.

Port of packages/coding-agent/src/core/cache-stats.ts in pi v1.0.0.

Structs§

CacheMiss
A counted cache miss on one assistant message.
CacheWaste
Counted misses across a session.

Constants§

CACHE_TTL_MS
Idle gaps longer than this are worth naming as the likely cause of a miss: Anthropic’s default cache lifetime.

Functions§

collect_cache_misses
pi’s collectCacheMisses: each counted miss with the id of the entry whose message paid for it, for notices when the transcript is drawn again.
compute_cache_waste
pi’s computeCacheWaste: the misses over every entry of a session, in file order.
detect_cache_miss
pi’s detectCacheMiss: the miss a newly finished assistant message paid for. entries may already hold the message, where the scan stops.