Skip to content

pi-jev-compaction

Automatic Pi context clearing: drops superseded tool outputs for free and asks Jev about large older ones, with originals retrievable.

ProjectbetaMIT

Overview

pi-jev-compaction is an automatic Pi extension that keeps the conversation and clears stale tool output, letting the agent retrieve originals without rerunning commands. Once the next request reaches 120k tokens or 45% of the context window, whichever is smaller, it evaluates concurrently with the next model call and protects the latest 12k tokens.

Outputs that a later output restates are cleared without any network call: a later full read of the same path, a later successful run of the same test command, repeated skill reads, later plans or identical diagnostics. For up to 16 remaining large outputs, it asks Jev in one request and clears those with an estimated probability of still being needed below 0.25. A batch is committed only if its one-time prompt-cache rewrite repays within 20 later requests. The status line shows state and cumulative tokens saved. It needs only Pi, works with models running inside Pi (not standalone Claude Code or Codex), and is MIT licensed.

What the decision model decides

TypeQuestionAnswers
Yes / noIs this older tool output still needed?yes · no

How it works

  1. Trigger at 120k tokens or 45% of the window.
  2. Clear restated outputs deterministically.
  3. Ask Jev about up to 16 large outputs; clear below 0.25.
  4. Commit only if cache rewrite repays within 20 requests.

Strengths

  • Many clearings need no API call.
  • Cache-aware commit rule.
  • Originals retrievable without rerunning.

Caveats

  • Requires a TypeSafe key.
  • Only for models running inside Pi.

Getting started

pi install git:github.com/nourhelmi/pi-jev-compaction, export TYPESAFE_API_KEY, then run pi.

At a glance

Type
Project
Status
beta
Language
TypeScript
Runtime
Pi extension
Has code
yes
License
MIT

Use cases and integrations

How curated lists describe it

  • Automatic Jev context clearing for Pi. Keep the conversation, prune stale tool output, retrieve originals without rerunning commands.

    logicrw/awesome-jev-projects
  • Automatic Jev context clearing for Pi. Keep the conversation, prune stale tool output, retrieve originals without rerunning commands.

    hellogumbo/awesome-jev

Frequently asked questions

When does it start clearing?

At 120k tokens or 45% of the model's context window, whichever is smaller.

Can cleared output be recovered?

Yes, the agent can retrieve originals without rerunning commands.

Does every clearing call Jev?

No, superseded outputs are cleared deterministically.

Related projects

  • Oh My Pi extension that truncates tool calls and results Jev scores as no longer needed, while keeping all user and assistant text verbatim.

    PluginbetaTypeScript
  • Pi port of fast-jev-compaction using Pi's context hook, with a savings gate against low-value pruning and retained status notes.

    PluginbetaTypeScript
  • winnow★ 110

    Calibrated context sieve for Claude Code: Jev judges each block of large tool output and hides confident-no blocks behind recallable stubs.

    Projectbeta
  • Codex hook that compacts large command and tool outputs, using Jev to rank which chunks matter and keeping the full output retrievable.

    ServicebetaPython
  • Local proxy for Claude Code that uses Jev to remove stale tool results from the context once it reaches about 120K tokens, failing open.

    ProjectbetaJavaScript
  • Claude Code /fc command where Jev picks which old tool outputs to keep whole; the rest are trimmed and saved to files.

    ProjectbetaTypeScript