INTEGRATION / AUGUST 4, 2026

OpenCode Memory
Persistent Long-Term Memory Plugin.

12 MIN READ
VERIFIED ENVIRONMENT
Tested on: OpenCode v1.0.2Runtime: Node.js v18+License: Apache-2.0

TL;DR

Give OpenCode persistent memory across every session. The Memwyre plugin auto-injects past project context when you start a session and auto-captures decisions when it ends — no manual context management needed.

The Problem: OpenCode Forgets Everything

Every time you close an OpenCode session, the context window resets. Your debugging breakthroughs, architecture decisions, and code patterns — all gone. You spend the first minutes of every session re-explaining your project.

OpenCode doesn't ship with built-in persistent memory. If you use OpenCode and Claude Code and Cursor, each tool maintains its own isolated silo.

Four Approaches to OpenCode Memory

FeatureManual Context FilesMem0 / Supermemory (Vector / Web RAG)MCP Memory ServerMemwyre Plugin
AutomationManual editsPredictive (LLM decides)Predictive (LLM decides)Deterministic (create/start → idle/end)
StorageFlat filesLocal SQLite + ChromaDBVariesCloud vault + entity graph
SetupManual file creationHours (SDK & API Key Config)JSON config + keynpm install @memwyre/opencode-plugin
Cross-Session❌ No persistence✅ Via API / Web extension✅ Via tool calls✅ Auto-injected on startup
Cross-Tool❌ OpenCode only❌ Custom pipelines / Chrome extension✅ Any MCP client✅ Shared vault (Claude Code, Cursor, VS Code)
LicenseN/AApache-2.0 / MITVariesApache-2.0
Best ForStatic rulesAPI developers & Web bookmarkingReal-time tool accessHands-free cross-tool memory

These approaches are complementary, not exclusive. Use manual files for static rules and Memwyre for dynamic OpenCode session memory — they work together.

Memwyre vs. Mem0 & Supermemory for OpenCode

Developers looking for long-term memory in OpenCode often evaluate general-purpose memory systems like Mem0 (API-first memory SDK) or Supermemory (web bookmarking & second brain engine). While both offer vector storage capabilities, neither includes a native plugin built for OpenCode's internal architecture.

Why OpenCode developers prefer Memwyre:

  • Native OpenCode SQLite Integration: Memwyre's plugin reads session transcripts directly from OpenCode's local database (`~/.local/share/opencode/opencode.db`) using native `node:sqlite`. It requires zero custom API integration code.
  • Automatic Lifecycle Hooks: Hooks into OpenCode's `create`/`start` events to inject past architectural context and `idle`/`end` events to capture newly learned facts seamlessly.
  • LoCoMo-10 Benchmark Scores: Memwyre's two-stage cross-encoder engine achieves 73.5% overall accuracy on the LoCoMo-10 benchmark vs. 43.7% for standard vector RAG systems. (Compare features on our Memwyre vs. Mem0 and Memwyre vs. Supermemory pages.)

How Cross-Tool Sync Actually Works

  • OpenCode (plugin): hooks into session lifecycle. On start → retrieval API. On end → POST transcript.
  • Claude Code / Cursor / VS Code / Claude Desktop / OpenClaw: connect via MCP or their respective plugins to same vault.
  • Same API key = same vault.

How the Memwyre OpenCode Plugin Works

① Session Start — Context Injection

When you start an OpenCode session (create/start/init events), the plugin calls the Memwyre retrieval engine for past memories matching the current project and injects them into the session prompt.

<memwyre-context>
## Past Memories for my-project
- Database uses PostgreSQL 15 with pgvector
- Auth flow: JWT + refresh tokens in httpOnly cookies
- Fixed: race condition in worker queue (use Redis lock)
</memwyre-context>

② Session End — Session Capture

When the session goes idle or ends, the plugin reads the session transcript — from the client API, event payload, or directly from OpenCode's local SQLite database at ~/.local/share/opencode/opencode.db. Sends it to Memwyre's background worker for extraction. Uses deduplication tracking to prevent double-captures.

Troubleshooting & Edge Cases

  • Misclassified memory: view/edit/delete via dashboard or API
  • Stale facts: Ebbinghaus decay auto-deprioritizes
  • Deduplication: capturedSessions Set prevents duplicate captures
  • SQLite fallback: if the client API doesn't provide messages, the plugin reads directly from OpenCode's local database

Install in 60 Seconds

Choose between automated CLI setup or direct npm package configuration:

Option A: Interactive CLI Installer (Recommended)

npx -y install-memwyre --opencode

Automatically detects your OpenCode config directory, logs you in via browser, and writes the plugin configuration.

Option B: Manual Plugin Setup

  1. 1. Install the npm package:
    npm install @memwyre/opencode-plugin
  2. 2. Register in OpenCode config (opencode.config.js or .opencode/plugins/memwyre.js):
    import { MemwyrePlugin } from '@memwyre/opencode-plugin';
    
    export default {
      plugins: [MemwyrePlugin]
    };
  3. 3. Export your API key:
    export MEMWYRE_API_KEY="bv_sk_your_api_key_here"
Need detailed setup docs or configuration options?
Read our official OpenCode integration guide covering plugin lifecycle hooks and SQLite transcript extraction.
Read OpenCode Docs →

What OpenCode Remembers With Memwyre

  • 🧠 Architecture Decisions
  • 🐛 Debugging Solutions
  • 🔗 Entity Relationships
  • ✂️ Dynamic Pruning

Benchmark: Why Retrieval Quality Matters

We evaluated Memwyre's retrieval engine against a flat vector RAG baseline on the LoCoMo-10 benchmark:

CategoryFlat Vector RAGMemwyre EngineImprovement
Multi-Hop24.0%45.0%+87.5%
Overall43.7%73.5%+68%
Context Tokens~26,000~3,000−88.5%

View the full LoCoMo-10 benchmark results →

Real-World Workflow: Iterative Feature Development

Scenario: building a payment integration over multiple sessions. Session 1 establishes the Stripe webhook architecture. Session 2 implements the subscription billing logic. Session 3 adds the retry/idempotency layer. Without memory, Session 3 doesn't know about the webhook signing secret rotation decision from Session 1. With Memwyre, all sessions share context.

Token Costs, Noise, & Security

Noise Filtration

Not every CLI error needs to be remembered. Memwyre's backend uses a specialized extraction model that differentiates between ephemeral noise and structural knowledge. Only the structural knowledge is saved to your vector vault, keeping your persistent memory highly relevant and dense.

Token Efficiency

By summarizing and deduplicating past sessions, the plugin injects a concise <memwyre-context> block that rarely exceeds 1,500 tokens. Compared to manually pasting in megabytes of old transcript logs, this targeted injection saves API costs while providing superior context.

Enterprise Security

Your code is yours. The Memwyre extraction engine uses zero-retention policies—meaning your transcripts are processed in memory and immediately discarded. For enterprise environments with strict compliance requirements, the entire Memwyre backend can be self-hosted behind your firewall.

License & Requirements

  • Apache-2.0
  • Node.js 18+, any OS
  • Self-hosting: Docker deployment
  • No special profile requirements (unlike OpenClaw)

Why Not Just Use Manual Context?

Manual files are good for static rules, but limited by maintenance, flat storage, and tool-locking. They don't update automatically as your architecture evolves.

FAQ

Does OpenCode have built-in memory?
No built-in persistence.
How do I give OpenCode persistent memory?
Install @memwyre/opencode-plugin, configure, set API key.
What is the best OpenCode memory plugin?
Depends. Memwyre for cross-tool (73.5% LoCoMo), claude-mem for local-first.
How is Memwyre different from claude-mem?
Same comparison.
Does the plugin work with Claude Code and Cursor?
Yes, same vault.
What license is Memwyre released under?
Apache-2.0.
What happens if Memwyre captures something wrong?
Dashboard/API edit/delete.
Is my memory data private?
Zero-retention, self-host option.