@howaboua/pi-cache-hit-predictor

Predicts reusable prompt-cache prefixes when Pi switches model or reasoning lanes.

Packages

Package details

extension

Install @howaboua/pi-cache-hit-predictor from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@howaboua/pi-cache-hit-predictor
Package
@howaboua/pi-cache-hit-predictor
Version
0.0.1
Published
Jul 18, 2026
Downloads
477/mo · 75/wk
Author
howaboua
License
MIT
Types
extension
Size
11.2 KB
Dependencies
0 dependencies · 1 peer
Pi manifest JSON
{
  "extensions": [
    "./index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

@howaboua/pi-cache-hit-predictor

Shows an inline cache-hit prediction when you switch Pi models or reasoning levels.

Cache hit prediction · gpt-5.6-sol · low: ~27k / ~104k (26%) cached

The prediction is a UI-only transcript notification. It is not sent to the model and does not change the prompt. Back-to-back predictions update the same line while you cycle through models or reasoning levels.

Install

pi install npm:@howaboua/pi-cache-hit-predictor

Try it for one session:

pi -e npm:@howaboua/pi-cache-hit-predictor

How it works

The extension treats each provider, API, model, and reasoning level combination as a separate cache lane. It remembers the prompt size from the latest successful request in each lane. When you return to one, the old prompt size is the prefix that may still be reusable.

For example, if low last saw 25k tokens and the session grew to 100k on high, switching back predicts a hit of up to 25k, or 25%. The next completed request refreshes that lane with the larger prompt.

This is an estimate, not provider preflight data. Provider expiry or eviction, compaction, branch summaries, changed tools or system instructions, and provider serialization can change the actual hit. The provider's cacheRead usage remains the final result.

Local development

bun install
bun run check
bun run pack:dry
pi -e ./index.ts