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

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.26
File Size Uploaded Provenance Actions
mnemonic_proxy-0.3.26.tar.gz 509.6 kB With provenance Details for mnemonic_proxy-0.3.26.tar.gz

Built distribution (wheel)

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

Total release size: 796.7 kB

Release files / mnemonic_proxy-0.3.26.tar.gz

Download URL mnemonic_proxy-0.3.26.tar.gz
Size 509.6 kB
Tags Source
SHA-256 checksum
How to use checksums
752e64bde81c58a11e694439d66e392127ee56d473e0a7fb2a157f57500ae8c7
BLAKE2b-256 checksum
How to use checksums
b19a034cdc321e18256e92303eb2d13347d102cea139d755c09ffde24c07a72f
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 11, 2026.

Transparency log

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

Download URL mnemonic_proxy-0.3.26-py3-none-any.whl
Size 287.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
39bbb21fdc7363f0ae6ef07e54ce0cfcc9628ce117a8fad5ce383f9b5d0a6516
BLAKE2b-256 checksum
How to use checksums
0c67ef6087eaf3fe0ef0a954b3e0687c8b50c8e3a361299648ce0df8a1213fc0
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 11, 2026.

Transparency log

Security for mnemonic-proxy 0.3.26

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.26.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 11, 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.26 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