codex-agent-mem is a local-first MCP memory layer. Codex was the first
adapter, but the public core is designed around portable MCP retrieval and
local SQLite persistence.
- A local capture adapter or API submits an agent turn.
- The payload is normalized into a generic event envelope.
- The event is persisted into local SQLite with FTS-backed retrieval.
- Heuristics extract operational observations:
- session summaries;
- user requests;
- objectives;
- decisions;
- constraints;
- pending and completed work;
- blockers;
- project, mission, and session Definition of Done items;
- completion claims.
- The store derives project operational state from those observations.
mem_bootstrap_contextresolves startup scope defensively from explicit thread/path hints before active context is loaded.mem_context_packbuilds a scoped continuity pack from recent turns, durable decisions, open work, DoD state, and scope guardrails.pack_hashandknown_pack_hashavoid resending unchanged continuity packs.- MCP clients retrieve memory, open work, health, provenance, snapshots, policies, inheritance, repairs, and runtime health through the configured profile.
- The optional local API/UI renders the same store for inspection.
- Optional
AGENTS.mdsync writes a generated continuity block only when compression is favorable.
project_key is the broad workspace or project scope. It may intentionally
cover several chats, agents, or client runtimes.
Capture adapters resolve project identity from explicit configuration first, then from referenced repository paths, AGENTS scope, project-state canonical names, and finally the working directory. Technical working directories and broad roots are treated cautiously so they do not become accidental project keys when the turn clearly points to a narrower project.
session_id is the persisted chat/session scope inside that project. v1.0.1
exposes mem_session_list(project_key), mem_scope_resolve(project_key, hint),
and optional session_id filters on retrieval tools so broad project scopes
can be narrowed without changing the database model. mem_scope_resolve and
mem_session_list use explicit hints such as chat title, cwd/repo path, query,
or sub-scope hint; those hints are selection aids, not a formal sub-project
taxonomy.
The current live turn is not guaranteed to appear in retrieval until it has been captured and persisted. Session-aware retrieval filters stored local memory; it does not add live message tracking or hosted sync.
Project-wide packs can still be useful for broad continuity, but v1.0.1 treats
multi-session or multi-sub-scope packs as ambiguous. Defensive startup callers
should use mem_bootstrap_context first. When lanes are ambiguous, it returns
candidate lanes and does not fetch a project-wide context pack. If a caller
explicitly requests mem_context_pack(project_key) anyway, the pack emits a
visible scope warning, reports the last captured turn, and marks the objective
as a project-wide candidate rather than live current intent.
Adapters are intentionally thin. They translate a local runtime event into the generic envelope; they do not define the memory model.
- Codex
notifyis the historical capture adapter and remains supported. - Generic ingestion is available for local tools that can submit normalized events.
- MCP retrieval is the portable surface used by Codex, Claude Code, Google Gemini CLI, Qwen Code/Ollama workflows, and other MCP-capable local clients.
The tool surface is controlled by profile:
minimal: session list, continuity pack, open work, completion check, runtime health.standard: read-oriented retrieval, provenance, health, snapshot listing, policy listing/validation, inheritance listing, and repair proposals.full: the complete local tool surface, includingmem_note_createfor manual operational notes; mutating tools remain blocked when--read-onlyis active.
This keeps low-impact clients small while preserving a complete local inspection and governance surface for maintainers.
The canonical MCP payload is structuredContent.
- List-shaped results are wrapped as
{items, count}. mem_session_listfollows the same object-root list contract and returns recent persisted sessions for oneproject_key, optionally filtered byquery/sub_scope_hintto help choose a session in broad workspaces.mem_scope_resolveandmem_bootstrap_contextare read-only startup helpers. They expose candidate lanes and avoid silent broad-pack retrieval when a broad project key contains several possible threads.content.textis a response-mode view:compactfor short text when the client exposes structured payloads;balancedfor short text plus a pointer tostructuredContent;verbosewhen the client needs payloads rendered into text.
- MCP stdio server: primary retrieval surface.
- Optional loopback daemon: local process-sharing optimization; not a remote service.
- FastAPI UI: local inspection surface at
/ui. - SQLite database: plaintext local store by default.
The public 1.0.x core does not require embeddings, vector search, hosted web
bridges, OAuth, ChatGPT web integration, Claude web integration, or a SaaS
backend.