Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Long-Term Memory

Plugin ID: nexus.memory.longterm

Cross-session memory persistence. Stores memories as individual markdown files with YAML frontmatter. Injects a lightweight index into the system prompt on boot and provides LLM tools for CRUD operations.

Configuration

nexus.memory.longterm:
  # Where memory files live.
  # Default: ~/.nexus/memory/ (CLI), ~/.nexus/agents/<agentID>/memory/ (desktop shell)
  path: "~/.nexus/memory/"

  # Memory scope: "agent" (per-agent isolated), "global" (shared across agents), or "both".
  # "both" merges global + agent-scoped memories, with agent-scoped taking precedence on key conflicts.
  scope: "agent"

  # Inject memory index (titles + keys + tags) into system prompt on session start.
  auto_load: true

  # Instructions injected into system prompt telling the LLM when to
  # proactively save memories mid-session. Empty string = only save when
  # user explicitly asks (tools still available, just no prompting to use them).
  auto_save_instructions: ""

  # Agent ID for agent-scoped storage (injected automatically by desktop shell).
  agent_id: ""

Scope Resolution

scope valuePaths searchedWrite target
agent~/.nexus/agents/<agentID>/memory/agent path
global~/.nexus/memory/global path
bothglobal path + agent path (agent wins conflicts)agent path

For CLI mode (no agent ID), agent and global behave identically — both use the configured path.

Storage Format

One file per memory entry at <memory_path>/<key>.md:

---
key: user_prefers_dark_mode
tags:
  category: preference
  domain: ui
created: 2026-04-10T14:30:00Z
updated: 2026-04-15T09:00:00Z
source_session: 20260410-143022
---

User strongly prefers dark mode across all interfaces.
They mentioned eye strain with light themes during long sessions.

Keys are sanitized to lowercase alphanumeric with hyphens and underscores, truncated to 128 characters.

LLM Tools

ToolParametersDescription
memory_writekey (string), content (string), tags (map, optional)Create or update a memory entry
memory_readkey (string)Read full content of a memory entry
memory_listtags (map, optional)List all memories, optionally filtered by tags (AND semantics)
memory_deletekey (string)Delete a memory entry

System Prompt Injection

When auto_load: true, the plugin injects a section listing all available memories with key, tags, and a one-line preview (first line of content). Full content is retrieved on demand via memory_read.

Events

EventDirectionPayload
memory.longterm.loadedPlugin -> busLongTermMemoryLoaded
memory.longterm.storeAny -> pluginLongTermMemoryStoreRequest
memory.longterm.storedPlugin -> busLongTermMemoryStored
memory.longterm.readAny -> pluginLongTermMemoryReadRequest
memory.longterm.resultPlugin -> busLongTermMemoryReadResult
memory.longterm.deleteAny -> pluginLongTermMemoryDeleteRequest
memory.longterm.deletedPlugin -> busLongTermMemoryDeleted
memory.longterm.listAny -> pluginLongTermMemoryQuery
memory.longterm.list.resultPlugin -> busLongTermMemoryListResult

Desktop Shell Integration

The desktop shell automatically injects agent_id into the plugin config before boot, enabling per-agent memory isolation without manual configuration.