Skip to content

openrouter-decisions 0.1.0: OpenRouter's Decisions API as System One - #1324

Open
Subway-chenyan wants to merge 2 commits into
magpie-community:mainfrom
Subway-chenyan:openrouter-decisions
Open

Subway-chenyan wants to merge 2 commits into
magpie-community:mainfrom
Subway-chenyan:openrouter-decisions

Conversation

@Subway-chenyan

Copy link
Copy Markdown

What

A new provider package, packages/openrouter-decisions
(@magpie-community/opencode-openrouter-decisions-auth), exposing
OpenRouter's Decisions API (POST https://openrouter.ai/api/alpha/decisions)
through magpie's System One interface.

Provider id: openrouter-decisions. Models:
microsoft-decision-1.1 (text+image input) and microsoft-decision-1
(text), Microsoft's System One decision models on OpenRouter.

Registry entry and a root-README row are included, beside the other
decision providers.

Why

OpenRouter speaks a System One dialect on a different path with a few extra
constraints, so its decision models (including newly added Microsoft
Decision 1.1) cannot serve as magpie classifiers directly. This package
converts, the same way openai-decisions does for OpenAI's native API.

How

  • choice, score and noul questions; answers validated and restored
    with probabilities, confidence and the score legend. Per-question
    refusals stay refusals; other answers and usage are kept.
  • The choices: [...] shorthand expands to a criteria map; blank criteria
    text falls back to the option name (then a positional label), because the
    upstream rejects empty strings with 422 (string_too_short).
  • Object, numeric and boolean System One state become JSON text evidence;
    text passes through; multimodal part arrays keep their form.
  • auth.usage reads /api/v1/auth/key and /api/v1/credits: credit
    window, percentage and balance in magpie quota.
  • Fixed upstream endpoint, fresh header set, no redirects, gateway headers
    and cookies never forwarded. HTTP error answers pass through untouched
    and are never retried; one quick network-level retry absorbs transient
    connection failures (observed once in production use); cancellation
    propagates. No failover of its own — magpie routes.
  • Decision models carry decides: true, stay out of the chat catalog and
    refuse conversation requests.
  • opencode2.mjs is a byte-identical copy of scripts/opencode2.mjs.

Checks

  • bun scripts/check.mjs — all packages pass (60 ✓, 0 ✗) on this branch.
  • bun test packages/openrouter-decisions — 16 pass, 0 fail (offline,
    injected fetches, synthetic credentials, no files written).
  • scripts/try.sh openrouter-decisions in a sandbox HOME with magpie
    0.1.4462: provider listed with 2 models; after sign-in,
    provider test shows ✓ decide 2228 ms · microsoft-decision-1.1
    (chat correctly refused: the models only decide).
  • Live routing: as a group's intent classifier, the decision reached the
    gateway in ~1.1–3.0 s and the routing record carried the matched intent
    and sure values of 0.94–0.99; magpie quota showed the credit window
    and balance.

Review checklist from the README followed: credentials only through the
host's selected-account auth, non-empty instructions and criteria supplied
wherever the upstream requires them, offline tests without credential
files, English code comments, root README / package README / bilingual
registry / changelog aligned, live verification recorded in
VERIFICATION.md.

Not verified: OpenCode 2.x decision workflows end to end; other OpenRouter
decision models; box questions (the models do not declare image
localization and the adapter does not accept the type).

chenyan added 2 commits November 18, 2026 20:17
A provider exposing OpenRouter's Decisions API (POST
https://openrouter.ai/api/alpha/decisions) through magpie's System One
interface, serving Microsoft's decision models microsoft-decision-1.1
and microsoft-decision-1 as classifiers and decision-group members.

- choice, score and noul questions with probabilities, confidence and
  the score legend validated and restored
- choices [...] shorthand expanded to a criteria map; blank criteria
  text falls back to the option name so the upstream's non-empty
  constraint holds
- object, numeric and boolean state become JSON text evidence; text
  and multimodal part arrays pass through
- per-question refusals stay refusals; other answers and usage kept
- OpenRouter credit usage through auth.usage (/api/v1/auth/key,
  /api/v1/credits)
- fixed upstream endpoint, fresh header set, no redirects; HTTP error
  answers never retried, one quick network-level retry for transient
  connection failures; cancellation propagates
- decision models stay out of the chat catalog and refuse conversation

16 offline tests (node --test, bun test) with injected fetches;
verified live on magpie 0.1.4462 as an intent classifier and through
/provider test (decide 2228 ms) in a sandbox HOME.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant