What Is pi-infinite-context?
pi-infinite-context is a Pi extension designed for long-running agent sessions. It lets the agent replace completed portions of its active context with concise summaries while retaining the original messages in a searchable archive.
A fold groups consecutive messages or existing folds beneath a summary. Pi’s chat history remains unchanged, and folds can contain earlier folds to organize a growing session hierarchically.
Context Management Tools
The extension provides four agent tools:
context_foldgroups consecutive messages or folds under a new summary.context_maplists top-level context items or the direct contents of a fold.context_searchfinds original messages and fold summaries with regular expressions.context_peekreads an original message or fold summary by ID, optionally within a line range.
Map and search results supply IDs that the agent can inspect next. This allows information to be retrieved from the archive without restoring all folded content to the active context.
Context Reminders
The extension reminds the agent to fold completed work when estimated context usage reaches 150,000 tokens or 75% of the model’s context window, whichever occurs first. Further reminders appear as usage rises, with a default interval of 15,000 tokens that becomes shorter when little room remains.
Each reminder records context measurements and thresholds in its details. The agent decides what to fold and writes the summaries; reminders do not alter context automatically.
Configuration and Limits
Optional settings can change the token and percentage thresholds. Missing or invalid settings fall back to the defaults, changes apply after restarting Pi, and the effective limits are recorded in the session whenever they change.
The extension blocks Pi’s built-in compaction, including the compact command. Because folding is agent-directed, the context can still overflow if the agent does not fold enough material.