$ cat ~/map/pi-cache-lens.md
pi-cache-lens
Status-bar chip tracking per-request and session KV cache hit rates, with background forensics attributing every drop.
extensions✓ Oct 31
Facts
- repository
- github.com/w31r4/pi-cache-lens ↗
- GitHub Stars
- ★ 0
- Forks
- 0
- license
- —
- npm / mo
- —
- last push
- Oct 30, 2026
install
pi install git:github.com/w31r4/pi-cache-lens, then update anytime with pi update. The chip renders through the built-in pi footer automatically; pi-powerline-footer and pi-cc-extensions have documented integration snippets in the README.## TL;DR
A zero-overhead pi extension that displays prefix KV cache hit rates for the latest request and the whole session in the status bar, and runs background forensics that attribute every cache drop — cold start, mutated tools, rewritten history, TTL expiry, model change, or gateway drift — using hashes and offsets only, never raw prompt text.
## Key points
- $Dual hit-rate chip: the latest request and the cumulative session, colored accent at 70% or above, warning between 30% and 69%, error below 30%, with a muted warmup across a session's first three calls.
- $Zero overhead by construction: no tool schemas are registered and outgoing requests are never mutated; the extension observes traffic in the before_provider_request hook.
- $Root-cause tags separate miss families: cold start, below-minimum tokens, mutated tools, provider strict-tool fallback, mutated system prompt, rewritten or compacted history, TTL expiry, model change, gateway routing drift, and sharp partial drops without comparable evidence.
- $Credential-safe attribution: the normalized system prompt, tools including inline additional_tools, provider effort markers, and conversation items are fingerprinted, and storage holds hashes, byte lengths, and char@/byte@ offsets — never prompt excerpts.
- $Slash commands: /cache shows the session summary and the last eight calls with short hashes, /cache anomalies the ten most recent drops across sessions, and /cache path prints the forensics file locations.
- $Forensics live under ~/.pi/agent/cache-lens/: latest-report.md grouped by model, events.jsonl rotating at 10 MB, and anomalies.jsonl holding demonstrated drops only.
- $TTL thresholds follow the provider: 290 seconds by default when cache_control or prompt_cache_key is active, 1800 for a 30-minute prompt cache TTL, up to 86400 for 24 hours; every threshold is configurable in ~/.pi/agent/cache-lens.json.
- $The UI locale auto-detects from rpiv-i18n or LANG (zh or en) and can be forced in the config file.
## FAQ
Q Does pi-cache-lens add tokens or tools to requests?
No. It registers no tool schemas and never mutates outgoing requests; the chip and the forensics are computed from observed traffic.
Q Can it leak prompt content to disk?
The design says no: attribution persists hashes, byte lengths, and numeric offsets only, and raw prompt excerpts are never written.
Q What does the (!tools) tag mean?
The tool list or a JSON schema changed and triggered a cache drop; the record notes whether tools were added, removed, or modified.
Q Which providers are covered?
openai-responses, anthropic-messages, and openai-completions.
Q Does it work with third-party footers?
Yes. pi-powerline-footer and pi-cc-extensions have documented integration snippets, and the built-in pi footer works automatically.
## References
## Related entries
$ pi-librenms
LibreNMS network-monitoring tools for pi: devices, ports, alerts, and Oxidized configs over the REST API, no MCP layer.
$ big-pi
Model-driven compression that summarizes completed phases into tiered blocks while Pi's JSONL transcript stays authoritative and untouched.
$ inception
A curator LLM replaces pi's compaction, rewriting old history every few turns to keep the context dense.
## Guides
Last updated: Oct 30, 2026