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

@cad0p/pi-fallback-provider

v0.1.0

Published

Automatic model cycling when the pi agent gets stuck on errors

Readme

pi-fallback-provider

Automatic model cycling when the pi agent gets stuck on errors.

The problem

When an LLM provider fails (rate limit, context overflow, content policy, etc.), pi's built-in retry handles transient errors (429, 5xx). But when retries are exhausted — or the error isn't retryable — the agent just stops. You have to manually switch models and continue from the current context.

How this extension helps

Instead of classifying errors or intercepting at the transport layer, this extension uses progress detection:

agent_end fires with stopReason === "error"
  → start 20s timer
  → if turn_start fires → cancel timer (pi is making progress)
  → if timer expires → cycle to next model, send "continue"
  • No error classification — works for any error type
  • Respects pi's retries — 20s timeout gives pi's built-in retry (3 retries × exponential backoff ≈ 14s) a chance to finish
  • Sends continue after switching — resumes from the current agent context instead of replaying a stale user request
  • Resets on each failure — each agent_end with error resets the timer, so it waits for the last failure's quiet period
  • Skips user aborts — only triggers on stopReason === "error", not "aborted" (ESC)
  • Smart ordering — prefers the last working model (cached 1h), skips recently failed models (5min cooldown)

Install

pi install git:github.com/cad0p/pi-fallback-provider

Or copy index.ts to ~/.pi/agent/extensions/.

Configuration

No configuration needed — it cycles through all models you have authenticated in pi.

Set PI_FALLBACK_DEBUG=true for verbose logging:

PI_FALLBACK_DEBUG=true pi

Manual trigger

Use /cycle-model to manually cycle to the next available model and send continue.

How it decides which model to try next

  1. Cached model — if you recently had a working model, try it first (1h TTL)
  2. Round-robin — cycles through remaining authenticated models
  3. Failed models last — models that recently failed are tried as a last resort (5min cooldown)

Differences from existing extensions

| Extension | Approach | Auto on error? | Cycles models? | |---|---|---|---| | pi-fallback-provider (xilnick) | Transport-level stream interception | Only retryable | Within chain | | pi-retry | agent_end hook, same-model retry | Only aborted | ❌ Same model | | pi-model-switch | LLM tool for manual switching | ❌ | ✅ Manual | | pi-cycle | F8 hotkey, profile cycling | ❌ | ✅ Manual | | This extension | agent_end + progress timer | ✅ Any error | ✅ Automatic |

License

MIT