@8monkey/pi-context-history
Manages long conversation context, automatically trims history while preserving summaries.
Install & Use
Copy this prompt and send it to your AI assistant (Claude / Cursor / TRAE / Codex / WorkBuddy etc.) to auto-install:
Help me install this AI Skill: @8monkey/pi-context-history. It is used for: Manages long conversation context, automatically trims history while preserving summaries. Full Skill content: https://321skill.com/skills/8monkey-pi-context-history/raw/index.md Read that page and install it.
The prompt includes a link to the full Skill content. You can also view the full content.
This Skill addresses the issue of context window inflation in AI coding agents during long conversations. In real-world development, as a session progresses, old messages and tool call results accumulate, forcing the model to process large amounts of irrelevant information. This wastes tokens and degrades response quality. This extension automatically prunes outdated history, strips unnecessary tool calls, and injects a rolling summary into the system prompt, ensuring the model stays focused on the current task.
Usage is straightforward: simply install via Pi's package manager: pi install npm:@8monkey/pi-context-history. All features are enabled by default after installation, requiring no extra configuration. You can control each feature independently via environment variables: set PI_TRIM_HISTORY=false to disable history trimming, and PI_STRIP_TOOL_HISTORY=false to retain tool call records. It also provides commands like /compact-session, /add-user-message, and /add-assistant-message for manually triggering summary generation or appending messages.
It is ideal for developers or teams running long AI coding sessions, particularly those using Pi as a coding agent for complex refactoring, large-scale project development, or scenarios requiring continuous conversation. For contexts involving frequent switching or reviewing earlier discussions, this extension significantly reduces the manual effort of cleaning history, allowing the model to reason based on the latest, most relevant information.
We recommend installing this extension before starting a long-term project or complex debugging session. Note that it is primarily designed for the Pi coding agent environment and is not compatible with other AI platforms. The summary feature regenerates by default after a session becomes stale for 3 days; you can adjust this threshold via PI_COMPACT_STALENESS_DAYS. To customize the summary generation prompt, override the built-in template at ~/.pi/prompts/compact.md.
Key Features
Unlike Pi's built-in simple truncation, it allows independent toggling of each feature (history trimming, tool call stripping, rolling summary) and preserves early context by injecting summaries into the system prompt instead of discarding it outright.
Limitations
Only compatible with the Pi coding agent environment, requires a Node.js or Bun runtime, and depends on Pi's extension mechanism.
FAQ
How do I disable a specific feature?
Set the corresponding environment variable to false. For example, use `PI_TRIM_HISTORY=false` to disable history trimming.
How can I customize the prompt for summary generation?
Override the default template by creating a prompt file at `~/.pi/prompts/compact.md` or `.pi/prompts/compact.md` within your project, containing the `{conversation_history}` placeholder.
Installation guide for AI assistants
If your AI coding assistant (Claude Code, Cursor, TRAE etc.) can see this page, send it this message to auto-install:
Visit https://321skill.com/skills/8monkey-pi-context-history/raw/index.md to read the original Skill definition (Markdown format) for @8monkey/pi-context-history, and install it according to the instructions.
Raw Markdown URL for AI: /skills/8monkey-pi-context-history/raw/index.md