pi-session-memory2.0.14
Find Pi conversation history with SQLite-backed search instead of relying on lossy summaries. Use multi-agent discussion for deeper analysis and save reusable, evidence-based knowledge.
Untested on omp
This is a pi package. No one has reported whether it works on omp yet. If you try it, add your result below.
Reports 0
No reports yet.
Readme
pi-session-memory
Recover compacted session details, search Pi history with SQLite, compare historical perspectives, save cited knowledge, and build ontologies from supplied context.
Project website · npm · CHANGELOG.md
The download-history workflow updates this chart daily. You can also run it manually from GitHub Actions.
Core features
- Recover remembered details. Search and read compacted messages on the active Pi session branch, including stored tool arguments and results.
- Find past decisions. Search indexed user and assistant text across Pi sessions using case-insensitive literal keyword and phrase matching.
- Compare historical perspectives. Consult selected historical Pi agents through optional multi-agent Discussion, then ask private follow-up questions.
- Keep reusable knowledge. Ask the main Pi agent to write cited Open Knowledge Format (OKF) Markdown with native file tools. Validate the files and reuse them later.
- Build ontologies. Ask Pi to edit Turtle files from supplied context. Run syntax and optional SHACL validation, fix reported errors, and preview saved graphs.
Pi's native context compaction stays in place. Readback adds selected stored messages to model context when a remembered detail is missing.
Get started
Install the package:
pi install npm:pi-session-memoryStart or restart Pi. Open
/pi-session-memoryand select Agentic setup. The agent explains each option and asks one question at a time. Review the proposed settings and approve the final save.After setup, approve the separate history import when prompted. You can also select Import history from
/pi-session-memorylater. Full import can restore sessions that you manually deleted from the SQLite index.
To update the package, run pi update.
Choose the history retrieval route
Decompaction reads selected stored messages that Pi replaced with a summary in model context. SQLite history search retrieves indexed conversation turns for unfamiliar history or requests across sessions.
| Aspect | Current-session decompaction | SQLite history search |
|---|---|---|
| Use when | You remember a detail from the active session or its summary and need the omitted text. | You need unfamiliar historical information or evidence from other sessions. |
| Source | The active SessionManager branch, before the latest compaction boundary. |
The local SQLite turn index across Pi sessions. |
| Tools | search_compacted_history, then read_compacted_history. |
recall_memory; fetch_session expands indexed hits, and review_jev_filtered audits filtered evidence. |
| Workflow | Read small windows into ordinary tool results. | Compare returned evidence. Write and validate a document only when the user requests a save. |
Cross-session requests use SQLite even when you remember the discussion. Use SQLite for unfamiliar history, including information that might belong to the active session.
Recover a remembered current-session detail
In this session, we agreed on a retry limit before compaction. Search the compacted history and read that original discussion.
Pi searches with search_compacted_history, then reads a small window with read_compacted_history.
Search results identify the session, compaction, and message entry. Readback uses those IDs and continuation offsets for paging.
This route uses SessionManager directly, without a SQLite import or synchronization step.
Readback returns ordinary tool results; it does not start historical review or save minutes.
Readback covers the active compacted branch only. It applies current context edits: omitted messages stay omitted, and replacements return their effective text. It includes stored text, tool arguments, and tool results. Thinking, image data, context-hook content, and external observation files remain outside this view. The tools leave source entries intact and keep native compaction in place.
Use your history
For unfamiliar history or requests across sessions, ask Pi to look back through SQLite:
Look back at our OAuth renewal conversations. What did we decide, and which questions remain?
The request context contains frontmatter and paths for managed saved meetings.
Pi can read a relevant file through native read, using knowledge_root and relative_path.
The catalogue contains metadata only; Pi reads minutes and evidence before relying on their contents.
It refreshes for each main-model request without writing to the session JSONL or SQLite index.
Even an empty collection exposes its configured root without creating directories.
For historical evidence, recall_memory searches indexed conversation turns.
Use fetch_session to expand an exact hit with neighboring turns when its excerpt needs more context.
The turn index contains user and assistant text, rather than complete message entries or tool payloads.
Reviewing history alone writes no OKF file. A save requires an explicit request.
A request to read saved minutes can use native file tools without retrieving history.
Compare historical perspectives
Choose Discussion when prompted, or set recallMode to discussion:
Review our earlier OAuth renewal conversations with historical agents and compare their answers.
Pi opens a checklist of eligible sessions. Confirm the sessions that you want to consult.
Pi can ask private follow-up questions, then call finish_session_consultation.
That tool releases the participants and returns their answers and supporting evidence; it writes no files.
The main Pi agent compares the evidence and writes minutes only when you request them.
Each historical agent uses its reconstructed session context and supplied indexed evidence first.
For a specific evidence gap, it can use only search_compacted_history and read_compacted_history.
These tools read that agent's active compacted branch in an in-memory historical session copy.
File tools, cross-session search, and access to the main agent's session remain outside its permissions.
Source transcript files stay unchanged.
Pi compares each answer within its historical session and records explicit decision replacements. Claims about session order require cited timestamps or an explicit relationship between those sessions. A session that reports only a proposal can coexist with another session that records a final decision. Recorded decisions and evidence of production deployment remain separate.
Save or update knowledge
Choose the evidence source in your request:
- New current-context save. Pi uses native
write,edit, orbashwith the visible dialogue only. - Current-context append. Pi reads the original minutes and linked evidence, then appends the authorized revision without retrieving history.
- Historical append. Pi reads the original file, retrieves fresh historical evidence, and compares it with the prior record. Discussion completion returns evidence to the main agent; the main agent performs the file changes.
For a new current-context save:
Save the current context as OKF. Use only this conversation.
To append a revision from the current conversation:
Append the revised plan we just confirmed to the original rollout OKF. Use only this conversation, without retrieving historical conversations.
To append new historical evidence:
Append new historical evidence to the original OAuth renewal OKF. Review the newly available conversations and record the latest decision and its reasons.
For either append, Pi uses the catalogue path to read the exact target.
It preserves the selected location, existing identity, prior text, and evidence.
New evidence receives unused source IDs and filenames; existing citations stay unchanged.
Pi updates navigation links, runs validate_okf, and corrects reported errors within the authorized scope.
The chat answer stays independent from the file. Ask for the complete document if you want it returned.
You can also request a broader change:
Reorganize all existing OKF meeting folders by topic. Preserve every original source and update the navigation links. Validate the whole collection afterward.
The main agent uses native file operations for moves and edits. Validation reports problems; it does not repair or roll back files. Ask before broad or destructive changes unless the request already authorizes them.
OKF validation and discovery limits
The default root is ~/.pi/agent/pi-session-memory/knowledge; knowledgePath selects another absolute root.
Automatic discovery reads minutes.md recursively under its meetings/ directory.
The containing directory supplies meeting_id, which must remain unique across that collection.
Topic folder names and depth can change; paths in the next request reflect the moved files.
validate_okf accepts document, directory, or catalogue scope.
A document or directory path is relative to the configured root; use path: "" for the root directory.
Catalogue validation checks the whole root, excluding its top-level ontologies/ directory and hidden directories.
Directory checks require immediate-child navigation in index.md.
Meeting sources must link to sibling Markdown evidence files of a supported evidence type.
This validator checks structure and citations, not claim accuracy. Arbitrary external OKF roots and cross-directory meeting evidence links remain outside its current interface.
Choose how Pi reviews evidence
recallMode controls SQLite historical review, separately from current-session decompaction.
Set it during setup or through Edit configuration:
| Mode | Behavior |
|---|---|
choice (default) |
Ask you to choose Normal or Discussion after each search. |
normal |
Return transcript evidence for the main agent to compare. |
discussion |
Return private answers from confirmed historical sessions. |
Edit configuration saves each valid field immediately. The command menu also provides database session management, usage statistics, and indexed-tool-turn cleanup. See the setup reference for configuration details.
Build ontologies
An ontology models entities and their relationships as a graph. Ask Pi to build one from the context you supply:
Create
teams.ttlfrom the teams and projects described in this conversation. Use native file tools, preserve source identifiers, and validate the file. Apply my existingteams-shapes.ttlconstraints.
Pi uses native read, write, edit, and bash to inspect and edit the selected files.
Turtle represents Resource Description Framework (RDF) triples. No plugin draft revision or save dialog is required.
validate_ontology reads explicit data paths and optional Shapes Constraint Language (SHACL) Core file paths:
{
"files": [
{ "path": "teams.ttl", "shapes": "teams-shapes.ttl" },
{ "path": "other-graph.ttl", "shapes": null }
]
}
The tool returns per-file syntax errors or SHACL results without changing files.
Pi fixes reported problems with native file tools and validates again.
shapes: null checks syntax only. Zero targeted nodes means SHACL tested no data nodes.
Validation accepts relative paths from the process working directory or absolute paths. The current parser limits each data or SHACL file to 40,000 UTF-8 bytes and 1,500 lines, and accepts non-empty Turtle default graphs with absolute IRIs. SHACL Core validation runs locally without fetching imports. These are implementation limits, not general Turtle requirements. A valid graph does not establish SDK-specific schema compatibility, successful compilation, inference, or deployment.
Read-only ontology search and /preview-ontology use ontologyPath, or knowledgePath/ontologies.
They read .ttl files directly inside that configured directory; preview requires interactive Pi mode.
Place a file there if you want it in that library. File validation itself has no configured-root restriction.
Creation and destructive edits still require user authorization.
Data and model use
Current-session readback and SQLite search run locally. History import starts through your explicit approval or menu selection. Decompaction reads the active session branch directly; SQLite retrieval uses the local turn index. Retrieved evidence enters model context. Optional relevance filtering uses your configured model service. Discussion uses your Pi model and in-memory session copies. Consultation leaves the original historical transcript files unchanged. The OKF catalogue metadata is also sent to the main model and consumes context tokens. History and consultation tool results stay in request-local memory; native file tool inputs and results follow Pi's normal session persistence. Writing retrieved evidence with native tools can therefore put those bytes in session JSONL. Review cited evidence before treating findings as verified.
Tool migration
The current source replaces inspect_memory_knowledge, read_memory_knowledge, write_okf, and finish_memory_recall with native file operations and validate_okf.
finish_session_consultation now takes only consultation_id, releases participants, and returns evidence instead of saving minutes.
The stateful build_ontology, constraint-review, draft-preview, save, and discard tools are no longer registered.
validate_ontology now takes file paths instead of a draft revision.
Existing files stay in place. Reload or restart Pi to load the new tools and prompts; previously loaded extensions keep their old behavior until then.
Source architecture
The main path separates evidence collection, file editing, and validation:
Pi model request
└─ extensions/index.ts context hook
├─ presentation/MemoryContext: restore request-local history evidence
└─ knowledge/okf-context.ts: read current meeting frontmatter and paths
Main Pi agent, after a user request
├─ recall/ and consultation/: return evidence; close participants
├─ Pi native read/write/edit/bash: inspect, create, move, or edit files
└─ knowledge/okf-validation.ts or ontology/ontology-file-validation.ts
└─ return diagnostics → main agent corrects files → validate again
prompts/ defines Agent-facing specifications and workflow guidance.
src/ and extensions/ own schemas, registration, validation, and execution.
Some legacy publication and draft helpers remain in source; they are outside the registered authoring path.
The source map shows static dependencies, not proof of runtime execution.
For evaluation commands and report usage, see evaluation/e2e/README.md.