← Catalog

pi-compaction-recall

Lexical recall for Pi's compacted history, with automatic locators and bounded grep/expand tools

Package

Install

Install with PiG

pig install npm:pi-compaction-recall

Install with Pi

pi install npm:pi-compaction-recall
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 0.2.0 (README.md). PiG does not review it.

compaction-recall

English | 简体中文

An extension that helps AI agents recover details from compacted conversations.

Summaries can lose names, numbers and exact wording. compaction-recall lets the model search the original messages on the current branch and expand the relevant evidence, without replacing the agent's own compaction.

  • Local, in-memory retrieval. SQLite FTS5 runs in a Node worker, with no persistent index, embedding service or extra model calls.
  • Multilingual lexical support. English stemming, Chinese and Japanese character-bigram indexing, whole-word indexing for other scripts, exact dotted runs such as IPs and versions, and NFKC folding of fullwidth/halfwidth forms, with jieba word boundaries for automatic hints.
  • Two modes. full provides automatic history hints and three tools; lite keeps only grep and expansion, without an index or worker.

Installation

Currently supports Pi, with support for other agents planned.

Pi

Requires Pi and Node.js >=24.18.0. Tested with Pi SDK 1.4.0.

Install from npm:

pi install npm:pi-compaction-recall

The configuration file lives in the Pi profile's agent extensions directory: $PI_CODING_AGENT_DIR/extensions/compaction-recall.json (default: ~/.pi/agent/extensions/compaction-recall.json). It is not generated automatically; create it manually if needed. Without it, defaults and environment variables are used.

Tools

In full mode, short history hints are added before answers. The model decides when to search or expand further.

ToolPurpose
history_recallSearch compacted history with concept groups, alternative wording and exclusions.
history_expandRead an original entry by ID, with optional neighboring entries and pagination.
history_grepSearch with a JavaScript regular expression, independently of recall.

Configuration

Unset fields use defaults; environment variables override the configuration file. Reload after changes.

SettingDefaultDescriptionEnvironment override
mode"full"full: automatic hints and three tools; lite: grep/expand only.COMPACTION_RECALL_MODE (full/lite)
jiebatrueSet Han word boundaries for automatic queries with jieba; when off, Intl.Segmenter is used.COMPACTION_RECALL_JIEBA (on/off)
autoGate280Treat longer user messages as task instructions and skip automatic recall to avoid adding unrelated history; the model can still search with tools (Han codepoints count as 2, others as 1).COMPACTION_RECALL_AUTO_GATE
snippetBudget240Source-text budget per automatic hint or history_recall result; higher values allow longer excerpts (Han codepoints count as 2, others as 1).COMPACTION_RECALL_SNIPPET_BUDGET
recallTimeoutMs5000Manual recall deadline in milliseconds; native MATCH cannot be interrupted.COMPACTION_RECALL_QUERY_TIMEOUT_MS
preindex.userCycles10Completed user exchanges before preparation; integer 1–100, either preindex threshold triggers.COMPACTION_RECALL_PREINDEX_TURNS
preindex.toolRounds10Completed tool batches before preparation; integer 1–100, parallel calls count once per batch.COMPACTION_RECALL_PREINDEX_TOOL_ROUNDS
tracefalseContent-bearing recall diagnostics; requires the timing-file path and should stay private.File only
COMPACTION_RECALL_TIMING_FILEUnsetJSONL timing output path; unset means no timing log.Environment only

Retrieval, preindex and trace settings apply to full mode. Details: Configuration and behavior reference.

Scope and privacy

  • Searches only compacted history on the current branch, not other sessions or abandoned branches.
  • Indexes user/assistant text and assistant tool-call names and arguments. Thinking, images, tool-result bodies and compaction summaries are not indexed; readable tool results can still be expanded by ID.
  • Honors branch-local context edits: omitted entries stay unavailable, and replacement text hides the original.
  • Hints and tool results enter the model's context and may be sent to its provider. lite disables automatic hints, not the transmission of explicitly retrieved history.

An empty result does not prove a detail was never mentioned. Verify important facts against the expanded source. Diagnostic traces can contain conversation content and should not be published.

Benchmarks

Evaluation uses selected LongMemEval cases. The repository includes 16 Chinese question translations, source identifiers, processing notes, result metrics and reproduction scripts; original corpora and other full-text evaluation inputs are obtained separately.

Answering model: gpt-6-luna (high). Scores are correct answers / questions, split into DEV8 and HARD8 (eight questions each).

Historical best

ModeDEV8HARD8Combined peaks
Pi native2/80/82/16
lite2/80/82/16
full8/83/811/16

Random test run

A single run on the fixed English LongMemEval_M set. The native baseline has retained context only, without history-retrieval tools.

ModeDEV8HARD8Total
Pi native0/80/80/16
lite2/80/82/16
full7/83/810/16

These small development-set results are not full LongMemEval scores or a guarantee of recall accuracy.

See the benchmark guide for commands and required inputs.

Development

npm ci --ignore-scripts
npm run check
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover -s test -p 'test_*.py'

Tests use synthetic fixtures and isolated agent directories. Live benchmarks need external data and provider configuration and may incur model API costs.

License

MIT. Third-party software and dataset attribution are listed in THIRD_PARTY_NOTICES.md.