pi-observational-memory  by elpapi42

AI agent memory extension for persistent context

Created 2 months ago
294 stars

Top 89.7% on SourcePulse

GitHubView on GitHub
Project Summary

This Pi extension addresses the critical issue of context loss in long AI coding sessions. By proactively capturing and distilling session memory into "Observations" and "Reflections," it ensures that crucial details and decision rationales are retained across Pi's session compactions. This provides engineers using Pi for complex, multi-day tasks with a more coherent and continuous agent experience, significantly reducing the impact of context window limitations and improving workflow continuity.

How It Works

The extension operates by continuously capturing concrete session events as "Observations" and distilling durable facts from them into "Reflections" in the background. This proactive memory work occurs before Pi's native compaction process is triggered. Consequently, when compaction is needed, the memory is already prepared, transforming the process from a slow, model-intensive summarization into a rapid rendering step. This approach minimizes context loss and avoids interrupting the user's flow, allowing the agent to maintain a grounded understanding of the work over extended periods. The recall agent tool further enhances traceability by allowing specific observations or reflections to be linked back to their source evidence.

Quick Start & Requirements

  • Installation:
    • Stable: pi install npm:pi-observational-memory
    • Development: pi install git:github.com/elpapi42/pi-observational-memory or from a local checkout.
  • Prerequisites: Pi environment.
  • Configuration: Settings are managed under the observational-memory namespace in ~/.pi/agent/settings.json or project-local .pi/settings.json. Key tunable parameters include observeAfterTokens, reflectAfterTokens, compactAfterTokens, and compactAfterTokensMode (options: calibrated, ratio). Defaults are provided.
  • Documentation: Links to docs/configuration.md, docs/concepts.md, and docs/how-it-works.md are implied within the repository structure.

Highlighted Details

  • V3 Memory Model: The latest version introduces a significant update, requiring users to migrate settings and start new Pi sessions, as V2 memory and configurations are incompatible.
  • Proactive Memory Capture: Utilizes "Observations" (concrete events) and "Reflections" (distilled facts) to preserve context.
  • Fast Compaction: Memory preparation occurs in the background, making Pi's compaction process significantly faster and less disruptive.
  • Recall Agent Tool: Enables tracing specific memory items back to their source evidence via unique IDs.
  • Adaptive Compaction: Supports compactAfterTokensMode set to ratio to scale compaction thresholds dynamically with the active model's context window size.

Maintenance & Community

No specific details regarding maintainers, community channels (e.g., Discord, Slack), or project roadmap were found in the provided README.

Licensing & Compatibility

  • License: MIT.
  • Compatibility: The MIT license is permissive, generally allowing for commercial use and integration within closed-source projects.

Limitations & Caveats

The V3 update is not backward compatible with V2 settings or memory formats; users must update their configurations and initiate clean Pi sessions. Rolling back from V3 to V2 will result in a loss of memory continuity.

Health Check
Last Commit

5 days ago

Responsiveness

Inactive

Pull Requests (30d)
2
Issues (30d)
1
Star History
109 stars in the last 30 days

Explore Similar Projects

Feedback? Help us improve.