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:.
Get engineering notes and model releases in your inbox.
Sovereign AI inference, OpenAI-compatible, EU-hosted. Benchmarks, new models (Mistral, Qwen, GLM), and cost insights. One email, no spam.
Thank you for subscribing!
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-complexity-pro 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: €0.0065 on Regolo Pay-As-You-Go, or negligible pool usage in Regolo Core).
Ship Private AI. Not Infrastructure.
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.5, Mistral, Llama, DeepSeek, and Brick Complexity Pro with zero data retention and no new SDK to learn.
Start your 30-day free trial →
Build, test, and deploy with no infrastructure to maintain. Core plans from €11.70/mo (70% off first 3 months).
Clone the GitHub repository →
Get the full implementation, configuration scripts, evaluation benchmarks, and ready-to-run templates.
Join the Regolo Discord →
Meet engineers building with coding agents, private RAG, local LLMs, and production open-weight models.
Talk to an AI Infrastructure Engineer →
Scaling beyond a proof of concept or running regulated EU workloads? Get a tailored architecture and commercial plan.