🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

opencode-agent-memory

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

opencode-agent-memory

Letta-style editable memory blocks for OpenCode.

latest
Source
npmnpm
Version
0.2.0
Version published
Weekly downloads
426
-1.84%
Maintainers
1
Weekly downloads
 
Created
Source

opencode-agent-memory

Letta-style editable memory blocks for OpenCode.

Experimental

This plugin is experimental. The core idea - giving the agent persistent, self-editable memory blocks - is adapted from Letta. Specifially, the plugin follows Letta's shared memory blocks pattern - the markdown files on disk are shared state that every OpenCode session can read and write.

Think of it as AGENTS.md with a harness. OpenCode supports rules via AGENTS.md and custom instruction files - this plugin is similar in spirit, but 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. The content is similar; the scaffolding around it is what's different.

For background on the memory concept, see Letta's docs on memory and memory blocks.

Features

  • Persistent memory - Information survives across sessions and context compaction
  • Shared across sessions - Global blocks shared across all projects, project blocks shared across sessions in that codebase
  • Self-editing - The agent can read and modify its own memory with dedicated tools
  • System prompt injection - Memory blocks appear in the system prompt, always in-context
  • Journal - Append-only entries with semantic search for capturing insights, decisions, and discoveries across sessions

Requirements

Installation

Add to your OpenCode config (~/.config/opencode/opencode.json):

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

Restart OpenCode and you're ready to go.

Optionally, pin to a specific version for stability:

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

OpenCode fetches unpinned plugins from npm on each startup; pinned versions are cached and require a manual version bump to update.

Local Development

If you want to customize or contribute:

git clone https://github.com/joshuadavidthomas/opencode-agent-memory ~/.config/opencode/opencode-agent-memory
mkdir -p ~/.config/opencode/plugin
ln -sf ~/.config/opencode/opencode-agent-memory/src/plugin.ts ~/.config/opencode/plugin/memory.ts

Usage

Memory Tools

The plugin gives the agent 3 tools for managing memory:

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

You interact with memory by editing the markdown files directly or asking the agent to update its memory.

Journal Tools

When the journal is enabled, the agent gets 3 additional tools:

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

Journal entries are append-only markdown files with YAML frontmatter, stored in ~/.config/opencode/journal/. Each entry records which project, model, provider, agent, and session it was written from. Semantic search uses local embeddings (all-MiniLM-L6-v2) - no data leaves your machine.

Default Blocks

Three blocks are seeded on first run:

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

These are just starting points. Create whatever blocks make sense for your workflow - debugging-notes, api-preferences, learned-patterns, etc.

Memory Locations

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

Block Format

Each block is a markdown file with YAML frontmatter:

FieldTypeDefaultDescription
labelstringfilenameUnique identifier for the block
descriptionstringgenericTells the agent how to use this block
limitinteger5000Maximum characters allowed
read_onlybooleanfalsePrevent agent from modifying

All fields have defaults for graceful degradation, but description is essential - without it, the agent gets a generic fallback and won't know how to use the block effectively. See Letta's docs on the importance of the description field.

Journal Configuration

The journal is opt-in. Enable it in ~/.config/opencode/agent-memory.json:

{
  "journal": {
    "enabled": true
  }
}

You can optionally suggest tags to guide the agent's classification:

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

Tags are free-form strings - the agent can use any tag, not just the suggested ones. Suggested tags appear in the system prompt to provide guidance.

Inspiration

The memory architecture and philosophical framing are adapted from Letta (formerly MemGPT), a framework for building LLM agents with editable long-term memory.

Also worth exploring: private-journal-mcp by Jesse Vincent, which gives Claude a private journaling capability to process feelings and thoughts. His blog post about it explores similar territory around AI self-reflection and persistent inner experience.

Contributing

Contributions are welcome! Here's how to set up for development:

git clone https://github.com/joshuadavidthomas/opencode-agent-memory
cd opencode-agent-memory
bun install

Then symlink the plugin to your OpenCode config:

mkdir -p ~/.config/opencode/plugin
ln -sf "$(pwd)/src/plugin.ts" ~/.config/opencode/plugin/memory.ts

License

opencode-agent-memory is licensed under the MIT license. See the LICENSE file for more information.

opencode-agent-memory is not built by, or affiliated with, the OpenCode team.

OpenCode is ©2025 Anomaly.

FAQs

Package last updated on 01 Mar 2026

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts