Project Memory
How annodex stores project context — passive injection, working memory, and promotion to MEMORY.md / CONTEXT.md.
Annodex uses a dual-layer memory model (Phase 1): durable markdown files injected into every new thread, plus a JSONL working memory store the agent can read and write through MCP tools.
Overview
Passive injection (thread start) Working memory (agent tools) Promotion (you or agent)
──────────────────────────────── ──────────────────────────── ────────────────────────
~/.config/annodex/SOUL.md retain → JSONL entries → MEMORY.md
~/.config/annodex/HARNESS.md recall → lexical search → CONTEXT.md
{project}/AGENTS.md reflect → synthesize answer
{project}/MEMORY.md
{project}/CONTEXT.md| Layer | Where | Who updates it | When the agent sees it |
|---|---|---|---|
| Global persona | ~/.config/annodex/SOUL.md, HARNESS.md | You (edit files) | Every thread start (system prompt) |
| Project instructions | {project}/AGENTS.md or CLAUDE.md | You | Every thread start |
| Project memory | {project}/MEMORY.md (or memory.md) | You, or promote from working memory | Every thread start |
| Project context | {project}/CONTEXT.md (or context.md) | You, or promote from working memory | Every thread start |
| Working memory | ~/.config/annodex/memory/<hash>/entries.jsonl | Agent via retain / recall / reflect | When tools are called |
Working memory is not vector search in Phase 1 — recall ranks entries by lexical match, importance, and recency.
Passive injection
When annodex starts or resumes a Codex thread, buildSystemPrompt() loads context files in this order:
- Annodex runtime rules (in code) — tool authorization and safety baseline
- Global SOUL.md — persona, tone, working style (neutral default seeded on first start)
- Global HARNESS.md — behavioral constraints and output rules
- Project AGENTS.md (or CLAUDE.md) — project-specific instructions
- Project MEMORY.md — durable analysis log and long-term notes
- Project CONTEXT.md — stable facts, paths, conventions, assumptions
These files are background continuity, not hard overrides for safety or tool rules. Edit project files (MEMORY.md, CONTEXT.md, AGENTS.md) from the Files panel or your editor. Edit global SOUL.md / HARNESS.md under ~/.config/annodex/ (see Configuration). Changes apply on the next turn that starts a fresh system prompt context.
Lowercase filenames (memory.md, context.md) are detected if the uppercase file is missing.
Working memory store
Per-project JSONL lives under annodex config (not inside the repo):
~/.config/annodex/memory/<sha1(project-cwd)>/entries.jsonlOverride the config root with ANNODEX_CONFIG_DIR — memory follows the same path.
Each line is one record with fields such as:
- content — the fact or note
- importance — 0–1 (higher → more likely to become a promotion candidate)
- memoryType —
fact,context,preference,decision, ornote - governance.candidate —
none,spark, orproject_memory(UI highlights candidates for promotion)
Agent tools (MCP)
Three tools are exposed through the annodex-memory MCP server:
| Tool | Purpose |
|---|---|
| retain | Store one or more compact facts for later |
| recall | Search working memory with a natural-language query |
| reflect | Answer a question by synthesizing top recall hits |
Enable the memory extension
- Start annodex (the MCP server calls the local HTTP API).
- Open Settings → Extensions.
- Add or select the Annodex Memory preset (
annodex-memory-mcp). - Click Install to Codex (once per machine/user).
- Enable annodex-memory for the session from the chat bar Extensions control.
On first session start, annodex also registers the extension definition in ~/.config/annodex/extensions.json.
The MCP process uses the Codex workspace cwd as the project key and reads the annodex listen port from ~/.config/annodex/annodex.json (default port 30121).
Tools panel — inspect and promote
Open the Tools tab in the right sidebar (with a project selected):
- Counts by memory type and number of promotion candidates
- Path to the JSONL store (relative to the project when possible)
- Promotion candidates — high-importance or decision/context entries
- Recent memory — latest retained items
Use To MEMORY.md or To CONTEXT.md to append a candidate to the project markdown files. Promotion is idempotent — the same entry is not duplicated if already promoted.
You can also promote programmatically:
POST /api/memory/promote
Content-Type: application/json
{
"cwd": "/path/to/project",
"memoryId": "<uuid from working memory>",
"target": "memory"
}target may be "memory" or "context".
When to use which file
| File | Good for |
|---|---|
| MEMORY.md | Dated analysis notes, experiment outcomes, decisions with rationale |
| CONTEXT.md | Stable bullets: sample naming, directory layout, toolchain versions, lab conventions |
| Working memory | Session-local facts the agent discovers; candidates you review before promoting |
A practical workflow:
- Let the agent retain durable facts during analysis.
- Review candidates in Tools → Memory.
- Promote vetted items to MEMORY.md or CONTEXT.md.
- Future threads automatically load the markdown layers at startup.
API reference (local server)
| Endpoint | Method | Purpose |
|---|---|---|
/api/memory/status?cwd= | GET | Summary for Tools panel |
/api/memory/retain | POST | { cwd, sessionId?, items[] } |
/api/memory/recall?cwd=&query= | GET | Lexical recall |
/api/memory/reflect | POST | { cwd, query, context?, limit? } |
/api/memory/promote | POST | { cwd, memoryId, target } |
/api/agent/runtime?cwd= | GET | Runtime status plus memory when cwd is set |
These routes are intended for localhost use alongside the annodex UI and MCP bridge.
Related configuration
See Configuration for path tables and Usage for day-to-day workflow in the workspace.
Roadmap (not in Phase 1)
Future phases may add vector or FTS search, automatic top-K recall at turn start, checkpoints, and sleep-style compression. Phase 1 deliberately mirrors a simple, inspectable JSONL + markdown hybrid.