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

@season179/pi-model-fallback

v26.7.0

Published

Automatic model failover for Pi, driven by a standalone fallback-models.json config.

Readme

@season179/pi-model-fallback

Automatic model failover for Pi. When the selected model fails with a persistent provider error (rate limit, overload, 5xx, network), Pi switches to the next model in a user-defined fallback chain and resumes work automatically.

Main model settings (settings.json) are configured nowhere in this extension — the fallback chain lives in its own config file.

What It Does

  • Triggers only after Pi's built-in same-model retries are exhausted.
  • Classifies errors by HTTP status first, error-message patterns as backstop.
  • Falls back on rate limit (429), overload (529), 5xx, and network errors.
  • Never falls back on user aborts, context-overflow, or 4xx request errors (those fail identically on every model).
  • Auth errors (401/403) do not trigger fallback unless explicitly enabled.
  • Resumes the interrupted run automatically via a "continue" message.
  • Restores your original model on the next interactive message after a cooldown (default 10 minutes), so an ongoing outage doesn't cause churn.
  • A manual model switch (/model, Ctrl+P) cancels the pending restore — your choice wins.
  • Persists fallback state in the session: resuming a session left on a fallback model restores the original immediately.

Installation

pi install npm:@season179/pi-model-fallback

Configuration

Create ~/.pi/agent/fallback-models.json (global) or .pi/fallback-models.json (project-local, wins if present). It contains only the fallback chain:

{
  "fallbacks": [
    { "provider": "openai-codex", "model": "gpt-5.6-sol" },
    { "provider": "google", "model": "gemini-3-pro" }
  ],
  "restoreCooldownMinutes": 10,
  "fallbackOnAuthErrors": false
}
  • fallbacks — ordered chain; entries without a configured API key are skipped.
  • restoreCooldownMinutes — how long after the last failure before the original model is restored on your next message (default 10).
  • fallbackOnAuthErrors — set true to also fall back on 401/403. Off by default because it can silently shift spend to a metered key and mask an expired credential.

The config is re-read on every trigger, so edits apply without reloading Pi.

Usage

  • /fallback — show the chain, current model, and whether a fallback is active.
  • /fallback restore — force-switch back to the original model before the cooldown expires.

Known Pi-Core Limitation

Pi persists every model switch (including this extension's) as the new global default in ~/.pi/agent/settings.json; there is no session-only setModel in the extension API. The restore path writes the original defaults back, and resumed sessions repair them at startup. But while a fallback is active — or after a crash mid-fallback, until that session is resumed — new Pi sessions elsewhere will start on the fallback model.