anchor — agents that remember their own work. mm + ms memory for AI agents: an append-only session archive, an entity index, a dangling-reference trigger and a search ladder that recovers what context compaction destroys.
pip install anchor-memory==0.9.0 Copy PIP instructions
anchor = mm + ms. Memory management plus memory search for AI agents.
When a long-running agent hits its context limit, compaction summarizes the history — and the summary silently drops the details: the tool the agent built (p3c2), the file it wrote, the decision it made, the approach it tried and rejected. The agent then rebuilds things it already built. anchor fixes this in two halves:
Pure stdlib Python — no pip dependencies to run, works offline, optional local-Ollama for one rung. Ships as an MCP server so Claude Code, OpenCode and any MCP client can use it in one config block.
pip install anchor-memory That's the whole install. Verify with python -m anchor.selftest, then wire it into your tool (next section). Source, if you'd rather: pip install git+https://github.com/zacharyol/anchor-memory.git
Website & full setup guide: https://zacharyol.github.io/anchor-memory/
anchor-mcp # starts the MCP server (stdio) python -m anchor.selftest # offline end-to-end test with numbers python -m anchor.replay # ingest your own OpenCode session history Wire it into your agent (one block, then restart the session):
{ "mcpServers": { "anchor": { "command": "anchor-mcp" } } } Your agent gains: anchor_resolve (what was p3c2?), anchor_check (which names in this summary are unexplained?), anchor_search (BM25 over raw history), anchor_sessions, anchor_sync (incremental ingest from the live session database), anchor_stats, and anchor_relay (shard-searchers with negative-result merge — the last resort before "unfindable").
v0.7 honesty note: the card-thinning regression (docstrings replacing rich lines) ate the recall gap — root-caused and fixed in the current source (docstring prepends, rich lines kept). Verification rerun of the fixed code pending; coverage still favored anchored (+5 pts) and wobble stayed ±5–6%.
Trigger fire precision on labeled real data: 58% (firing is free — junk is filtered at the card layer). Sampling wobble ±5–6%: model randomness is small; question difficulty dominates. Full methodology: docs/BENCHMARK.md.
Memory loss after compaction is the defining production failure of long running agents ("context rot"). anchor's answer is deliberately simple: archive raw, index entities, detect the gap automatically, search in a cost ladder, and never trust a summary when the primary source still exists. MIT licensed — take it, wire it, fork it.
Claude Code · OpenCode · any MCP client · local Ollama (optional, rung 2)
MIT License · repo: https://github.com/zacharyol/anchor-memory
ai agent memory context-window compaction context-limit llm mcp model-context-protocol rag retrieval claude opencode agent-memory long-running-agents
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
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.
None of the files in this release were uploaded with provenance metadata.
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.




