Prefixwise tells you why your LLM calls miss the prompt cache, and what each miss costs you. Put it between your agent and the model, or inside vLLM itself, and it identifies the cause of every miss in plain English, fixes the common ones for you, and prevents new ones from reaching production. Your prompts never leave your machine: it stores hashes and counts, nothing else.
Repo: https://github.com/tejachavali/prefixwise
Install: pip install prefixwise (0.10.0 is out today)
Identify: 19 causes, each with its evidence and fix. Tools sent in a changed order, a timestamp in the system prompt (naming whether a date, time, UUID, or file path changed), an edited earlier message, a compaction rewrite, a model switch, a misplaced cache breakpoint, TTL expiry, a retry, an eviction, a routing miss, and more. Agrees with Anthropic's own miss diagnostics 32 of 32.
Fix: --fix canonical_tools lets the proxy repair the most common cause in flight. Measured: 99.9% of the predicted saving realised on Claude, 97.5% on vLLM, task success unchanged.
Prevent: prefixwise check -- pytest tests/agent_scenarios, or the GitHub Action, runs your agent's scenarios against a local mock and fails CI when a change breaks the cache. Nothing is sent anywhere.
Where it runs, each about thirty seconds to set up (no config files to edit):
• prefixwise import claude-code && prefixwise report (or prefixwise import codex): reads the local logs of a subscription, nothing is sent anywhere
• prefixwise run -- claude (or codex, opencode, any agent): wraps the agent, reports when it exits
• prefixwise serve --upstream <url>: a local proxy for a service, several agents, or a gateway
• vllm serve <model> --middleware prefixwise.PrefixwiseMiddleware: inside vLLM, no proxy
• prefixwise.wrap(Anthropic()) or wrap(OpenAI()) in your own Python
• litellm.callbacks = [PrefixwiseCallback()] for LiteLLM, SDK or proxy server
Self-hosted engines: it auto-detects the vLLM or SGLang behind any URL you give it and subscribes to the engine's own KV events. From those it confirms evictions, tells an LMCache or HiCache restore (host_restored) from a GPU hit, and confirms routing misses across replicas.
Data: a report in the CLI, /api/v1, JSONL and CSV export, Prometheus metrics with a Grafana dashboard and an alert rule, OpenTelemetry spans, a collector for many edges.
Measured this week, live on a Colab L4: reasoning models' chat templates drop the thinking from history, so every turn prefills the previous answer again. Qwen3-4B: 25-36% of all prompt tokens. A DeepSeek-R1 distill: 57%. Qwen2.5 and Llama 3.2 keep history as generated: 0%. The engine reports a hit either way; Prefixwise now names the tail per turn (output_rerendered).
Also live: agrees with Anthropic's own miss diagnostics 32 of 32; names injected causes 120 of 120 on vLLM, LMCache and SGLang; evictions confirmed 5 of 5 from KV events; 3 ms overhead per request. Every number in the README links to its run record.
Docs for engine users:
• vLLM: https://github.com/tejachavali/prefixwise/blob/main/docs/VLLM.md
• SGLang: https://github.com/tejachavali/prefixwise/blob/main/docs/SGLANG.md
• LMCache: https://github.com/tejachavali/prefixwise/blob/main/docs/LMCACHE.md