persistent-memory

Public

Forked from khtsly/persistent-memory

Give your local LLM a long-term brain. This plugin stores facts, preferences, projects, and notes across conversations in a local SQLite database — zero cloud, zero external services, fully portable.

62 Downloads

README

Persistent Memory — LM Studio Plugin

Give your local LLM a long-term brain. This plugin stores facts, preferences, projects, and notes across conversations in a local SQLite database — zero cloud, zero external services, fully portable.

Retrieval Scoring (Inspired by SRLM)

Memories are ranked by a composite score blending four signals (inspired by the SRLM paper which showed that combining multiple uncertainty signals outperforms any single one):

SignalWeightWhat it measures
TF-IDF Similarity55%Semantic relevance to the current query
Recency Decay20%Exponential decay based on last access time
Confidence15%How certain we are about this fact (0–1)
Access Frequency10%How often this memory has been surfaced

Decay follows score = 2^(-days/halfLife) — memories that stop being accessed gradually fade, just like human memory.

Memory Scopes

ScopePersistenceUse for
global (default)Forever, all chatsUser facts, preferences, standing instructions
projectForever, project-filteredProject-specific context, repo details, team info
sessionUntil LM Studio closesTemporary context, scratch notes, current-task state

Global memories are injected into every conversation automatically. Project memories are persisted to SQLite but only surface when that project is referenced. Session memories live entirely in memory — they're never written to disk and vanish when the plugin reloads. This lets you store throwaway context without polluting your permanent knowledge base.

Memory Categories

CategoryUse for
factThings about the user: name, job, skills
preferenceLikes, dislikes, coding style, UI choices
projectCurrent work, repos, goals
noteFree-form memos
instructionStanding instructions ("always use TypeScript")
relationshipPeople, teams, organizations
contextSituational context ("interviewing at X")

Project-Scoped Memory Guidance

When Active Project is set, durable repo knowledge should be written into that project's namespace instead of global memory.

Scope split

  • global: user-wide preferences and standing instructions
  • project: repo-specific knowledge, architecture decisions, workflow rules, team conventions, recurring issues
  • session: temporary task state and scratch context

Important limitation

Setting Active Project and enabling AI extraction is only sufficient if the write path also stores extracted memories with scope: "project" and the configured project slug. This plugin now applies that rule to auto-extracted chat memories.

Project ingest / bootstrap

Use the bootstrap flow to store distilled project memories, not raw file dumps. Good bootstrap entries include:

  • architecture invariants
  • important commands
  • service boundaries
  • persistent constraints
  • known failure modes
  • active goals

Run a project ingest when:

  • a repo is connected for the first time
  • architecture changes materially
  • major tickets land
  • conventions change

Privacy

All data stays on your machine. The memory database is a single file at ~/.lmstudio/plugin-data/persistent-memory/memory.db. You can:

  • Back it up: Just copy the file
  • Move it: Change the storage path in settings
  • Delete it: Remove the file to start fresh
  • Inspect it: Open with any SQLite browser

License

MIT