Skip to content

0.4.0: Self-healing routing and npm distribution

Choose a tag to compare

@qadanm qadanm released this 05 Nov 10:09
· 37 commits to main since this release

The router now recovers from a class of provider errors that used to end the turn.

What happened on a real session: Anthropic only accepts user and assistant message roles. Mid-session notices got rebuilt into the prompt as system roles, so every turn on a Claude model died with Invalid discriminator value. Expected 'user' | 'assistant' at messages.23.role.

Three changes:

  1. For Anthropic-protocol models, the router folds system entries after the first message into user messages before the request leaves. The error cannot happen anymore.
  2. A rejected request shape is its own failure class now. The host's retry is refused, so the same 400 does not burn several turns in a row.
  3. If a provider still rejects the request, the router holds the model back for five minutes, re-routes the task to the next best eligible model, and continues the turn with a single [router] notice. One failover per prompt. The panel shows what was rejected and what took over.

npm

The routing core ships as @qadanm/opencode-smart-router, one self-contained file with no runtime dependencies:

{ "plugin": ["@qadanm/opencode-smart-router"] }

The desktop panel, terminal commands, history import and first-run onboarding still come from the installer:

curl -fsSL https://raw.githubusercontent.com/qadanm/opencode-smart-router/main/install | bash

759 tests across 63 files. MIT.