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

opencode-session-fallback

v0.1.4

Published

OpenCode plugin: quota/auth exhausted fallback that resumes the same session with a fallback lane

Readme

opencode-session-fallback

OpenCode plugin that catches quota/auth-pool exhaustion on a running session and resumes the same sessionID on a configured fallback lane.

What It Does

  • Listens to session.error events from OpenCode
  • Detects quota/auth-pool exhaustion signatures such as:
    • auth_unavailable + no auth available
    • insufficient_quota
    • quota exceeded
  • Resolves the current agent from session history
  • Reads agent markdown frontmatter to find:
    • fallback_agent on the source agent
    • model on the fallback agent
  • Aborts the failed turn and injects a continuation prompt into the same session with the fallback model and fallback system prompt

The plugin does not require patching OpenCode core. It relies on the existing plugin event surface and the session prompt API.

Agent Contract

The source agent should declare a fallback target:

---
fallback_agent: metis
---

The fallback agent should declare the model it runs on:

---
model: cliproxy_gpt/gpt-5.4
---

The fallback prompt body is appended to a short continuation system block so the new lane keeps working from the same session state instead of restarting.

Installation

{
  "plugin": [
    "[email protected]"
  ]
}

In opencode-heartbeat, the recommended entrypoint is role-level heartbeat.json -> opencode.extraPlugins.

For the bundled cliproxy_fault/* drill provider used by end-to-end validation, the plugin also treats the Anthropic SDK connectivity wrapper error as an eligible fallback signal. This branch is test-only and scoped to the cliproxy_fault/ provider prefix.

Environment

| Variable | Default | Description | |----------|---------|-------------| | OPENCODE_SESSION_FALLBACK_ATTEMPT_LIMIT | 1 | Max automatic retries per session | | OPENCODE_SESSION_FALLBACK_DEBUG | false | Enable file-based debug logging | | OPENCODE_SESSION_FALLBACK_DEBUG_LOG | log/opencode-session-fallback.debug.log | Debug log path |

Behavior Notes

  • Recovery is session-local. The plugin retries on the same sessionID.
  • The default retry budget is one automatic continuation per session.
  • The plugin listens to both session.error and session.status(type=retry) so provider-auth pool exhaustion can be intercepted before OpenCode collapses the turn into a generic terminal abort.
  • Recovery currently uses model + system override and does not depend on OpenCode core accepting agent: metis from every caller.
  • If the plugin cannot resolve the fallback target from agent markdown, it leaves the original error untouched.