Skip to main content

Mnemonic Proxy

Mnemonic Proxy

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

License: MIT Python ≥ 3.10 Project page

Mnemonic Proxy lets a coding agent work for hours with a local model, even when the model's context window is small.

Without it, a long session ends in auto-compaction: the agent keeps working from a summary of a summary, slowly forgets the details, and redoes work or research it had already done.

Mnemonic Proxy works differently. It sits between your agent and your model server. Old tool outputs leave the prompt, so the window does not fill up. They are not summarized and not thrown away: every message stays on disk, word for word, and the model can read it back with a recall tool when it needs it.

It is for you if you run a local model server (Strata, llama-server, Ollama, LM Studio, Unsloth, ds4-server or any OpenAI-compatible server) and a coding agent (Claude Code, Codex, opencode, pi, Hermes, DeepSeek Harness, Continue), and you are tired of auto-compaction.

Replay: a question answered from three hours earlier with one recall call

A real session, three hours in: one recall call brings back the first version of a code block, exactly as it was written.

What it does for you

Measured on our hardware, single runs (details):

  • Hours on one GPU. A 3 h 15 min coding session on a single 12 GB GPU: 448K tokens of history, at most 105K in the prompt at any time.
  • Better answers than a summary. On 100 AgentLongBench questions about old tool outputs, the same model answered 86 right with the proxy in a 32K window, 47 with a model-written summary and 69 with the full history in a larger window. A repeat run gave 85, 57 and 75.
  • Fast resume. A 110K-token conversation comes back from disk in 1.4 s instead of about 50 s, on engines that can save their state.

What it does not do

  • It does not make the model smarter. Keeping the text exact does not guarantee that the model looks for it, or looks in the right place.
  • Search is by words, not by meaning: a paraphrase with no word in common can miss.
  • Fast resume needs a server that can save its state: llama-server and Strata (ds4-server keeps its own). The other servers get everything else.
  • The model still sees one window at a time. The rest is retrievable, not "in context".
  • Our numbers come from single runs on our machines. What we have not proven lists the gaps.

Quick start

You need:

  • Python 3.10 or newer;
  • a model server that is already running, with a context window of at least 16K tokens (32K or more is better);
  • a model that can call tools, so it can use recall.

The proxy does not run a model itself. It talks to your server.

pip install mnemonic-proxy
mnemonic-proxy check --upstream http://127.0.0.1:8095 --port 8096 --data ./data
mnemonic-proxy --upstream http://127.0.0.1:8095 --port 8096 --data ./data

--upstream is the address of your model server. check tells you READY, or what to change, line by line.

Then point your agent at the proxy, http://127.0.0.1:8096/v1, instead of the server, and turn off the agent's own auto-compaction (next section).

No model at hand? uvx mnemonic-proxy demo shows the archive and recall working in one minute, with a scripted fake model.

Connect your agent

Two changes in every agent: the address, and its own auto-compaction off, so two context managers do not fight over the same history.

agent point it at turn off setup
Claude Code ANTHROPIC_BASE_URL=http://127.0.0.1:8096 (no /v1) DISABLE_AUTO_COMPACT=1 Claude Code
Codex base_url = "http://127.0.0.1:8096/v1", wire_api = "responses" model_auto_compact_token_limit = 100000000 Codex
opencode http://127.0.0.1:8096/v1 (openai-compatible provider) "compaction": {"auto": false} opencode
pi, omp http://127.0.0.1:8096/v1 (openai-completions) "compaction": {"enabled": false} pi
Hermes Agent http://127.0.0.1:8096/v1 (custom provider) compression.enabled: false Hermes
DeepSeek Harness (dsh) baseURL: http://127.0.0.1:8096/v1 (openai-completions) compaction-basic, tool-result-pruner: disabled: true DeepSeek Harness
Continue, other Chat Completions clients http://127.0.0.1:8096/v1 the client's own context compaction Chat Completions

Ollama and LM Studio: give the model a context of 32768 first. With their default (4096 or 8192) they silently drop part of long prompts. Engines has the command for each server.

How it works

  1. Hide. When the prompt grows, old tool outputs and old reasoning are replaced by a one-line receipt with an id. The receipt says what the call was and how it ended.
  2. Keep. The original text goes to a local SQLite archive, unchanged.
  3. Recall. The model gets a recall tool to search the archive and read any piece back. The proxy answers these calls itself; your agent never sees them.
  4. Start a new segment. If the window still fills up, the model writes handoff notes and continues in a fresh segment. The old messages stay in the archive and remain searchable.
  5. Resume fast. On servers that support it, the engine state is saved to disk, so a long session restarts in seconds instead of being read again.

Privacy

Everything stays on your machine. The proxy talks only to the server you give it, with no telemetry. The archive is plain text and holds everything the agent saw, secrets included: protect the data folder. The proxy listens on 127.0.0.1 and has no authentication, so do not expose it on a shared network. Security

Documentation

Credits and license

Developed and benchmarked mainly with Strata, by Niko1221 and contributors. Mnemonic Proxy is maintained independently and also supports the other servers listed above.

MIT license. Author: Maurizio Verde — LastReload.

Metadata

Release files for mnemonic-proxy 0.3.29

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mnemonic-proxy 0.3.29
File Size Uploaded Provenance Actions
mnemonic_proxy-0.3.29.tar.gz 538.2 kB With provenance Details for mnemonic_proxy-0.3.29.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for mnemonic-proxy 0.3.29
File Interpreter ABI Platform Actions
mnemonic_proxy-0.3.29-py3-none-any.whl Python 3 none any Details for mnemonic_proxy-0.3.29-py3-none-any.whl

Total release size: 835.1 kB

Release files / mnemonic_proxy-0.3.29.tar.gz

Download URL mnemonic_proxy-0.3.29.tar.gz
Size 538.2 kB
Tags Source
SHA-256 checksum
How to use checksums
651e3ed155532e820ac33097ab79dc6ffe1ddebef3d4b434623e275bd83ce38a
BLAKE2b-256 checksum
How to use checksums
ecc774f45d12f667f69a24f00d9beb5a26ea70f13db9bf0e96eca026cf6a3a40
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 15, 2026.

Transparency log

Release files / mnemonic_proxy-0.3.29-py3-none-any.whl

Download URL mnemonic_proxy-0.3.29-py3-none-any.whl
Size 296.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7b0cae2824963c444f5bf4b17d401127040b751f4dc24ae0d8fa6049302fb915
BLAKE2b-256 checksum
How to use checksums
b7b281856ebab40b85cc865f1f17d8f70eee7c5f5807855522762ac2ce52be36
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 15, 2026.

Transparency log

Security for mnemonic-proxy 0.3.29

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for mnemonic_proxy-0.3.29.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 15, 2026.

Transparency log

A 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.

Release history Release notifications | RSS feed

This release

0.3.29 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page