CacheSurgeon fixes silent KV-prefix cache collapse in coding agents, 0%→98.7% hits
Fickle-Connection851 · reddit · 2026-12-01
Debugging a local coding agent burning 16K+ uncached tokens per turn, the author found the culprit: tiny prefix mutations upstream of the model — non-deterministic tool JSON ordering, per-second timestamps in system prompts, missing Anthropic cachecontrol breakpoints, and 5-minute TTL expirations forcing 1.25× cold rebuilds. The open-source CacheSurgeon proxy (MIT, FastAPI, <2ms overhead) fixes these in flight: canonicalizing tool schemas and injecting cachecontrol breakpoints lifted turn-2 cache hits from 0% to 98.7% (109s → 1.07s) on Apple Silicon MLX/Ollama. It also includes a cost-aware TTL warmer, a reversible secret vault that scrubs credentials before egress across split SSE chunks, and a tool firewall with loop circuit breaker that blocks destructive calls (rm -rf, DROP TABLE, force-pushes). 30-second setup: pip install cachesurgeon, point your base URL at the local proxy.
Related event: CacheSurgeon Open-Sourced to Fix Silent Cache Misses in Coding Agents(2 posts)→
More from coding & agent
- RELAY: training-free early stopping cuts token cost in multimodal multi-agent reasoning — showlab · 2026-12-01
- SEO Skill reverse-engineers rivals' AI search playbooks for $0.86 a report — iannuttall · 2026-12-01
- Agentests turns engineering rules into tests, reserving LLMs for semantic calls — Ok-Buyer-9421 · 2026-12-01
- Three tries, no PR: GitHub Copilot agent struggles with its own bread-and-butter — craig_macdonald · 2026-12-01
- One guy + 6 AI bots: Grok Bot content team pulled 3.5M+ views in 48 hours — mhdfaran · 2026-12-01
- Grok Bot 'AI employees' prompt templates: research analyst + social media manager roles — TawohAwa · 2026-12-01