// courier protocol · local LLM agents

MNEMONIC
PROXY

Like Johnny, your agent carries more than its head can hold — and keeps working for hours.

> payload: 448,331 tokens of history
> head capacity: 131,072 · peak load 105,086
> session: 3h 15m · 430 requests · 0 errors

One session, measured

A real coding session — a canvas tower-defense game built from scratch by Qwen3.8 Flash Next (IQ3_XXS) on a single 12 GB RTX 4070 Ti — with the proxy in between. Nothing was summarized away: every message, tool call and output stays on disk, verbatim, and the model can pull any of it back.

Developed and benchmarked primarily with Strata, by Niko1221 and contributors. mnemonic-proxy is an independently maintained project that also supports llama-server, ds4-server and other OpenAI-compatible backends; saved engine state depends on what the backend supports.

448K
tokens of history archived and recallable
105K
peak tokens actually in the prompt (window: 128K)
3h15
continuous agent work · 430 requests · 0 errors
1.4s
to resume a 110K-token conversation from disk (≈50 s re-reading it)

Replay of a real exchange (GIF). Three hours and two segment switches in, one recall call — resolved inside the proxy in 61 ms — brings back the verbatim first version of the boss block, message 20. No model summarized anything.

0K100K200K300K400K0h1h2h3h3h15segment 1 · ~2 minsegment 2 · ~2 minmodel window · 128K 448K archived & recallable what the model sees · peak 105K

Magenta: the full history of the session. Cyan: what the model actually reads on each request. Dashed lines: the two segment switches (≈2 minutes each, written handoff notes). Data from the proxy journal, 5 Oct 2026.

How it works

An OpenAI / Anthropic / Responses-compatible HTTP proxy. Your agent talks to it exactly as it would talk to the model. No summaries written by a model, no vector database required.

01 · HIDE

Mask, don't summarize

Old tool outputs and reasoning leave the prompt in stable blocks and become one-line receipts with an id. The prefix stays byte-identical between blocks, so the engine's KV cache keeps working.

02 · RECALL

Structured, exact recall

A recall tool searches the verbatim archive: first write of a file, its full edit timeline, command → output, the reasoning behind an edit — every hit tagged with message number and segment.

03 · SEGMENT

Segments with handoff notes

When even the masked window fills up, the model writes its own notes, the segment is sealed and a fresh one starts. Pinned lines (!!) survive every switch.

04 · SAVE

Saved engine state

On engines that support it (llama-server, Strata) the KV state is saved to disk: resuming after a pause, a restart or another client takes 1–3 s instead of a full re-read.

05 · ARCHIVE

Deduplicated cold storage

Old state files are rebuilt bit-for-bit from content-addressed zstd blocks: −36% disk on our sessions, sha256-verified before every restore.

06 · LEAN

Tools on demand

Agents ship tens of thousands of tokens of tool definitions. The proxy keeps the core ones and loads the rest by name: 25.6K → 6.2K tokens on every request.

"In the courier business you don't read the payload. You carry it, and you give it back exactly as it was."— the design rule. Hidden content is never paraphrased; it is either in the prompt or retrievable verbatim.

Recall, benchmarked

71 questions about past sessions, each with the known location of the evidence (including 8 with no answer in the archive). Held-out split:

keyword searchstructured recall
evidence found within 5 calls90%100%
tokens returned per question5,9402,737
"not in the archive" recognised1 / 44 / 4

The benchmark guided development, so read it as a regression suite, not an independent score.

Saved state, measured

Resuming a conversation instead of re-reading it:

casesavedre-read
Strata (session-files branch), 110K tokens, RTX 4070 Ti1.4 s≈50 s
Strata (session-files branch), 69K tokens, after restart2.9 s33 s
llama-server, 8.2K tokens, CPU, Qwen3-0.6B1.9 s28.6 s

Context restore only; loading the model is separate.

Claude Code and Codex, live

on Strata, 12 GB GPUClaude CodeCodex
session1 h 41 min, 339 requests, 0 proxy errors20 requests
prompt tokens from the engine cache92.6%93.9%
context328K virtual, ≤46K in the prompt, 14 segment switchesexact recall: 36 tests, 8/8 messages

Claude Code 2.1.284 on a low-threshold test config (masking at 36K) so that segments switch. Facts scattered in 16K–122K prompts on Strata alone: 151/160 exact, 0 wrong, 9 omitted (all ≥ 64K).

Why it matters. Without saved state, the whole prefill of a long conversation is paid again every time the engine loses it — after a restart, when another client used the engine in between, when the proxy returns to a sealed segment. On a 12 GB GPU that is close to a minute for 100K tokens; restoring takes a second or two, from disk, not VRAM. Any client of a local engine benefits, not just this proxy. llama-server has it (--slot-save-path); Strata has it since 0.1.40 (PR #668), opt-in with --slot-save-path.

Does the model recall on its own?

Recall only helps if the model uses it without being told. Short scripted tasks where a value needed at the end exists only in an old, masked tool output — not on disk, not reproducible — and the final request never says "remember" or "earlier": a random script output, a file read once then deleted, the old version of an overwritten config, an error from a service that is then shut down, and a long session with several segment switches.

client · Qwen3.8 Flash Next on Strata 0.1.40, RTX 4070 Ti 12 GB, proxy 0.3.1short episodes: right valueslong session
Claude Code 2.1.2848 / 8, all via recall the model chose to call127K virtual, 3 segment switches: right
pi 0.87.13 / 3, all via recall231K virtual, 6 segment switches: right
omp 18.10.1 (oh-my-pi)4 / 4, all with recall ¹82K virtual, 2 segment switches: right

¹ With omp the model repeated some of the values in its own one-line answers, so in two episodes recall was strictly needed only for part of them. Across 18 real sessions the need is rare: 5 spontaneous recalls against 108 after a question about the past; when a file can be re-read, the model re-reads it. One model, one run of each long session, scaled-down thresholds (32K window) for the long ones. Details in the benchmarks.

User reports

Measured by users on their own hardware, shared with permission, not reproduced by us.

u/Swimming-Farmer7815
hardwareRTX 5060 Ti 16 GB, Xeon E5-2699 v3, 64 GB
engine · clientStrata, Qwen3.8-Flash-Next IQ3_XXS, 128K · Cline
session13 h, ~280K tokens of history, ~77K in the last request
saved state~58K tokens restored in < 4 s (≈1 min 15 s to re-read)
recall8 calls, all used — only when asked for a summary of the day

Share your numbers, especially with clients and models we have not tested: open an issue with the user report template.

Long sessions on ds4

Proxy vs pi's own compaction, ds4-server on a Ryzen AI Max+ 395 (128 GB), 32K window, one run per side:

16-step taskwith proxypi alone
Qwen3.8 Flash Next Q2: steps in 2 h16 / 1614 / 16
re-reads from token 0023
tokens read by the engine167K267K
DeepSeek V4 Flash Q2 (official ds4)16 / 16, 0 re-readsnot run

A 29-step, 4-hour run gave 29/29 vs 10/29 and 1 vs 38 re-reads, but it is not a clean quality result: with the client's 4,096 max output tokens Qwen3.8's reasoning was cut before acting and unanswered steps piled up. Give reasoning models room (8192+ output tokens). Details in the engines.

Run it

Python ≥ 3.10, standard library only (optional: tokenizers for exact counts). Point it at any OpenAI-compatible engine; with llama-server you also get saved state. Engine window: at least 16K, 32K or more recommended — below 16K the proxy refuses to start.

# 1. an engine — llama.cpp with slot saving
$ llama-server -m model.gguf -c 131072 --slot-save-path ./slots --port 8095

# 2. the proxy
$ pip install mnemonic-proxy                   # or: uvx mnemonic-proxy demo
$ mnemonic-proxy --upstream http://127.0.0.1:8095 --port 8096 --data ./data

# 3. your agent → http://127.0.0.1:8096
$ OPENAI_BASE_URL=http://127.0.0.1:8096/v1 pi              # Chat Completions
$ ANTHROPIC_BASE_URL=http://127.0.0.1:8096 claude          # Anthropic Messages
$ codex -c model_providers.local.base_url=http://127.0.0.1:8096/v1 \
        -c model_providers.local.wire_api=responses        # Responses

Every engine (Strata, llama-server, llama-server in router mode, ds4-server, any OpenAI-compatible server), every agent and every OS, with the config file to copy: Install in the documentation (agents: Connect your agent). llama-server router mode (several models, loaded on demand; since 0.3.7): the window is read from each model's own context before the prompt is built, and saved state is kept per model.

The recommended README and ds4 example configs keep auto_recall: false: retrieval is requested by the model. The 100-question AgentLongBench confirmation run logged 379 model-requested recall calls and zero auto_recall events. Automatic hints are opt-in: auto_recall_hint: true only selects hint mode and also requires auto_recall: true; it does not enable retrieval by itself.

client \ engineStratallama-serverds4-serverany OpenAI-compatible
Chat Completions (pi, omp, Hermes, Continue…)tested · fulltested on CPU · fulltested with pi · engine keeps its own statebase (no saved state)
Claude Code (Anthropic Messages)tested liveexperimentalexperimentalexperimental
Codex (Responses)tested liveexperimentalexperimentalexperimental
MCP recall server (Claude Code, Codex, Hermes)tested read-only on a real archive

ds4-server (antirez/ds4) with pi on a Ryzen AI Max+ 395, 8K window: GLM 5.3 Flash Q2 recalled an error line removed from the prompt (right id and shard, plus an invented timestamp), and after each recall ds4 read only the new 614–634 tokens. The 8K window was chosen to stress recall; the proxy now requires at least 16K. Long 32K sessions on ds4 are above. mnemonic-proxy is a separate tool, compatible with ds4-server; it is not part of the ds4 project.

What we have not proven