@janvitos/pi-auto-model

Route the first Pi prompt to one of two or three configured models.

Packages

Package details

extension

Install @janvitos/pi-auto-model from npm and Pi will load the resources declared by the package manifest.

$ pi install npm:@janvitos/pi-auto-model
Package
@janvitos/pi-auto-model
Version
0.1.4
Published
Aug 29, 2026
Downloads
902/mo · 32/wk
Author
janvitos
License
MIT
Types
extension
Size
41.8 KB
Dependencies
0 dependencies · 3 peers
Pi manifest JSON
{
  "extensions": [
    "./index.ts"
  ]
}

Security note

Pi packages can execute code and influence agent behavior. Review the source before installing third-party packages.

README

pi-auto-model

A Pi extension that classifies the first prompt in a new session and routes it to one of two or three configured models before the main agent request starts.

Features

  • Two tiers (simple, complex) or three (simple, standard, complex)
  • A searchable, scrolling model picker for every tier
  • A model and thinking level for every tier
  • A separately configurable classifier model and thinking level
  • The classifier may use any authenticated model, including fast or free models outside the routing scope
  • Automatic deterministic routing with no sensitivity tuning required
  • Interactive recovery when classification or model activation fails
  • Global configuration only
  • No rerouting of later prompts or resumed sessions

Install

pi install npm:@janvitos/pi-auto-model

For local development:

pi -e /path/to/pi-auto-model

Configure

Run:

/automodel

On first startup or reload without a configuration, the extension directs the user to /automodel setup. Initial setup requires selecting every model and thinking level; the extension assumes no provider or model defaults. The tier picker respects Pi's current enabledModels or --models scope when one is active.

Commands:

/automodel             Open the menu
/automodel setup       Reconfigure tiers and classifier
/automodel tiers       Reconfigure only the tiers
/automodel classifier  Reconfigure only the classifier
/automodel status      Show the active configuration
/automodel on          Enable routing
/automodel off         Disable routing

Configuration is stored at:

~/.pi/agent/auto-model.json

How routing works

On the first agent-bound prompt of an empty session, the extension asks the configured classifier model to return one tier label. It evaluates implied scope, investigation, data, ambiguity, constraints, consequences, and synthesis using a deterministic rubric. Pi then switches to that tier's model and thinking level before processing the task. In two-tier mode, exact standard output is normalized to simple, matching the routing policy for standard-level work when no Standard tier exists. The classifier call has a short timeout and a bounded output allowance that leaves room for reasoning tokens.

If classification fails, the selected tier model cannot be activated, or authentication fails, interactive modes ask whether to stop, use an available adjacent tier, choose a configured tier manually, or continue with the Pi model that was active before routing. No fallback preference is saved. Modes without interactive UI stop automatically.

Because Pi cannot cancel from the fully expanded before_agent_start event, Stop is implemented as a safe soft stop: the original task and images are removed from the outgoing task-model context, tools are temporarily disabled, and the active model receives only a minimal request to acknowledge that execution stopped. This makes one small acknowledgement model call; it does not execute the original task. The classifier has already received the expanded first prompt at that point.

Routing happens once per session. Existing, resumed, and already-routed sessions are left unchanged.

Limitations

Pi does not currently expose an API for extensions to contribute entries to the built-in /settings menu, so this package provides its own native-style /automodel menu.

License

MIT