# pi-blackhole

By Saurabh Kumar · TIL note, Sep 5, 2026 · Tags: pi-agent

Source: https://saurabh-kumar.com/til/1788609600/

Every coding agent (Claude Code, Codex, pi) compacts long sessions the same way: ask an LLM to prose-summarize, then summarize that summary, until load-bearing details erode (why a decision was made, which approaches got rejected). [pi-blackhole](https://github.com/k0valik/pi-blackhole) swaps that for deterministic compaction: a zero-token `compile()` that extracts structured sections (goal, files touched, commits, preferences, brief transcript). No LLM, no drift, no cost. The compile is only lossy in the window, not on disk: blackhole also ships a `recall` tool (BM25 + regex over the raw session JSONL and the memory ledger) that re-fetches any dropped turn on demand, so compile + recall together is lossless where an LLM summary-of-a-summary destroys the original. It also adds observational memory: background observer/reflector workers append durable facts to per-session ledgers that survive every compaction, and `/blackhole-export` walks every past-session JSONL under a git-root into a ranked context file. The clever part is what export trusts. A fact's rank is driven by cross-session *recurrence*, damped as `log(1 + distinctSessions)` with a burst penalty, not raw counts, so one chatty session can't inflate it. Recurrence-as-reinforcement is basically [Hebbian](https://saurabh-kumar.com/articles/2025/11/notes-on-understanding-hebbian-learning/): facts that keep firing across sessions get stronger. Dedup is a 3-pass funnel, exact then Levenshtein then Sørensen-Dice token-set, with a Levenshtein floor so keyword overlap alone can't merge two distinct facts. Bonus: the OM workers run on their own model and billing, so I point them at `openai-codex/gpt-5.6-luna` while the main thread stays on Claude.
