How Compaction Works in Pi
Pi compacts long coding-agent sessions by retaining roughly 20,000 recent tokens, truncating older tool results, and asking a separate clean context for a structured summary. The summary is appended as a session entry, preserving room for more work while retaining the recent turns unchanged.
The design also breaks the prompt-cache prefix: even unchanged recent turns now follow a new summary, so their prior cache cannot be reused. HN discussion pushed toward selective pruning, branch/handoff workflows, and keeping durable task state in Markdown instead of trusting lossy summaries.