惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
J
Java Code Geeks
Apple Machine Learning Research
Apple Machine Learning Research
Jina AI
Jina AI
博客园_首页
C
Check Point Blog
小众软件
小众软件
博客园 - 叶小钗
Blog — PlanetScale
Blog — PlanetScale
Engineering at Meta
Engineering at Meta
美团技术团队
Martin Fowler
Martin Fowler
Vercel News
Vercel News
D
Docker
罗磊的独立博客
B
Blog RSS Feed
The Cloudflare Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 聂微东
Last Week in AI
Last Week in AI
T
Tailwind CSS Blog
雷峰网
雷峰网
博客园 - Franky

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Give Your AI Persistent Memory: OpenCode + MemPalace in 1...
geco · 2026-05-15 · via DEV Community
Cover image for Give Your AI Persistent Memory: OpenCode + MemPalace in 10 Minute

geco

The Problem

Every OpenCode session starts from scratch. Your AI doesn't remember past conversations, decisions, or solved problems. You repeat context over and over.

The Solution

opencode-mempalace-persistence is a pure TypeScript plugin that auto-saves every conversation to MemPalace — a local vector database with 96.6% recall on LongMemEval. No cron, no cloud, no API keys.

Architecture

The plugin uses two OpenCode hooks:

  1. chat.message — when you send a new question, the previous turn (question + answer) is saved
  2. session.idle — catches the last turn before you close OpenCode

Each turn is categorized by wing type (developer, creative, emotions, family, consciousness) and fed to MemPalace's vector store. Knowledge Graph facts (decisions, milestones, problems, preferences) are extracted automatically.

The mining runs asynchronously — state is saved immediately, and MemPalace indexing happens in the background. The UI is never blocked.

Setup

Step 1: Install MemPalace

pip install mempalace

Enter fullscreen mode Exit fullscreen mode

Or with uv:

uv tool install mempalace

Enter fullscreen mode Exit fullscreen mode

Step 2: Configure OpenCode

Edit ~/.config/opencode/opencode.json:

{
  "plugin": ["opencode-mempalace-persistence"],
  "mcp": {
    "mempalace": {
      "type": "local",
      "command": ["mempalace-mcp"],
      "enabled": true
    }
  },
  "instructions": ["AGENTS.md", "~/.mempalace/identity.txt"]
}

Enter fullscreen mode Exit fullscreen mode

Step 3: Create AGENTS.md

Create ~/.config/opencode/AGENTS.md:

# Memory & Knowledge Instructions

Before answering, search MemPalace using MCP tools.

1. Call `mempalace_search` with the user's question as query.
2. Call `mempalace_kg_query` for entity "user" and filter by keywords.
3. Use relevant context in your response.

Enter fullscreen mode Exit fullscreen mode

Step 4: Add your identity

Create ~/.mempalace/identity.txt:

I am [name], a [role]. I work with [technologies].

Enter fullscreen mode Exit fullscreen mode

Step 5: Restart OpenCode

That's it. Every conversation is now automatically saved to MemPalace.

What Gets Saved

Every turn produces:

  • A drawer in MemPalace's vector database with the full conversation text
  • A wing assignment based on content analysis
  • Knowledge Graph facts: decisions, milestones, problems, preferences

Why Not Cron?

Before building this plugin, I was running a cron job to sync conversations. It was fragile, slow, and produced duplicates. The plugin approach is:

  • Real-time: sync happens immediately after each response
  • Delta-only: only new messages are processed
  • Async: the UI is never blocked
  • Graceful shutdown: session.idle catches the last turn

Links


Built with TypeScript, OpenCode Plugin SDK, and MemPalace. Published under MIT license.