Skip to main content

Second Brain

Mercury has a persistent, structured memory that grows with every conversation. When enabled, it automatically extracts, stores, and retrieves facts about you — your preferences, goals, projects, habits, and more.

How it works

  1. Extraction — After each conversation, Mercury pulls 0–3 facts and stores them with type, confidence, importance, and durability scores.
  2. Retrieval — Before each message, the top 5 relevant memories (within a 900-char budget) are injected into context. Mercury references them naturally.
  3. Consolidation — Every 60 minutes, Mercury builds a profile summary, an active-state summary, and generates reflection memories from detected patterns.
  4. Pruning — Active-scope memories stale after 21 days. Inferred memories decay. Low-confidence durable memories are dismissed after 120 days. Memories reinforced 3+ times are promoted to durable.

Memory Types

TypeScopeWhat it stores
identitydurableWho you are — name, role, background
preferencedurableWhat you like and dislike
goalactiveWhat you're working toward
projectactiveWhat you're building
habitdurableBehavioral patterns and routines
decisionactiveDecisions and choices you've made
constraintdurableRules and constraints you follow
relationshipdurablePeople and connections
episodeactiveSpecific events and experiences
reflectiondurableSystem-generated insights from patterns

Conflict Resolution

When Mercury detects opposing memories (e.g. "prefers TypeScript" vs "prefers Python"), the higher-confidence one wins. If equal, the newer one wins. Negation mismatches ("likes X" vs "does not like X") are detected and resolved automatically.

Evidence Kinds

  • direct — Explicitly stated by you (highest confidence)
  • inferred — Pattern Mercury detected (decays over time)
  • manual — Added via /memory command
  • system — Auto-generated reflections from consolidation

Managing Memory

Use /memory in any channel:

ActionCLITelegram
OverviewArrow-key menu → OverviewInline button: 📋 Overview
Recent memoriesArrow-key menu → RecentInline button: 🔍 Recent
SearchArrow-key menu → SearchNot available (ask Mercury to search)
Pause learningArrow-key menu → PauseInline button: ⏸ Pause
Resume learningArrow-key menu → ResumeInline button: ▶ Resume
Clear allArrow-key menu → Clear (with confirmation)Inline button: 🗑 Clear → Yes

Enable / Disable

Second Brain is enabled by default. To disable it:

  • Environment variable: SECOND_BRAIN_ENABLED=false
  • Config file: set memory.secondBrain.enabled: false in ~/.mercury/mercury.yaml

When disabled, Mercury falls back to basic long-term fact search (JSONL, text-match only). No extraction, no consolidation, no SQLite.

All data is stored locally in ~/.mercury/memory/second-brain/second-brain.db (SQLite). Nothing leaves your machine.

Troubleshooting

Native module version mismatch

If you see NODE_MODULE_VERSION mismatch errors in logs, the better-sqlite3 native addon was compiled against a different Node.js version than your runtime. Fix with:

npm rebuild better-sqlite3

When better-sqlite3 fails to load, Second Brain silently falls back to disabled — memory extraction and consolidation will not run. Check daemon logs (mercury logs) for SQLite-related errors if memories aren't being stored.