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

推荐订阅源

Recent Announcements
Recent Announcements
J
Java Code Geeks
U
Unit 42
GbyAI
GbyAI
大猫的无限游戏
大猫的无限游戏
L
LangChain Blog
D
Docker
F
Fortinet All Blogs
N
Netflix TechBlog - Medium
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
罗磊的独立博客
I
InfoQ
The Cloudflare Blog
小众软件
小众软件
V
Visual Studio Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
Engineering at Meta
Engineering at Meta
S
SegmentFault 最新的问题
爱范儿
爱范儿
Hugging Face - Blog
Hugging Face - Blog
P
Proofpoint News Feed
V
V2EX
月光博客
月光博客
Martin Fowler
Martin Fowler

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.