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

pi-compaction-model

v0.1.0

Published

Choose a dedicated model for Pi's native compaction without changing its compaction algorithm or prompts.

Downloads

968

Readme

pi-compaction-model

A minimal extension for Pi Coding Agent that lets native compaction use a dedicated model and thinking level.

It does not introduce a new summarization pipeline. It calls Pi's exported compact() implementation with the configured model, preserving Pi's native:

  • prompts and structured summary format
  • cut-point and recent-message retention behavior
  • iterative previous-summary updates
  • split-turn summaries
  • file-operation tracking
  • output-token budgeting
  • /compact focus instructions

If the configured model is unavailable or fails, the extension returns control to Pi, which compacts with the active conversation model.

Install

From npm:

pi install npm:pi-compaction-model

Or directly from GitHub:

pi install git:github.com/JMHSV/pi-compaction-model

You can also clone it and add local/pi-compaction-model to ~/.pi/agent/settings.json.

Restart Pi after installation, or use /reload.

Configure

Add compactionModel to ~/.pi/agent/settings.json:

{
  "compactionModel": {
    "model": "openai-codex/gpt-5.6-terra",
    "thinkingLevel": "medium"
  }
}

model must be a model known to Pi in provider/model form.

Supported thinking levels are:

off, minimal, low, medium, high, xhigh, max

Omit thinkingLevel to use the provider default.

Select which compactions to route

By default the configured model handles all native compaction reasons:

  • manual/compact
  • threshold — automatic context-threshold compaction
  • overflow — overflow recovery before retry

Use reasons to handle only a subset:

{
  "compactionModel": {
    "model": "google/gemini-2.5-flash",
    "thinkingLevel": "low",
    "reasons": ["threshold", "overflow"]
  }
}

An empty reasons array disables routing without removing the configuration. You can also use "enabled": false, or set "compactionModel": false in trusted project settings.

Project overrides

A trusted project's .pi/settings.json can override individual global fields:

{
  "compactionModel": {
    "model": "anthropic/claude-sonnet-4-5"
  }
}

Project fields are shallow-merged over the global compactionModel object. Untrusted project settings are ignored.

Coexisting with other compaction extensions

Multiple extensions can handle session_before_compact, and the last extension that returns a compaction result wins. Avoid configuring two extensions for the same reason.

For example, to use Smart Compact manually and this extension only for automatic native compaction:

{
  "smartCompact": {
    "autoTrigger": false
  },
  "compactionModel": {
    "model": "openai-codex/gpt-5.6-terra",
    "thinkingLevel": "medium",
    "reasons": ["threshold", "overflow"]
  }
}

The resulting routing is:

| Event | Handler | |---|---| | /smart-compact | Smart Compact | | /compact | Pi native compaction with the active model | | Automatic threshold | Pi native compaction algorithm with the configured model | | Overflow recovery | Pi native compaction algorithm with the configured model | | Configured-model failure | Pi native fallback with the active model |

Failure behavior

The extension logs a warning and falls back to Pi's active model when:

  • the configuration is invalid
  • the model cannot be found
  • authentication cannot be resolved
  • the compaction request fails or is cancelled

Pi currently resolves authentication for the active conversation model before firing the compaction extension hook. Consequently, the active model must also have valid authentication even when a dedicated compaction model is configured.

Development

bun install
bun run check

License

MIT