r/opencode • u/No-Individual159 • 1h ago
Prefixwise: see why opencode's prompt cache misses, and what each miss costs
Prompt caching is a big part of what an agent costs. When the start of a prompt matches the last call, the provider charges about a tenth of the normal price for it. When something near the top changes, you pay full price again, and nothing tells you why.
Prefixwise shows you. Run opencode through it:
pip install prefixwise
prefixwise run -- opencode
prefixwise report --session latest
It sits between opencode and the API as a local proxy and gives you every call with how much was read from the cache, and the reason when it wasn't. From a real opencode run:
turn model prompt cached hit cause
1 claude-haiku-5-5 807 0 0% first_write
2 claude-sonnet-4-6 7,915 0 0% model_switch
3 claude-sonnet-4-6 8,011 7,912 99% none
The first call goes to a small model (opencode uses one for the session title), so the main model's first call can't reuse anything. That's expected and costs nothing extra. After that it's 99% from cache. When something does go wrong, like a timestamp in the system prompt, tools sent in a different order, or an edited earlier message, Prefixwise names it, tells you what it cost, and gives you the fix.
Good to know:
It works with an API key. A subscription login can't be routed through a proxy.
It stores hashes and token counts, never your prompts.
It's open source (MIT): github.com/tejachavali/prefixwise
If you run long opencode sessions, try it and tell me what your hit rate looks like.