system one: a decision provider's own models-list URL is asked as given, and its models can each be tested (Discord, ARNO: OpenRouter added as a System One provider with the list https://openrouter.ai/api/v1/models?limit=500&output_modalities=decisions didn't get its models, and a model typed in by hand couldn't be tested from its right-click) — a System One-only provider went to fetchDecide before its ModelsURL was read, so magpie asked …/models, which at OpenRouter lists the 466 chat models, and kept only Jev's ids of those: typesafe/jev-router alone. With a ModelsURL, fetchDecide now asks it as written, query included, and keeps every id in it, since that list is of decision models already (OpenRouter's answers 13: pplx-decider, liquid/d1, cloudflare/clef, respan/span-01, typesafe/jev-1.13 …). Without one nothing changes, Bailian included. Testing a decision model was refused outright (the chip's Test this model off, Test models leaving them out); where the API takes System One's own body (System One, TypeSafe, OpenRouter, Vercel's TypeSafe API) each model is now sent AskSystemOne's yes-or-no question, the one Detect already asks, and the editor offers Test for it (providerJSON.decideTest); Vercel's evaluation models and Workers AI, which wrap it their own way, still say why not. TestDecideModelsURLAndModelTest (a fake OpenRouter: the plain list, the decisions list, a hand-added model through /systemone, an unknown one failing) and TestModelTest's Workers AI case fail on the old code; model-test-why.test.cjs gains a hand-added System One model tested from its chip and Test models, and a Workers AI one still off (WebKit en and zh pass, with model-test-one and model-copy-id; Chromium doesn't launch in this sandbox). OpenRouter's live decisions list returns the 13 models. Not tried with an OpenRouter key: the /systemone question itself. go vet, builds (darwin, GOOS=linux, GOOS=windows) and go test -tags nogui -count=1 ./... under a temp HOME pass.

This commit is contained in:
yetone
2026-10-04 18:40:13 +08:00
parent 040ae5675a
commit 71d96e28e8
8 changed files with 186 additions and 19 deletions
+4 -2
View File
@@ -7573,7 +7573,9 @@ function renderModels(p) {
}, "API this model is asked on", "model-api-menu");
};
const menu = (c, id) => {
const noTest = decidesModel(p, id) ? modelTestWhy({ modelTest: "decide" }) : modelTestWhy(p);
// a decision model is asked a System One question where the server
// says its API takes one (decideTest)
const noTest = decidesModel(p, id) ? (p.decideTest ? "" : modelTestWhy({ modelTest: "decide" })) : modelTestWhy(p);
if (!noTest) c.title = (c.title ? c.title + "\n" : "") + t("Right-click to test just this model");
c.oncontextmenu = (e) => {
e.preventDefault();
@@ -7893,7 +7895,7 @@ function renderModels(p) {
const testAll = el("button", "text action", t("Test models"));
testAll.title = t("Send a tiny request to each model agents see, to find the ones that don't answer") + "\n" + t("Right-click a model to test just it");
testAll.onclick = async () => {
const ids = (draft.chosen.length ? draft.chosen : p.models.filter((m) => m.on).map((m) => m.id)).filter((id) => !decidesModel(p, id));
const ids = (draft.chosen.length ? draft.chosen : p.models.filter((m) => m.on).map((m) => m.id)).filter((id) => p.decideTest || !decidesModel(p, id));
if (!ids.length) { status(t("Pick a model first."), "err"); return; }
testAll.classList.add("busy");
const got = modelTests[p.id] = {};
+5 -1
View File
@@ -94,6 +94,10 @@ type providerJSON struct {
// when they can (provider.ModelTest): the editor says so on a chip's
// right-click rather than offer no menu
ModelTest string `json:"modelTest,omitempty"`
// DecideTest is set when its decision models can each be sent a
// System One question (provider.AsksDecideModels): a mixed
// provider's Jev too, beside its conversation models
DecideTest bool `json:"decideTest,omitempty"`
Key struct {
Set bool `json:"set"`
@@ -355,7 +359,7 @@ func agentUses(agents []*agent.Agent, findGroup func(string) (provider.Group, []
func providerInfo(p provider.Provider, agents []agentUse) providerJSON {
out := providerJSON{
ID: p.ID, Name: p.Name, Icon: p.Icon, Preset: p.Preset, Host: p.Host(),
Chat: p.Chat, Responses: p.Responses, Anthropic: p.Anthropic, Decide: p.Decide, ModelTest: p.ModelTest(),
Chat: p.Chat, Responses: p.Responses, Anthropic: p.Anthropic, Decide: p.Decide, ModelTest: p.ModelTest(), DecideTest: p.AsksDecideModels(),
Catalog: p.Catalog, Website: p.Website, KeysURL: p.KeysURL,
Proxy: p.Proxy, AccountProxies: p.AccountProxies, AccountModels: p.AccountModels, AccountCaps: p.AccountCaps, Headers: p.Headers, Searches: p.Searches, BalanceURL: p.BalanceURL, BalancePath: p.BalancePath, ModelsURL: p.ModelsURL,
Ready: p.Ready(), Chosen: p.Models, Models: []modelJSON{}, Agents: []providerAgent{},
+47 -1
View File
@@ -6,7 +6,9 @@
// own API (Kiro: modelTest "own-api") and a classifier ("decide") still open
// the menu on a right-click, its Test this model off with the reason under it
// and as its title, and Test models is off with the reason as its title;
// nothing is posted and the page doesn't move. In English and Chinese.
// nothing is posted and the page doesn't move. A System One provider's
// model, one typed in by hand too, is tested (decideTest); Workers AI's
// isn't. In English and Chinese.
const assert = require("node:assert/strict");
const fs = require("node:fs/promises");
const path = require("node:path");
@@ -26,6 +28,16 @@ const providers = [
models: [{ id: "claude-sonnet-5", name: "", on: true }, { id: "claude-haiku-5", name: "", on: true }],
account: { agent: "kiro", agentName: "Kiro", user: "k@example.com", plan: "PRO", logins: [{ user: "k@example.com", plan: "PRO", active: true, on: true }] },
},
// a System One provider (OpenRouter's) with a model typed in by hand
// (ARNO on Discord), and Workers AI, whose models can't each be asked
{
...base, id: "or-decide", name: "Deciders", decide: "https://openrouter.ai/api/v1", decideTest: true, chosen: ["respan/span-01"],
models: [{ id: "liquid/d1", name: "", on: true }, { id: "respan/span-01", name: "", on: true }], key: { set: true, masked: "sk-…one" },
},
{
...base, id: "cf-jev", name: "Workers", decide: "https://api.cloudflare.com/client/v4/accounts/a/ai/run", modelTest: "decide",
models: [{ id: "typesafe/jev", name: "", on: true }], key: { set: true, masked: "sk-…two" },
},
];
function serve(lang, tests) {
@@ -152,5 +164,39 @@ for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium",
assert.deepEqual(missing, [], "every string has its Chinese");
assert.deepEqual(errors, []);
});
test(`${engine} ${lang}: a System One model typed in by hand is tested from its chip`, async (t) => {
const tests = [];
const { page, errors } = await open(t, "Deciders", tests);
const c = chip(page, "respan/span-01");
await c.click({ button: "right" });
const menu = page.locator(".pop.row-menu");
await menu.waitFor();
const item = menu.getByRole("menuitem", { name: w.item });
assert(await item.isEnabled(), "the decision model can be tested");
await item.click();
for (let i = 0; i < 60 && !tests.length; i++) await page.waitForTimeout(50);
assert.deepEqual({ id: tests[0]?.id, test: tests[0]?.test }, { id: "or-decide", test: ["respan/span-01"] });
await c.locator(".tdot.ok").waitFor();
const all = page.locator(".editor .mfoot").getByRole("button", { name: w.all, exact: true });
assert(await all.isEnabled(), "Test models is offered");
await all.click();
for (let i = 0; i < 60 && tests.length < 2; i++) await page.waitForTimeout(50);
assert.deepEqual(tests[1]?.test, ["respan/span-01"], "Test models asks the picked decision model");
assert.deepEqual(errors, []);
});
test(`${engine} ${lang}: a Workers AI classifier's model still says why it can't be tested`, async (t) => {
const tests = [];
const { page, errors } = await open(t, "Workers", tests);
await chip(page, "typesafe/jev").click({ button: "right" });
const menu = page.locator(".pop.row-menu");
await menu.waitFor();
assert(await menu.locator(".rm-item").first().isDisabled(), "Test this model is off");
await page.keyboard.press("Escape");
await page.waitForTimeout(150);
assert.equal(tests.length, 0, "nothing was sent");
assert.deepEqual(errors, []);
});
}
}
+4 -1
View File
@@ -131,7 +131,10 @@ func TestModelTest(t *testing.T) {
{Provider{ID: "copilot", Chat: "https://api.githubcopilot.com", Account: &Account{Agent: "copilot"}}, ""},
{Provider{ID: "kiro", Key: "k", Account: &Account{Agent: "kiro"}}, "own-api"},
{Provider{ID: "cursor", Account: &Account{Agent: "cursor"}}, "own-api"},
{Provider{ID: "jev", Decide: "https://decide.test/v1"}, "decide"},
// System One's models are each asked a question of their own;
// Workers AI's envelope isn't System One's
{Provider{ID: "jev", Decide: "https://decide.test/v1"}, ""},
{Provider{ID: "cf", Decide: "https://api.cloudflare.com/client/v4/accounts/a/ai/run"}, "decide"},
} {
if got := c.p.ModelTest(); got != c.want {
t.Errorf("%s: %q, want %q", c.p.ID, got, c.want)
+15 -7
View File
@@ -486,11 +486,18 @@ func (p Provider) fetchDecide(ctx context.Context) ([]catalog.Model, error) {
}
return p.decideModels(), nil
}
// Bailian lists its chat models only: its decision model is asked
if bailianDecides(p.Decide) {
// the list where the user said its models are, asked as given, query
// and all (ARNO on Discord: OpenRouter's decision models are at
// …/models?output_modalities=decisions; its /models lists chat models
// only, and only Jev's of those were kept): every model in it is one
list, all := p.Decide+"/models", false
if u := strings.TrimSpace(p.ModelsURL); u != "" && p.DecideOnly() {
list, all = u, true
} else if bailianDecides(p.Decide) {
// Bailian lists its chat models only: its decision model is asked
return p.decideAsked(ctx)
}
req, err := http.NewRequestWithContext(ctx, http.MethodGet, p.Decide+"/models", nil)
req, err := http.NewRequestWithContext(ctx, http.MethodGet, list, nil)
if err != nil {
return nil, err
}
@@ -512,7 +519,7 @@ func (p Provider) fetchDecide(ctx context.Context) ([]catalog.Model, error) {
}
return nil, fmt.Errorf("%s: %s", p.Name, APIError(b, res.Status))
}
ms, err := listedDecide(b)
ms, err := listedDecide(b, all)
if (err != nil || len(ms) == 0) && own {
return p.decideAsked(ctx)
}
@@ -585,8 +592,9 @@ func (p Provider) AskSystemOne(ctx context.Context, model string) error {
// {"models":[{"name":…}]}. A gateway in front of Jev often answers
// OpenAI's instead, {"data":[{"id":…}]}, and that list is every model
// it serves, so an id counts only when it is Jev's: "jev…" or "…/jev…".
// Names, when the list has any, are kept as they are.
func listedDecide(b []byte) ([]catalog.Model, error) {
// Names, when the list has any, are kept as they are. With all, every id
// counts: a list the user pointed at is of decision models already.
func listedDecide(b []byte, all bool) ([]catalog.Model, error) {
var out struct {
Models []struct {
Name string `json:"name"`
@@ -610,7 +618,7 @@ func listedDecide(b []byte) ([]catalog.Model, error) {
}
seen := map[string]bool{}
take := func(id string) {
if id == "" || seen[id] || !jevID(id) {
if id == "" || seen[id] || !all && !jevID(id) {
return
}
seen[id] = true
+75
View File
@@ -0,0 +1,75 @@
package provider
import (
"context"
"encoding/json"
"net/http"
"net/http/httptest"
"slices"
"sync"
"testing"
)
// A System One provider at OpenRouter (ARNO on Discord): its /models lists
// chat models, Jev's router among them, and its decision models are at
// /models?output_modalities=decisions, the URL the user gave. Every model
// in that list is fetched, and a model typed in by hand is tested with a
// System One question of its own.
func TestDecideModelsURLAndModelTest(t *testing.T) {
t.Setenv("HOME", t.TempDir())
t.Setenv("USERPROFILE", t.TempDir())
t.Setenv("XDG_CONFIG_HOME", t.TempDir())
t.Setenv("XDG_CACHE_HOME", t.TempDir())
var mu sync.Mutex
var asked []string
up := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
switch r.URL.Path {
case "/api/v1/models":
if r.URL.Query().Get("output_modalities") == "decisions" && r.URL.Query().Get("limit") == "500" {
w.Write([]byte(`{"data":[{"id":"perplexity/pplx-decider-v1-27b","architecture":{"output_modalities":["decisions"]}},{"id":"liquid/d1"},{"id":"~typesafe/jev-latest"},{"id":"typesafe/jev-1.13"}],"total_count":4}`))
return
}
w.Write([]byte(`{"data":[{"id":"openai/gpt-5"},{"id":"typesafe/jev-router"}]}`))
case "/api/v1/systemone":
var q struct{ Model string }
json.NewDecoder(r.Body).Decode(&q)
mu.Lock()
asked = append(asked, q.Model)
mu.Unlock()
if q.Model == "nobody/none" {
http.Error(w, `{"error":{"message":"No such model"}}`, 404)
return
}
w.Write([]byte(`{"answers":{"ok":{"answer":true}}}`))
default:
http.NotFound(w, r)
}
}))
defer up.Close()
p := Provider{ID: "openrouter-s1", Name: "OpenRouter", Key: "k", Decide: up.URL + "/api/v1",
ModelsURL: up.URL + "/api/v1/models?limit=500&output_modalities=decisions", Models: []string{"respan/span-01"}}
if err := Save(p); err != nil {
t.Fatal(err)
}
ms, err := p.Fetch(context.Background())
if err != nil {
t.Fatal(err)
}
var ids []string
for _, m := range ms {
ids = append(ids, m.ID)
}
if !slices.Equal(ids, []string{"perplexity/pplx-decider-v1-27b", "liquid/d1", "~typesafe/jev-latest", "typesafe/jev-1.13"}) {
t.Fatalf("decision models: %v", ids)
}
if why := p.ModelTest(); why != "" {
t.Fatalf("models not testable: %s", why)
}
r := p.TestModels(context.Background(), []string{"respan/span-01", "nobody/none"})
if !r[0].OK || r[0].Protocol != "decide" || r[0].Model != "respan/span-01" || r[1].OK || r[1].Error == "" {
t.Fatalf("model tests: %+v", r)
}
if !slices.Equal(asked, []string{"respan/span-01", "nobody/none"}) && !slices.Equal(asked, []string{"nobody/none", "respan/span-01"}) {
t.Fatalf("asked: %v", asked)
}
}
+5 -5
View File
@@ -313,21 +313,21 @@ func TestFetchDecideOpenAIJevIDs(t *testing.T) {
t.Fatalf("test %+v", r)
}
names, err := listedDecide([]byte(`{"models":[{"name":"jev-latest"},{"name":"other-model"}],"data":[{"id":"gemini-3"}]}`))
names, err := listedDecide([]byte(`{"models":[{"name":"jev-latest"},{"name":"other-model"}],"data":[{"id":"gemini-3"}]}`), false)
if err != nil || len(names) != 2 || names[0].ID != "jev-latest" || names[1].ID != "other-model" {
t.Fatalf("names %+v %v", names, err)
}
byID, err := listedDecide([]byte(`{"models":[{"id":"jev-preview"},{"id":"gemini-3"}]}`))
byID, err := listedDecide([]byte(`{"models":[{"id":"jev-preview"},{"id":"gemini-3"}]}`), false)
if err != nil || len(byID) != 1 || byID[0].ID != "jev-preview" {
t.Fatalf("id %+v %v", byID, err)
}
if ms, err := listedDecide([]byte(`{"data":[{"id":"gemini-3.8-flash"}]}`)); err != nil || len(ms) != 0 {
if ms, err := listedDecide([]byte(`{"data":[{"id":"gemini-3.8-flash"}]}`), false); err != nil || len(ms) != 0 {
t.Fatalf("unrelated %+v %v", ms, err)
}
if _, err := listedDecide([]byte(`<html>`)); err == nil || err.Error() != "not a model list" {
if _, err := listedDecide([]byte(`<html>`), false); err == nil || err.Error() != "not a model list" {
t.Fatal(err)
}
if ms, err := listedDecide([]byte(`{"data":[{"id":"jevons"},{"id":"foo/jevx"}]}`)); err != nil || len(ms) != 0 {
if ms, err := listedDecide([]byte(`{"data":[{"id":"jevons"},{"id":"foo/jevx"}]}`), false); err != nil || len(ms) != 0 {
t.Fatalf("jevons %+v %v", ms, err)
}
}
+31 -2
View File
@@ -100,13 +100,17 @@ func clineProbe(body string) string {
}
// ModelTest says why p's models can't each be sent a test request ("" when
// they can): "decide" for a decision API, whose models only classify and
// whose endpoint Test asks it for them; "own-api" for a sign-in reached
// they can): "decide" for a decision API whose models can't each be sent
// a System One question (AsksDecideModels), whose endpoint Test asks it
// for them; "own-api" for a sign-in reached
// through its agent's own API (Cursor, Devin, Kiro, Zed, Qoder, a Google
// sign-in), which the gateway translates every request for, so a probe
// has no endpoint to go to.
func (p Provider) ModelTest() string {
if p.DecideOnly() {
if p.AsksDecideModels() {
return ""
}
return "decide"
}
if p.isClaudeAccount() {
@@ -120,6 +124,16 @@ func (p Provider) ModelTest() string {
return "own-api"
}
// AsksDecideModels reports whether each of p's decision models can be
// sent a System One question of its own (TestModels): where the API is
// System One's, TypeSafe's or a gateway's that serves it as it is
// (Vercel's TypeSafe API, OpenRouter's), not Vercel's evaluation models
// nor Workers AI, which wrap it their own way.
func (p Provider) AsksDecideModels() bool {
v := p.DecideVia()
return p.Decides() && (v == ViaSystemOne || v == ViaVercel)
}
func tinyBody(q Provider, proto Protocol, model string) (url, body string) {
switch proto {
case Chat:
@@ -186,6 +200,21 @@ func (p Provider) TestModels(ctx context.Context, models []string) []Result {
}
func (p Provider) testOne(ctx context.Context, model string) Result {
if p.DecidesModel(model) && p.AsksDecideModels() {
// a decision model is sent the smallest System One question, a
// yes-or-no (ARNO on Discord: a System One model typed in by hand
// couldn't be tested from its right-click)
t0 := time.Now()
r := Result{Protocol: "decide", Model: model}
err := p.AskSystemOne(ctx, model)
r.Millis = time.Since(t0).Milliseconds()
if err != nil {
r.Error = err.Error()
return r
}
r.OK, r.Status = true, http.StatusOK
return r
}
if p.isClaudeAccount() {
return p.testClaude(ctx, model)
}