pi-compact-jev

September 20, 2026 · View on GitHub

Uses Jev to compact Pi Coding Agent conversations by removing or shortening tool output and preserving retained text verbatim. Automatic compaction is enabled by default; if Jev pruning cannot be used, Pi falls back to its built-in summarizer.

Install

Choose one installation source.

pi install npm:pi-compact-jev
pi install git:github.com/dev-willbird1936/pi-compact-jev

Restart Pi, or run /reload in an existing session.

What it does

When Pi would summarize a dropped prefix, this extension scores unpinned tool calls with Jev:

  • not useful → delete the call
  • useful and needed in full → keep the output word for word
  • useful but not full → keep the first and last 25% of the output, each capped at 2,500 characters

Unresolved errors, git commits, edits, writes, images, and invoked skills skip Jev and stay. Auto-compact can call Pi compact() after a settled turn. At 512,000 tokens it compacts without waiting for Jev.

Scoring sends selected conversation, tool output, and workspace context to TypeSafe or OpenRouter. It does not share Pi’s live session cache.

Exact prune path: HOW.md.

Commands

CommandEffect
/jev-compactCompact now
/jev-compact on / offEnable or disable the package
/jev-compact-configSettings menu

Status bar: compact:auto, compact:jev, compact:off, or compact:no key.

Requirements

  • Node.js >=22.19.0
  • Pi Coding Agent >=0.84.0
  • Pi compaction enabled (settings.json"compaction": { "enabled": true })
  • A Jev key (TypeSafe first, else OpenRouter)

Keys, in order:

  • TypeSafe: TYPESAFE_API_KEY or JEV_API_KEY, then ~/.brain/secrets/typesafe-api-key.txt or ~/.brain/secrets/jev-api-key.txt
  • OpenRouter: OPENROUTER_API_KEY, then ~/.brain/secrets/openrouter-api-key.txt

provider: auto uses a TypeSafe/Jev key when present, otherwise OpenRouter.

Configuration

~/.pi/agent/pi-jev-compact.json is created on first load. /jev-compact on|off writes enabled. /jev-compact-config edits the rest.

FieldDefaultRole
enabledtrueHook no-ops when false
providerautotypesafe, openrouter, or auto
autoCompacttrueAfter a settled turn, Jev may call Pi compact()
minContextTokens64000Auto-compact will not judge below this
forceCompactTokens512000Compact without Jev at this size
keepThreshold0.5Minimum useful score to keep
preserveRecentTurns5Last N user and N assistant windows
windowChars2000Stored head/tail per windowed prompt/reply
maxStateTokens28000Fitted Jev state ceiling
maxRequestTokens64000State plus one batch of questions
truncateHeadChars2500Max chars at each end of a stubbed dump
minReduction0.25Else fall back to Pi’s summarizer
timeoutMs30000Per Jev request
debugfalseLog stats to stderr

Development

bun test
bun run typecheck

By dev-willbird1936.