npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@adeildo/pi-compact

v5.12.0

Published

Keeps a long pi session's context small: hides old tool output, keeping each call so the agent can run it again, and writes pi's compaction summary from the session's tasks.

Readme

What it does

When a run ends past 150k tokens of context, tool output older than the last 10 turns becomes one line that names its call:

Output hidden to save context, about 4.2k tokens. It came from: read src/view.ts. Run it again if you need it.

Long arguments leave whole, like a script sent to bash or a file sent to write, and a note on the call says which went. A value cut short would teach the model to cut its own: in a live session, after a prune that cut values that way, the agent wrote new calls cut the same way, and they ran. A call that copies the note, or a value cut the old way, does not run. Your messages, the agent's own words, errors and the last 10 turns stay whole. After a prune the agent gets the session's tasks at the end of its context, so it keeps its goals.

The prune runs when a run ends, so the cache rewrite it costs lands on your next message. When you were away longer than the cache lives, that message writes the whole prompt anyway. A turn in the middle of a run prunes only when the context passes 80% of the model's window, before pi's own compaction.

Anthropic can clear old output on its side instead, with clear_tool_uses, and it is off by default. It keeps the agent's thinking, which an edit drops for every later turn, because Anthropic signs each thinking block with the conversation before it. But in a session of 744 requests on Opus 5.5, each of its 15 clears made the next request write the whole prompt again, 450k to 600k tokens, to free 5% to 30% of it, since the thinking stays. Each clear cost about $2 and saved a few cents a request.

Each prune or clear leaves a line in the chat, with what rewriting the prompt cache costs and when that pays back. Ctrl+O lists the calls it hid.

When pi compacts anyway, pi's own prompt writes the summary on a small model, and the tasks and your last words go on top as they are, so no model rephrases a decision. Without tasks, pi writes the summary on the session's model.

On six recorded sessions, an agent that only had the summary answered 48 questions about what was dropped. A judge graded the answers against the truth. pi's summary on Haiku scored as well as on Opus, within the judge's noise, for 1/40 of the price. A first version that wrote its own short summary from the tasks scored 2.6 of 5 against pi's 3.9, and was dropped. The method is Factory's probes, and bun packages/compact/eval/summary.ts runs it.

Why this way

  • Hiding old tool output works as well as summarizing it and costs less. Summaries made agents run 13 to 15% longer (JetBrains, NeurIPS 2025).
  • A model that picks what to keep cost 94% more with no gain in quality (OpenHands, 2026). The rules here are plain code.
  • After a prune, the next request writes the whole conversation to the prompt cache again. Anthropic reuses cache only where an earlier request wrote it (Anthropic), and the writes near old outputs have expired. So a prune waits until it frees at least two fifths of the context at once. Pruning a little every turn would cost 3.4 times as much.
  • Errors stay and every placeholder keeps its call, after Manus.

Replaying a week of real sessions, mostly Opus with a 1M context, costs 32% less with the prune. The replay has each prune's next request write all of the context again, so the real saving is at least that. bun packages/compact/eval/replay.ts [--server 10] replays yours.

With pi's compaction

The package turns off nothing of pi's. A turn past 80% of the window prunes right before pi checks its own compaction threshold, so pi rarely needs to compact. /compact and auto-compaction still work; this package only writes their summary. The prune is a context_edit, so the session file keeps every output, and /tree to an earlier point shows them again. Anthropic's clearing edits nothing in the session.

Commands and settings

/prune hides old output when the run ends, whatever the context's size.

On the Compact tab of Alt+S, stored under compact in ~/.pi/agent/extensions/pi-harness/settings.json:

| Setting | Default | Does | | ----------------------- | -------- | ------------------------------------------------------------------------------------------------------ | | Hide old tool output | on | The prune | | On Anthropic's side | off | On Anthropic models, Anthropic clears instead of the prune, and the agent keeps its thinking | | Above | 150000 | Context tokens past which a run's end prunes | | Write it from the tasks | on | The tasks on top of pi's summary, written on the model below. Off, pi writes it on the session's model | | Model | auto | Writes the summary. auto is the cheapest of the session's provider |

The tab also shows what this session's prunes freed and how many hidden outputs the agent ran again. A high share means the prune hides what the agent still needs.

Part of pi-harness, which brings every piece in one install.