pi-compaction-recovery

Native-first overflow compaction recovery for Pi using transient payload reduction.

Packages

Package details

extension

Install pi-compaction-recovery from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:pi-compaction-recovery
Package
pi-compaction-recovery
Version
0.1.0
Published
Sep 22, 2026
Downloads
214/mo · 13/wk
Author
fcrescio
License
MIT
Types
extension
Size
13.1 KB
Dependencies
0 dependencies · 1 peer
Pi manifest JSON
{
  "extensions": [
    "./extensions"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-compaction-recovery

Native-first overflow compaction recovery for Pi.

When an overflow compaction fails because the summarizer reaches a generation or payload limit, this package retries Pi's native compaction with a transient reduction ladder:

  1. call the native compactor normally;
  2. if it fails, reduce tool-result payloads in the in-memory preparation;
  3. if that still fails, also remove assistant reasoning blocks;
  4. leave the persisted session history and user settings unchanged.

The extension only handles reason === "overflow". It is deliberately opt-in, does not replace Pi's normal compaction behavior, and fails through to Pi when the recovery attempts cannot succeed. It uses Pi's resolved provider streaming API, verified against Pi 0.84.4.

Install

pi install npm:pi-compaction-recovery

Enable or inspect it with pi config. To load a checkout directly:

pi -e ./extensions/index.ts

Development

npm install
npm run check
npm run release:check

The reduction functions are exported and tested independently from Pi. They copy the compaction preparation rather than mutating the original object.

Scope and limitations

  • This is a retry policy, not a guarantee that any summary can be recovered.
  • It does not hook session_compact_failed because that Pi event is observational; recovery must happen before Pi's compaction request.
  • It never rewrites JSONL entries, changes the configured context window, or silently installs dependencies.
  • Pi extensions execute with the host process's permissions. Review the source before installing third-party packages.

License

MIT