r/deeplearning • u/No-Individual159 • 21d ago
I broke the prompt cache 1,772 times on purpose to test whether my tool finds the right cause. Results on vLLM and SGLang
Quick background: LLM servers (vLLM, SGLang, Anthropic, OpenAI) cache the start of your prompt, so an agent that resends its whole conversation every turn only pays full price for the new part. But if one byte near the top changes, say the tools come back in a different order or a timestamp in the system prompt ticks, the cache misses and you pay for everything again. The server tells you how many tokens missed, not why.
I build Prefixwise, an open-source tool (MIT) that tells you why: what changed, what it cost, and how to fix it. Before claiming it's right, I wanted to measure it.
The test: replay agent conversations through Prefixwise into a real engine (Qwen3-4B on a Colab L4), and at random turns make one known change:
reorder the tools
add or remove a tool
change a timestamp in the system prompt
reword the system prompt
edit an earlier message
edit a tool's output
Then check whether Prefixwise names the change I made. Half the traffic is 150 real Claude Code sessions (nvidia/Open-SWE-Traces) with their own tools and system prompts; the other half is generated.
engine traffic right cause wrong cause false alarms (nothing changed)
vLLM 0.33 generated 441 of 441 0 0 of 909
vLLM 0.33 real sessions 425 of 441 0 0 of 906
SGLang 0.5.23 generated 456 of 456 0 0 of 894
SGLang 0.5.23 real sessions 424 of 434 0 0 of 913
Right cause: it said exactly what I changed.
Wrong cause: it blamed something else. Never happened.
False alarm: nothing changed, but it claimed something did. Never happened.
The 26 it didn't call the main cause were all one case: an edit to the newest tool output. That lands in the last part of the prompt, which the engine never caches anyway, so it cost nothing. Prefixwise reported no waste and still noted the edit.
What this doesn't show: one model, the first 10 calls of each session, and changes I made on purpose rather than ones found in the wild. The test harness and every run record are in the repo, so you can rerun it.
pip install prefixwise, then put it in front of your server or agent. It stores hashes and token counts, never your prompts.
Repo: https://github.com/tejachavali/prefixwise
Happy to answer questions about the method or the misses.