Context Guardian is a context-compression proxy that primarily addresses the problem of local OpenAI-compatible models being interrupted in long sessions when the context window is exhausted. It sits between the client and the backend; when a request is about to exceed the model's window, it summarizes earlier conversation turns, keeps the most recent turns verbatim, and forwards a request adapted to the window. If summarization fails, returns empty, or any exception occurs inside the proxy, the request is forwarded to the backend unchanged—a "fail-open" design that ensures normal requests are never blocked by a proxy failure.
Key capabilities include: automatic compression of long conversations; archiving folded content to disk, sealed with a SHA-256 hash chain for verifiable integrity; providing retrieval commands and MCP tools so models or users can search archived original content; supporting Claude Code session archiving and retrieval; providing a DeepSeek Harness native compression engine; providing a status-line tool that shows the actual number of tokens the proxy forwards; and providing receipts and savings statistics to quantify compression effectiveness.
Usage: users can install the PyPI package context-guardian via pip, point the client at the proxy address, and set the environment variable GUARDIAN_NUM_CTX to the model's true window size. For Claude Code, an adapter can be used to archive sessions without changing how connections are made. For DeepSeek Harness, the npm package dsh-context-guardian can be installed as a native engine. The proxy also provides a launch command that can temporarily start the proxy for a single client process.
Applicable scenarios: coding CLI users using local backends such as Ollama, LM Studio, vLLM, and LiteLLM; developers who need long sessions not to be interrupted; users who want retrievable, verifiable conversation archives; Claude Code and DeepSeek Harness users.
Limitations: the project is under active development; the PyPI package has been beta since 0.4.0, and the npm package has been beta since 0.1.0-beta.1. Hash-chain sealing is tamper-evident evidence, not tamper-proofing itself—anyone who can write to the archive directory can modify content and recompute the hash chain. Claude Code transcript lines are officially marked as an internal format and may change between versions. Session distinction relies on hashes of the model, the first system message, and the first user message; sessions with the same combination will collide. The proxy's token counting is accurate on llama.cpp and vLLM, and is an estimate on other backends. Some backend and client configurations come from documentation but have not been tested.