← Catalog

pi-recollect

Silent background cross-session memory for Pi: learns from finished sessions, injects a compact memory index, and lets the agent grep deeper memory on demand.

Extension

Install

Install with PiG

pig install npm:pi-recollect

Install with Pi

pi install npm:pi-recollect
Review before installing

Packages run code with your permissions and influence agent behavior. Catalog inclusion is not a security audit. Review the source before installing a third-party package.

Pi manifest JSON

The pi field of package.json.

{
  "extensions": [
    "./src/index.ts"
  ]
}

README

Written by the package's publisher, shown as published in version 2.0.1 (README.md). PiG does not review it.

pi-recollect

Background memory for Pi that works across sessions, modeled on the Codex CLI memory pipeline.

  • It saves memory without you seeing it. The chat model never calls a "save memory" tool. When Pi starts, a cheap model you pick learns from your finished sessions in the background (sessions idle ≥ 3 h).
  • Reading memory is cheap. A compact memory_summary.md, filtered to your current project, goes into the system prompt. The agent greps MEMORY.md and opens a session recap only when the topic matches, using at most 4–6 tool calls.
  • Plain Markdown in a git repo (~/.pi/agent/recollect/). You can read it, edit it, and check its history.

Automatic skill creation, vector search, and saving memory during the chat are out of scope for v0.1. See docs/design.md.

Install

pi install pi-recollect

For development, install a local clone instead: pi install ./pi-recollect.

Configure

~/.pi/agent/settings.json (a project's .pi/settings.json can override it):

{
  "recollect": {
    "extract": "provider/gpt-6-luna:low",        // Phase 1 model (provider/id[:thinking])
    "consolidate": "provider/gpt-6-luna:medium"  // Phase 2 model (defaults to extract)
  }
}
SettingDefaultMeaning
enabled / generate / usetruemaster switch / background pipeline / prompt injection
root~/.pi/agent/recollectmemory folder (git repo)
sessionsDir~/.pi/agent/sessionswhere Pi session .jsonl files live
extract, consolidate, fallbackModelunset (session model)"provider/id[:thinking]" or {provider,id,thinking}
minIdleHours3a session must be idle this long before extraction
maxAgeDays10ignore sessions older than this
maxSessionsPerRun / extractConcurrency4 / 4Phase 1 work per startup
minSessionChars4000skip tiny sessions without an LLM call
maxRawForConsolidation256top-N memories (by usage, then recency) sent to consolidation
maxUnusedDays30memories not used or refreshed for this long are forgotten
minNewInputs1batch Phase 2 until this many new memories (notes always trigger)
summaryMaxBytes10000hard limit on memory_summary.md (checked; one repair pass)
summaryMaxTokens2500budget for the whole injected memory section (instructions + cwd-filtered summary)
phase2TimeoutMinutes15consolidation worker timeout
startupDelaySeconds15delay before the background run after startup
excludeCwds[]globs like "/tmp/**"; sessions from these cwds are ignored
debugLogfalseNDJSON events in <root>/.state/log.ndjson
piCommandpibinary used to spawn the consolidation worker

Commands

Command(blank)
/memory statuscounts, models, last run, summary size, errors
/memory run [phase1|phase2]run now (ignores the idle threshold, forces consolidation)
/memory remember <text> / /memory forget <text>write a note in notes/; the next consolidation applies it
/memory pause / resumestop/start the background pipeline
/memory reloadrebuild the injected memory section mid-session (breaks the prompt cache once)

You can also just ask the agent to "remember X". The injected instructions tell it to write a note in notes/.

How it works

session_start (startup) ──15s──► lock ─► prune ─► Phase 1 ─► Phase 2 ─► commit
Phase 1: idle sessions → active branch → tiered/redacted transcript → extract model (JSON)
         → .state/raw/<id>.md + .state/summaries/<id>.md      (empty output = nothing saved)
Phase 2: sync raw_memories.md + session_summaries/ → git diff vs baseline
         → no changes? stop : spawn `pi -p` worker (file tools only, path guard)
         → edits MEMORY.md + memory_summary.md → validate → git commit
Read:    session_start → filter memory_summary.md by cwd → systemPromptOptions.sections.memory
Usage:   tool_result touching session_summaries/ → usage counters → ranking/forgetting
~/.pi/agent/recollect/
├── memory_summary.md      # injected; v1 header; scope headings carry (cwd=...)
├── MEMORY.md              # grep-able handbook
├── raw_memories.md        # generated Phase 2 input
├── session_summaries/     # one recap per selected session
├── notes/                 # explicit remember/forget requests (never deleted)
└── .state/                # state.json, lock, raw/, summaries/, log.ndjson (git-ignored)

The consolidation worker runs as pi -p --no-session --no-extensions -e src/worker-guard.ts --tools read,edit,write,grep,find,ls. The guard blocks any path outside the memory root and any write except to MEMORY.md and memory_summary.md. If validation fails, the agent's edits are rolled back and the next run retries.

Development

npm install
npm run typecheck
npm test