guides/agent-memory 1.00

Agent memory for coding agents

Agents now remember across sessions — what harnesses store, how memory layers work over MCP, and why memory should be local, measured, and visible like every other retrieval.

What agent memory is

Agent memory is durable context that survives a session: the fact that auth lives in src/auth/guard.ts, that this team prefers pnpm, that a migration replaced webpack with vite last month. Without it, every session re-discovers the same facts — slowly, and sometimes wrongly. With it, an agent starts already knowing the shape of your project and your preferences.

The harnesses converged on this fast. Claude Code layers static instructions (CLAUDE.md / AGENTS.md) with auto-memory — a per-project MEMORY.md the agent itself writes and reads every session. Cursor's index carries workspace context across chats. Devin checkpoints task state; Antigravity treats artifacts as memory.

The three places memory lives

The trust problem, and three properties that fix it

A memory that's wrong is worse than no memory — it poisons every session that trusts it. Three properties make memory trustworthy:

How OCE does it

OCE ships a memory store beside the code index, wired the same way as everything else:

# the built-in agent harvests insights + preferences as it works
oce trace

# any MCP client gets the memory tools
claude mcp add oce -- oce mcp
#   → memory_remember / memory_recall / memory_forget

# read and manage it directly
oce memory list
oce memory add "the team prefers pnpm" --kind preference
oce memory search "how is auth done"

Recall is hybrid — lexical + embeddings fused, the same conviction as code search. Memories render as a Markdown twin (memories.md beside memories.json) that you can read, diff, and hand-edit. Secret-shaped content is refused at write time. Every injection shows in the evidence rail's context engineering view. Nothing leaves the machine, and MCP clients share the same store — Claude Code, Cursor, CI bots — without a hosted service in the middle.

Where the line is

Memory is not a knowledge graph, not a hosted service, and not a substitute for code search — it's the small, high-trust layer above it: facts, preferences, and decisions that make each session start smarter than the last one ended. If a "memory" is big enough to need its own ranking pipeline, it belongs in the index; if it's a fact small enough to state in one sentence, it belongs here.

Frequently asked questions

What is agent memory?

Durable cross-session context: codebase facts, user preferences, decisions. Harnesses keep it natively (Claude Code's MEMORY.md); memory layers expose it over MCP for portability across clients.

How does Claude Code memory work?

CLAUDE.md/AGENTS.md hold static, human-maintained instructions; auto-memory is a per-project memory file the agent itself maintains and the system prompt loads every session.

Harness memory or a memory layer?

Harness memory for single-tool workflows; an MCP memory layer when you want one store across Claude Code, Cursor, and CLI agents — provided it gives you visibility and provenance.

Can agent memory run fully locally?

Yes — OCE's memory store lives beside the index, recall fuses lexical and local embeddings, and the MCP tools serve it to any client on stdio or localhost HTTP.

What happens when a memory goes stale?

Supersede it: the replacement stops the old fact from being recalled while keeping it auditable. OCE also frames remembered context as possibly-stale in the prompt, so fresh tool results win conflicts.