Each time you stop a Claude Code session mid-task and open OpenCode, Codex, or Cursor in the same repo, the new agent starts cold. It cannot read the previous tool’s private notes, so its first ten turns go into re-reading files you already checked and retrying strategies you already rejected. ai-memory (12.6k GitHub stars, MIT, Fabio Akita) eliminates that cold start by compiling sessions into a Git-backed Markdown wiki (<data_dir>/wiki/) and passing a claim-once handoff packet to the next agent.
Does ai-memory save tokens? And when does it actually call an LLM? By default, it uses 0 LLM calls: lifecycle hooks catch prompts and tool calls, SQLite FTS5 indexes your Markdown pages, and cross-agent handoffs work without spending a single API token. When you enable background LLM consolidation and hybrid vector search on Regolo’s OpenAI-compatible endpoint, our live test on a multi-file repo cut session warm-up prompt tokens by 79.2% (26,185 down to 5,453 tokens, and up to 95.2% on 90-turn refactoring handoffs) while stopping the next agent from repeating failed changes.
Persistent long-term codebase memory and claim-once cross-agent handoffs across OpenCode, Claude Code, Codex, Cursor, and Gemini CLI, backed by a plain Markdown repository wiki (OKF v0.2) and zero-LLM FTS5 + entity search by default.
$curl -fsSL https://github.com/akitaonrails/ai-memory/releases/latest/download/install.sh | sh
Works with OpenCode · Claude Code · Codex · Cursor · Gemini CLI
How ai-memory works: zero-llm capture versus opt-in regolo consolidation
In contrast to hosted memory APIs that call an LLM on every roundtrip and put your notes in a black-box vector DB, ai-memory keeps disk-based plain Markdown files (<data_dir>/wiki/) as the single source of truth. The SQLite DB (db/) is a secondary index that can always be rebuilt from those Markdown files. To see where the tool saves tokens, distinguish the default zero-LLM route from opt-in LLM consolidation:
Set up ai-memory and connect Regolo in 3 steps
Use the zero-LLM lifecycle hooks for daily capture, and point openai-compat to https://api.regolo.ai/v1 when you want LLM-written wiki pages and Qwen3-Embedding-8B vector recall.
Two configuration details from ai-memory‘s official provider documentation matter when you connect an open-weight endpoint:
# ~/.config/ai-memory/regolo.env
LLM_API_KEY="your-regolo-api-key"
# 1. LLM Consolidation on Regolo (disable thinking so strict JSON is never truncated)
AI_MEMORY_LLM_PROVIDER="openai-compat"
AI_MEMORY_LLM_BASE_URL="https://api.regolo.ai/v1"
AI_MEMORY_LLM_MODEL="qwen3.5-122b"
AI_MEMORY_LLM_COMPAT_STRICT="true"
AI_MEMORY_LLM_COMPAT_DISABLE_THINKING="true"
# 2. Hybrid Vector Search with Qwen3-Embedding-8B (no trailing space after Query:)
AI_MEMORY_EMBEDDING_PROVIDER="openai-compat"
AI_MEMORY_EMBEDDING_BASE_URL="https://api.regolo.ai/v1"
AI_MEMORY_EMBEDDING_MODEL="Qwen3-Embedding-8B"
AI_MEMORY_EMBEDDING_DIM="4096"
AI_MEMORY_EMBEDDING_QUERY_PREFIX="Instruct: Given a codebase memory query, retrieve relevant wiki pages\nQuery:"Code language: Bash (bash)
Setting AI_MEMORY_LLM_COMPAT_DISABLE_THINKING="true" makes ai-memory pass chat_template_kwargs: {"enable_thinking": false} on every openai-compat consolidation call, so Qwen3-series models use 100% of their output tokens for the structured wiki JSON instead of burning the budget on internal thinking.
For embeddings, Qwen3-Embedding-8B needs an instruction prefix on the query side only, with no space after Query:.
Sovereign AI inference, OpenAI-compatible, EU-hosted. Benchmarks, new models (Mistral, Qwen, GLM), and cost insights. One email, no spam.
Please check your inbox to confirm your subscription.
100% European infrastructure · Zero spam · Unsubscribe anytime.
Inspecting real token savings in Regolo Memory Studio
To measure how much context ai-memory saves when an agent comes back to a repo (and to inspect the compiled OKF v0.2 Markdown pages side by side), we created Memory Studio (regolo-ai/tutorials/memory-studio, Python 3.10+ stdlib only, python3 memory_wizard/server.py).
It reads a local repo with git ls-files, strips secrets at the capture boundary, compiles wiki/decisions/*.md, wiki/procedures/*.md, and wiki/handoffs/*.md, and compares a cold full-file session against a warm handoff session:
Select a cross-agent transition and compare cold rescans against compiled wiki handoffs
Start the local web inspector with python3 memory_wizard/server.py (http://127.0.0.1:8210) to test any model from GET /v1/models on your own project folder.
git ls-files ignore rules and redacts API keys/tokens before compiling observations into durable Markdown pages.
wiki/decisions/, wiki/procedures/, and wiki/handoffs/ Markdown files alongside the generated ~/.config/ai-memory/regolo.env file.Clone Regolo Memory Studio on GitHub
Test ai-memory consolidation and Claim-Once handoffs on your own repository with python3 memory_wizard/server.py.
Does ai-memory actually save tokens? When it helps and when it does not
A memory tool only saves tokens when the startup brief and wiki pages it injects are smaller than the exploratory file reads they replace. In both the web inspector and our 90-turn multi-file refactoring tests, how you use your coding agents directly determines the savings:
ai-memory‘s default capture, FTS5 search, and rule-based handoffs use zero API calls.synchronous=OFF after a prior crash test).What happens when you switch agents mid-task
MEMORY.md files do not sync across 20+ CLI harnesses or across teammates working on the same repository.Git-backed OKF v0.2 wiki + Claim-Once handoffs
ai-memory runThe receiving agent starts with Where We Left Off, Locked Decisions, and a temporary local projection of the previous session.brick-v1-beta and qwen3.5-122b compiles clean wiki pages.wiki/decisions/ and wiki/procedures/ is human-editable in Obsidian or VS Code and processed under EU Zero Data Retention.When will it not save tokens? If you run a single one-off prompt in a small repo and never switch agents or revisit the task. In that case, turning on eager per-turn LLM consolidation spends more tokens writing wiki pages than you save.
That is why ai-memory keeps per-turn capture 100% deterministic (0 LLM calls) and runs LLM consolidation only at session checkpoints or on demand with memory_consolidate (under a cent per run with qwen3.5-9b via brick-v1-beta at €0.10 input / €0.20 output per 1M on Pay-As-You-Go, or ×0.5 quota usage in Regolo Core).
We updated our pay-as-you-go token rates and introduced usage multipliers across subscription pools: ×0.5 on brick-v1-beta, qwen3.5-9b, and gpt-oss-20b; ×1 on gpt-oss-120b, mistral-small-4-119b, and gemma4-31b; ×2 on qwen3.8-27b; ×3 on qwen3.5-122b; and ×5 on glm5.2 (with non-chat endpoints billed on pay-as-you-go). Any historical benchmark logs or charts recorded before November 1 reflect October 2026 rates. See live plans on regolo.ai/pricing.
Frequently asked questions
How does ai-memory share context across Claude Code, OpenCode, and Codex?ai-memory stores session observations in a local SQLite FTS5 index and compiles decisions and procedures into a Git-backed Markdown wiki (wiki/decisions/ and wiki/procedures/). When you launch any supported CLI agent with ai-memory run, it injects a bounded startup brief so the new agent starts with prior context instead of re-scanning the repository.
Does ai-memory require LLM calls on every turn?
No. Daily capture and full-text search are 100% deterministic and use 0 LLM tokens. LLM consolidation runs only at session checkpoints or on demand via memory_consolidate using our OpenAI-compatible endpoints under European Zero Data Retention.
How many tokens does persistent codebase memory save when switching coding agents?
In multi-agent repository handoffs, cold-start discovery typically consumes 26,185 to 52,262 prompt tokens. Starting from an ai-memory consolidated brief reduces initial prompt usage to 2,485 to 5,453 tokens, saving 79% to 95% on handoff turns.
Related agent memory & coding guides: Compare this workflow with persistent memory for Hermes and OpenClaw with TencentDB, long-term graph memory with Cognee, cutting codebase context tokens by 92% with context-mode and headroom, multi-agent coding routing with OpenCode and Brick, and our coding agent integrations hub.
You have the architecture and the open-source workflow. Now give it a sovereign European inference layer built for production: fast access to GLM-5.2, Qwen3.8-27B, Qwen3.5-122B, Gemma 4, Mistral Small 4, and Brick (brick-v1-beta) with zero data retention and no new SDK to learn.
Build, test, and deploy with no infrastructure to maintain. Core plans from €11.70/mo (70% off first 3 months).
Get the full implementation, configuration scripts, evaluation benchmarks, and ready-to-run templates.
Meet engineers building with coding agents, private RAG, local LLMs, and production open-weight models.
Scaling beyond a proof of concept or running regulated EU workloads? Get a tailored architecture and commercial plan.