Skip to content

Memory integration ​

Leyline bundles the memory extension from .pi/extensions/memory/index.ts. The runtime loads it through resourceLoaderOptions.additionalExtensionPaths.

The extension stores durable Markdown memory. The Memory Inspector uses server routes in server/pi-api/memories.js to read and change the same records.

Storage and scope ​

The default database is:

text
~/.local/share/leyline/memory.sqlite

The memories table uses three scopes:

  • global records are visible in all projects and sessions.
  • project records are visible under one project root.
  • session records are visible only for one session file.

Leyline finds the nearest parent directory that contains .git. If it finds no Git root, it uses the current working directory. It derives project and session IDs from SHA-256 hashes of canonical paths.

Other modules use the same database for backend_connections, leyline_settings, subagent_overrides, vision_overrides, and rollout_feedback. Tables appear when their owning modules initialize storage.

Display preferences and saved connections use the native app backend's database. Memory, file-editor settings, feedback, and agent overrides use the selected backend's database. A global memory or override applies to that backend, not every saved connection.

Agent defaults, Project settings, and Session details edit global, project, and session subagent/vision overrides. These controls share AgentSettings.vue. They are no longer separate Subagents or Vision drawers. The Memory Inspector remains a separate surface.

Pi provider/model overrides in models.json are different from Leyline's subagent and vision overrides. Pi owns global provider, MCP, and credential files outside SQLite. See Pi configuration storage.

Rollout labels can be helpful or unhelpful, with an optional note. Leyline adds this feedback to transcript entries when it builds session detail. See SQLite metadata for table ownership.

Runtime context ​

At session start, the extension loads active memory into three caches. Before each agent turn, it adds a bounded memory block to the system prompt.

The current limits are:

  • 8 global records
  • 12 project records
  • 16 session records
  • 16 KiB for the complete injected block

New and changed records affect future turns. They do not change context that the model already received.

Memory has lower priority than system and developer instructions, the current request, project instructions, and verified repository data.

Agent tools and command ​

The extension registers these tools:

  • list_memory lists visible active or archived records.
  • search_memory searches visible content, reasons, and tags.
  • record_memory creates a record.
  • update_memory replaces the content, reason, and tags of a visible record.
  • archive_memory archives visible records without deleting them.

The /memory command shows the database and context. /memory list lists active records. /memory search <query> searches active records.

The browser API also supports create, edit, archive, restore, and permanent delete operations. See the API reference.

Path override ​

Set LEYLINE_MEMORY_DIR before the backend starts to use a different data directory. Connections, display/file settings, memory, subagent/vision overrides, and feedback then use memory.sqlite there. This variable does not relocate pi configuration or credentials.