Skip to content
Regolo Logo
Benchmarks & Cost Optimization

Getting started with ai-memory and regolo: persistent codebase memory across opencode, claude code, and codex

Alex Genovese
6 min read
Share

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.

FEATURED AGENT MEMORY · GITHUB TRENDING
★ 12.6k stars 20+ coding harnesses License: MIT

akitaonrails / ai-memory

Created by Fabio Akita (@akitaonrails)

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
Zero-LLM Default · Git-backed Markdown Wiki · Claim-Once Handoffs

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:

QUICK CONFIGURATION · ZERO-LLM HOOKS + REGOLO CONSOLIDATION
STEP 01 · ZERO-LLM SETUP
Install & wire agents
ai-memory setup ai-memory bootstrap
Installs hooks + MCP for OpenCode, Claude Code, and Codex with 0 API calls.
STEP 02 · REGOLO PROVIDER
Configure openai-compat
AI_MEMORY_LLM_PROVIDER=”openai-compat” AI_MEMORY_LLM_BASE_URL=\ “https://api.regolo.ai/v1″ AI_MEMORY_LLM_COMPAT_DISABLE_THINKING=”true”
Disables thinking tokens so structured JSON consolidation never truncates.
STEP 03 · HANDOFF
Switch agents mid-task
ai-memory run claude ai-memory run opencode ai-memory continue
Passes a claim-once startup brief + temporary native history projection.

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


ZERO DATA RETENTION

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:

OPEN-SOURCE WIKI & HANDOFF INSPECTOR · MIT LICENSE

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:

CAPTURE & FTS5
0 LLM tokens
Default hook & search path
Unlike per-turn fact extractors (Mem0/LangMem), ai-memory‘s default capture, FTS5 search, and rule-based handoffs use zero API calls.
REPO WARM-UP
−79.2%
Single-repo Compare run
In Regolo Memory Studio (Oct 22, 2026), resuming from compiled wiki cards cut prompt tokens from 26,185 to 5,453 (and total time from 12.8s to 9.7s).
90-TURN HANDOFF
−95.2%
Long-session harness switch
When switching from Claude Code to OpenCode after a 90-turn session, the Claim-Once brief + top-2 wiki pages used 2,485 tokens vs 52,262 for a cold rescan.
AVOIDED REWORK
100% (6/6)
Failed-approach guardrails
The largest hidden saving is stopping the next agent from re-running a broken idea (e.g., setting SQLite synchronous=OFF after a prior crash test).
WITHOUT AI-MEMORY · SILOED PER-AGENT NOTES

What happens when you switch agents mid-task

1. 26K–52K cold-start discovery taxOpening Codex or OpenCode after Claude Code hits a rate limit forces the new agent to re-read your directory tree and config files from scratch.
2. Repeating failed experimentsBecause rejected ideas lived only in the previous agent’s chat scrollback, the new agent wastes 5–10 turns re-discovering the same bug.
3. Locked inside one machine or vendorBuilt-in MEMORY.md files do not sync across 20+ CLI harnesses or across teammates working on the same repository.
WITH AI-MEMORY + REGOLO CONSOLIDATION

Git-backed OKF v0.2 wiki + Claim-Once handoffs

1. Bounded startup brief on ai-memory runThe receiving agent starts with Where We Left Off, Locked Decisions, and a temporary local projection of the previous session.
2. Zero-LLM aging + opt-in Regolo consolidationDaily capture and FTS5 cost 0 tokens; background consolidation on brick-complexity-pro and qwen3.5-122b compiles clean wiki pages.
3. Plain Markdown you own in GitEvery page in 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).

PRODUCTION-READY EU INFERENCE · ZERO DATA RETENTION OpenAI-Compatible API

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.

DROP-IN ENDPOINT export OPENAI_BASE_URL="https://api.regolo.ai/v1" Keep your existing SDK & agent setup
Private AI should not require a private data center. Regolo gives your team an EU-native path from local experimentation to production-grade inference.