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

@reasoning-router/pi

v0.2.0

Published

Adaptive per-step reasoning effort for the Pi coding agent

Downloads

1,295

Readme

@reasoning-router/pi

English | 简体中文 | 日本語 | 한국어

A Pi extension that asks a classifier how much reasoning each Claude request needs and lets Pi place that effort without breaking the prompt cache. Requires Pi 1.0.0 or later and Node.js 24.x.

export REASONING_ROUTER_CLASSIFIER_API_KEY=your-jev-key
pi install npm:@reasoning-router/pi
pi --model reasoning-router/claude-opus-5-5

The * peer range on @earendil-works/pi-coding-agent does not enforce Pi 1.0.0. An older Pi fails to load the extension because it has no registerVirtualModel.

The extension adds a virtual model reasoning-router/<id> for each Claude model the router knows. Each request runs on the matching anthropic/<id> model with your existing Anthropic login or key; the router only picks its thinking level. For these mid-conversation-effort models Pi pins output_config.effort: "high" and states the chosen effort in an effort-only system message, so changing effort keeps the cached prefix.

  • User turns and continuations are classified. A retry reuses the failed attempt's thinking level. Direct requests, such as compaction, use REASONING_ROUTER_BASE_EFFORT, or the model's base effort; the variable affects only those requests, not the pinned high above.
  • The last classified effort is stored in the session, per virtual model, so previous fallback survives a restart.
  • A model that Pi lacks, or that Pi cannot give mid-conversation effort, is rejected with reasoning-router unsupported_model: .... In Pi 1.0.0 and 1.0.4 that includes claude-mythos-5-1.
  • A classification failure in error fallback mode rejects the request with reasoning-router classification_failed: .... Cancelling a request never falls back. The messages carry no HTTP status codes, because Pi retries errors that look like transient provider failures.
  • The classifier endpoint receives the most recent user text, the most recent assistant text, and the names and output excerpts of recent tool results. System messages, thinking blocks, and tool-call arguments are not sent.

GPT-6 models (gpt-6-astra, gpt-6-sol, gpt-6-luna, gpt-6.1-sol) are routed the same way, to openai/<id>, on a Pi release that includes pi#10930. Pi then pins reasoning.effort and sends the chosen effort as configuration_update items. Older Pi rejects them with unsupported_model. They need an OpenAI API key: Sign in with ChatGPT is rejected with unsupported_model, because Pi then changes the request's effort and misses the cache. A none decision on gpt-6-luna or gpt-6-sol is also sent as request-level effort and misses the cache. openai-codex models are not routed.

Environment

The extension reads the proxy's variables on the first routed request, not when Pi loads it. The virtual models are always listed. A missing classifier key, a legacy variable such as TYPESAFE_API_KEY, or another invalid value fails that request with reasoning-router invalid_config: ...; Pi keeps running, and the next request reads the variables again until they are valid.

| Variable | Default | Purpose | | --- | --- | --- | | REASONING_ROUTER_CLASSIFIER | jev | Classifier provider name, such as jev (see classifiers). | | REASONING_ROUTER_CLASSIFIER_API_KEY | none | Classifier credential, if the provider needs one. | | REASONING_ROUTER_CLASSIFIER_BASE_URL | provider default | Classifier endpoint; defaults to the provider's. | | REASONING_ROUTER_CLASSIFIER_ACCOUNT_ID | none | Account ID, for providers that take one. | | REASONING_ROUTER_CLASSIFIER_MODEL | none | Classifier model, for providers that take one. | | REASONING_ROUTER_CLASSIFICATION_TIMEOUT_MS | 4000 | Total classification budget, including retries. | | REASONING_ROUTER_MAX_RETRIES | 1 | Classifier retries after a retryable error (0–10). | | REASONING_ROUTER_FALLBACK_MODE | fixed | On failure: fixed, previous (last classified effort, else fixed), or error. | | REASONING_ROUTER_FALLBACK_EFFORT | high | Effort for fixed fallback. | | REASONING_ROUTER_BASE_EFFORT | model default | Effort for direct requests. | | REASONING_ROUTER_DECISIONS_LOG_PATH | none | Absolute path for a JSONL log of decisions. |

See docs/environment.md for the classifier credentials. The decision log holds metadata only: model, effort, classifier latency and attempts, fallback, token usage including cache reads, and outcome, with no prompt text or credentials.

License

MIT