Skip to content

Agent Memory

Agent Memory

Agent Memory brings Letta-style editable memory blocks to OpenCode. Inspired by Letta (formerly MemGPT), the plugin gives the agent persistent, self-editable memory blocks — shared markdown files on disk that every OpenCode session can read and write.

Think of it as AGENTS.md with a harness: adds structure (scoped blocks with metadata and size limits), dedicated tools for memory operations, and prompting that encourages the agent to actively maintain its own memory.

Key Features

FeatureDescription
Persistent memorySurvives across sessions and context compaction
Shared across sessionsGlobal blocks shared across all projects; project blocks shared across sessions in that codebase
Self-editingThe agent can read and modify its own memory with dedicated tools
System prompt injectionMemory blocks appear in the system prompt, always in-context
JournalAppend-only entries with semantic search for capturing insights and decisions

Installation

Add to ~/.config/opencode/opencode.json:

{
  "plugin": ["opencode-agent-memory"]
}

Pin to a specific version:

{
  "plugin": ["opencode-agent-memory@0.2.0"]
}

Memory Blocks

Default blocks seeded on first run:

BlockScopePurpose
personaglobalHow the agent should behave and respond
humanglobalDetails about you (preferences, habits, constraints)
projectprojectCodebase-specific knowledge (commands, architecture, conventions)

Memory file locations:

  • Global blocks: ~/.config/opencode/memory/*.md
  • Project blocks: .opencode/memory/*.md (auto-gitignored)

Journal

Enable the journal for semantic search across sessions:

{
  "journal": {
    "enabled": true,
    "tags": [
      { "name": "perf", "description": "Performance optimization work" },
      { "name": "debugging", "description": "Debugging sessions and findings" }
    ]
  }
}

Journal config goes in ~/.config/opencode/agent-memory.json.

Semantic search uses local embeddings (all-MiniLM-L6-v2) — no data leaves your machine.

Tools

Memory Tools

ToolDescription
memory_listList available memory blocks (labels, descriptions, sizes)
memory_setCreate or update a memory block (full overwrite)
memory_replaceReplace a substring within a memory block

Journal Tools (when journal is enabled)

ToolDescription
journal_writeWrite a new journal entry with title, body, and optional tags
journal_searchSearch entries semantically, filter by project or tags
journal_readRead a specific journal entry by ID