kvguard
Catch 1-token prompt-cache misses in real time — and heal them before the request leaves your machine.
Prompt caches (Anthropic, OpenAI) and local KV caches (llama.cpp, Ollama, vLLM) only reuse work when a new prompt starts with exactly the same bytes as the last one. One rotating header, one timestamp, one reshuffled MCP tool list — and 30–80K tokens are billed or prefilled again. Nothing errors. You just pay more and wait longer.
kvguard is a local proxy + terminal UI that shows you where the prefix broke, why, and what it cost — and can rewrite requests so it doesn't break again.
Quick start
uvx kvguard -- claude # Claude Code (observe only)
uvx kvguard --target http://127.0.0.1:8080 -- opencode # any agent → llama-server
uvx kvguard attach # live TUI in a second terminal
The first run downloads the native binary for your platform from GitHub Releases and verifies its SHA-256 checksum. No Docker, no database, no account.
What you see
Turn Branch / Slot Model Prefix Health Hit % Root Cause / Action
#04 main [slot 0] claude-sonnet-4-5 [█░░░░░░░░░] 12% ❌ BUST @ tok ~#418 (volatile header/id in system · system[0].text)
#05 main [slot 0] claude-sonnet-4-5 [██████████] 96% ⚡ HEALED (sorted 48 tools + stripped cch= billing header)
#06 sub-1 [slot 1] claude-haiku-4-5 [··········] – ◆ NEW BRANCH
What it catches
| Cause | Typical source | --heal |
|---|---|---|
| tools[] order shuffled | MCP servers starting asynchronously | ✅ sorted by name |
| schema key order changed | non-deterministic JSON serialization | ✅ RFC 8785 key order |
| volatile header in system | Claude Code cch= billing header on non-Anthropic backends |
✅ stripped |
| timestamp in prefix | Current time: … with seconds |
⚙️ opt-in --pin-timestamps |
| chat-template drift | Qwen/DeepSeek dropping <think> from old turns |
✅ --normalize-think-tags |
| history message mutated | compaction, truncated tool output | 🔎 reported with JSON path |
| sub-agent evicting main KV slot | llama-server with parallel slots | ✅ main pinned to id_slot 0 |
Sub-agents and parallel sessions get their own branch, so they are never reported as false busts.
CI gate
uvx kvguard --record trace.jsonl -- my-agent run-scenario
uvx kvguard check trace.jsonl --fail-on-bust --min-hit-rate 0.95
Prints a Markdown report and exits 1 when a request breaks its parent's prefix.
Supported
Anthropic /v1/messages · OpenAI /v1/chat/completions and /v1/responses · llama.cpp llama-server · Ollama · any OpenAI-compatible server. Prebuilt for Linux (x86_64, arm64), macOS (Intel, Apple Silicon) and Windows (x86_64).
Also available as npx kvguard (npm), pipx run kvguard and as a standalone binary.
Full documentation, accuracy notes and design: https://github.com/tranhoangtu-it/kvguard
License
MIT OR Apache-2.0
Metadata
Release files for kvguard 0.3.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| kvguard-0.3.2.tar.gz | 4.2 kB | With provenance | Details for kvguard-0.3.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| kvguard-0.3.2-py3-none-any.whl | Python 3 | none | any | Details for kvguard-0.3.2-py3-none-any.whl |
Total release size: 9.3 kB
Release files / kvguard-0.3.2.tar.gz
| Download URL | kvguard-0.3.2.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
28845a267a0c0c160aceff8c4bd96895ace4cc99b6c98e87ede050daae28dd3f
|
|
BLAKE2b-256 checksum How to use checksums |
c5f4517e323456c206a86abb0ec46b752956a8504faed576b434a4440fa1e8ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logRelease files / kvguard-0.3.2-py3-none-any.whl
| Download URL | kvguard-0.3.2-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4b144f1aefb2f88d7a848335e49b503c7ddfbca4607292012d5246649aca27e3
|
|
BLAKE2b-256 checksum How to use checksums |
8ac691fce593d82429d02ed5030729efb0594af2aa82eb4244829a275daf0ad4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logSecurity for kvguard 0.3.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for kvguard-0.3.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.