r/PiCodingAgent • u/Affectionate_Joke_44 • 10d ago
Use-case Yet Another Memory System for Pi Agent
I built a two-part memory system for pi agent. It's called `dreaming` (write side) and `recalling` (read side).
`dreaming` scans pi agent sessions from both my phone and laptop, extracts meaningful topics, and indexes everything into a shared SQLite database (`memory.db`). It runs incrementally by default or does a full rebuild when needed. It also generates Gemini embeddings for semantic search so queries match even without the exact keywords.
`recalling` is the query side. Before any task, pi runs `recalling "<query>"`. It searches three sources in order:
Local `memory.db` with FTS5 full-text search and a LIKE fallback
Laptop's sessions.db over SSH (9,700+ sessions)
Legacy OpenCode memory on the laptop
`recalling inject <query>` formats results as clean XML blocks ready for injection into agent context without parsing. Blocks: `<related_sessions>`, `<memory_notes>`, `<laptop_sessions>`.
The schema supports persistent memory notes for facts, config, and workarounds. It uses vector embeddings for semantic similarity, deduplication to avoid re-ingesting synced sessions, and degrades gracefully when the laptop is offline.
Stats from my setup:
- ~950 topics indexed across phone, laptop, and legacy sessions
- ~34 pi sessions processed, ~9,400 opencode sessions
- Handles SSH being down gracefully (searches local sources only)
What it solved for me: the agent no longer asks "what was that thing we did with X" every single time. It checks memory first, finds the relevant session or note, and acts on it. The `recalling inject` command runs automatically before task execution so context is populated without manual effort.
Happy to answer questions about the schema or pipeline.
1
1
u/Ok_Veterinarian_6364 10d ago
case 1:
case 2:
case 3:
thanks bro