@vtstech/pi-long-term-memory

Long-term memory extension for Pi - persistent memory across sessions

Packages

Package details

extension

Install @vtstech/pi-long-term-memory from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@vtstech/pi-long-term-memory
Package
@vtstech/pi-long-term-memory
Version
1.3.5
Published
May 24, 2026
Downloads
791/mo · 310/wk
Author
vtstech
License
MIT
Types
extension
Size
221.7 KB
Dependencies
1 dependency · 1 peer
Pi manifest JSON
{
  "extensions": [
    "./long-term-memory.js"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

@vtstech/pi-long-term-memory

Long-term memory extension for the Pi Coding Agent.

Persistent memory across sessions with automatic injection, AI-driven memory creation, and a ~4k token window.

Install

pi install "npm:@vtstech/pi-long-term-memory"

Features

  • Persistent Storage: Memories survive across sessions and restarts
  • Auto-Injection: Memory automatically injected at session start
  • AI-Driven Creation: AI can request memories via create_memory tool
  • Memory Gate: Confirm before creating memories (enabled by default)
  • Tag Organization: Organize memories with tags
  • Token Management: ~4k token window with auto-summarization

Commands

/memory add <text>     - Add memory (with optional tags)
/memory delete <id|content> - Delete memory by ID or content
/memory replace <id> <new-content> [comma-separated-tags] - Replace memory content by ID
/memory list           - List all memories
/memory clear          - Clear memories (preserves metadata)
/memory clear-meta     - Reset metadata
/memory meta           - Show metadata
/memory backups        - List available memory backups
/memory stats          - Show comprehensive memory statistics
/memory-gate           - Toggle memory creation gate
/memory --help         - Show help

Memory Management

Delete Operations:

  • /memory delete <id> - Delete specific memory by ID
  • /memory delete <content> - Delete any memory containing the specified text

Replace Operations:

  • /memory replace <id> <new-content> - Replace memory content by ID
  • /memory replace <id> <new-content> tag1,tag2 - Replace content and update tags

Memory Statistics

The /memory stats command provides detailed metrics:

  • Total memories count
  • Total content characters
  • Estimated tokens (rough calculation)
  • Average tokens per memory
  • Formatted context tokens
  • Memory gate status
  • Last compaction timestamp

Enhanced Features

  • User-Prompted Metadata: Primary User, Environment, and Framework fields are now prompted on first run
  • Backup System: Automatic backup of pre-compacted memories to memory-backups directory
  • Enhanced Error Handling: Comprehensive debugging and error handling throughout memory operations
  • Memory Injection Hooks: Proper timing ensures memory is loaded and displayed before AI responses

AI-Driven Memory

The AI can request memory creation via the create_memory tool:

{
  "action": "create_memory",
  "content": "Decided on PostgreSQL for session storage",
  "tags": "decision, architecture",
  "reason": "Better consistency guarantees needed"
}

With the memory gate enabled (default), you'll be prompted to confirm before creation.

Memory Injection

Memory is automatically injected at session start, BEFORE the AI generates its first response. The extension hooks into:

  • pre_session_start - Ensures metadata is complete
  • session_start - Displays memory context to user
  • before_provider_request - Prepends memory to the API request

Token Management

Memory operates within a ~4k token window with automatic summarization:

  • Memories are sorted by importance and last accessed
  • When approaching token limits, older/less important memories are compacted
  • System preserves all memories across sessions

Metadata

User-prompted on first run:

  • Primary User: Prompted for user name
  • Environment: Prompted for environment (e.g., development, production, G! Colab)
  • Framework: Prompted for framework name (defaults to "Pi Coding Agent")

The system ensures metadata is complete before memory injection.

Storage

Memory file: .pi/agent/long-term-memory.json

Links

License

MIT — VTSTech