From d3aecfe9581a0e543a8e13cfcd423e109c7c3062 Mon Sep 17 00:00:00 2001 From: yetone Date: Wed, 11 Nov 2026 23:54:16 +0800 Subject: [PATCH] test models: a plugin model its vendor queued answers OK, saying the queue (Mr7Faith on X) Qoder personal_standard: qmodel_latest (shown as Qwen4-Max-Preview) and dfmodel were queued (503 "queued the request for qmodel_latest (this plan's queue: p4, 1 ahead); try again in 60s"). The test sends X-Magpie-Fallback so the plugin says the queue at once, and the probe counted that 503 a failure: red all day, and Working only unpicked the models. The id in the error is the model's own id (the listing's display name changed), not a mapping bug. A queued model is served and an agent's turn waits it out, so the probe now sets OK with Result.Queued, which the chip's title shows. Run on mote: go test -run TestPluginModelTest ./internal/provider ok (TestPluginModelTestSaysQueued now wants OK + Queued; build-red on the old test.go); go vet darwin/linux/windows ./internal/provider; GUI models-queued, model-test-one, i18n-keys in chromium and webkit ok; models-queued red without the app.js line. models-works-only is red on origin/main c43314792 too (#4391). Not run: full suite, real Qoder account. --- docs/subsystems/provider-plugins.md | 2 +- internal/gui/assets/app.js | 2 +- internal/gui/tests/models-queued.test.cjs | 72 +++++++++++++++++++++ internal/provider/plugin_model_test_test.go | 4 +- internal/provider/test.go | 13 ++++ 5 files changed, 89 insertions(+), 4 deletions(-) create mode 100644 internal/gui/tests/models-queued.test.cjs diff --git a/docs/subsystems/provider-plugins.md b/docs/subsystems/provider-plugins.md index 58afe728b..426d454b0 100644 --- a/docs/subsystems/provider-plugins.md +++ b/docs/subsystems/provider-plugins.md @@ -170,7 +170,7 @@ So `forwardOnce` sets two more headers on every plugin request, each dropped fir A free model's vendor may queue a request for minutes: Qoder answers its code 10605 and its plugin waits in Qoder's queue as Qoder's client does (up to 4 minutes), CodeArts answers a 429 with `queue-status: queued` and its plugin polls the trace for up to 5 minutes. While another account, provider or routing group member could answer at once, that wait only keeps the agent waiting (axuhere on X: "模型请求正在排队 · 预计等待超过 10 分钟"). -So the try loop marks a try that isn't the last candidate (`withFallback` in [`continuation.go`](../../internal/gateway/continuation.go), from `!last` in the loop), and `forwardOnce` sets `x-magpie-fallback: 1` (`provider.FallbackHeader`) on that plugin request; a header the agent sent under that name is dropped first. A plugin told so answers a queued request at once, a 503 with the queue's Retry-After and a message that says the queue (Qoder 0.2.40: "Qoder queued the request for dfmodel (this plan's queue: p3, 3 ahead); try again in 30s"; CodeArts 0.2.3 leaves the queue first). The 503 is `busy`, so the next candidate is asked, the trace shows the try's reason, and the queued one may be asked again in a replan round after its Retry-After. The last candidate is never told, and its plugin waits in the queue as the vendor's client does. `unsaid` in `host.js` takes the header off whatever the plugin sends on. A plugin model's test sends it as well, so a queued model is said at once there too (`probe` in [`test.go`](../../internal/provider/test.go), `TestPluginModelTestSaysQueued`). +So the try loop marks a try that isn't the last candidate (`withFallback` in [`continuation.go`](../../internal/gateway/continuation.go), from `!last` in the loop), and `forwardOnce` sets `x-magpie-fallback: 1` (`provider.FallbackHeader`) on that plugin request; a header the agent sent under that name is dropped first. A plugin told so answers a queued request at once, a 503 with the queue's Retry-After and a message that says the queue (Qoder 0.2.40: "Qoder queued the request for dfmodel (this plan's queue: p3, 3 ahead); try again in 30s"; CodeArts 0.2.3 leaves the queue first). The 503 is `busy`, so the next candidate is asked, the trace shows the try's reason, and the queued one may be asked again in a replan round after its Retry-After. The last candidate is never told, and its plugin waits in the queue as the vendor's client does. `unsaid` in `host.js` takes the header off whatever the plugin sends on. A plugin model's test sends it as well, so a queued model is said at once there too; the test counts that 503 as answered (`Result.Queued` holds the queue's message, shown as the chip's title; Working only keeps the model), since a queued model is served and an agent's turn waits it out (`probe` in [`test.go`](../../internal/provider/test.go), `TestPluginModelTestSaysQueued`, `models-queued.test.cjs`). `TestPluginToldAnotherFollows` ([`plugin_fallback_test.go`](../../internal/gateway/plugin_fallback_test.go)) sends a group of two members through the fake plugin: the first is told, gives way with a 503, and the second answers untold; a lone model is never told, and the vendor never gets the header. diff --git a/internal/gui/assets/app.js b/internal/gui/assets/app.js index e25decf56..8861ca81e 100644 --- a/internal/gui/assets/app.js +++ b/internal/gui/assets/app.js @@ -11243,7 +11243,7 @@ function renderModels(p) { // the API it was asked on said, where the answer says (01huadalang: // 右键选择测试只能测试出是不是通的,不能说什么协议是通的) const via = x?.protocol ? apiLabel(x.protocol) : ""; - c.title = !x ? t("Testing…") : x.ok ? (via ? t("Answered via {api} in {took}", { api: via, took: ledTook(x.ms) }) : t("Answered in {took}", { took: ledTook(x.ms) })) : (via ? via + " · " : "") + (x.status ? x.status + " · " : "") + x.error; + c.title = !x ? t("Testing…") : x.ok && x.queued ? x.queued : x.ok ? (via ? t("Answered via {api} in {took}", { api: via, took: ledTook(x.ms) }) : t("Answered in {took}", { took: ledTook(x.ms) })) : (via ? via + " · " : "") + (x.status ? x.status + " · " : "") + x.error; }; // a chip's right-click tests that model alone (yonghe); off, saying why, where it can't be (ARNO) const noTest = modelTestWhy(p); diff --git a/internal/gui/tests/models-queued.test.cjs b/internal/gui/tests/models-queued.test.cjs new file mode 100644 index 000000000..878862fb1 --- /dev/null +++ b/internal/gui/tests/models-queued.test.cjs @@ -0,0 +1,72 @@ +// Run with Node's test runner and Playwright on the module path; see README.md. +// A plugin's model its vendor has queued (Qoder's "queued the request for +// ...", Mr7Faith on X) answers its test OK: a green dot whose title says the +// queue, and Working only keeps it picked. +const assert = require("node:assert/strict"); +const fs = require("node:fs/promises"); +const path = require("node:path"); +const { test } = require("node:test"); +const { chromium, webkit } = require("playwright"); + +const assets = path.resolve(__dirname, "../assets"); +const fetched = new Date(Date.now() - 3600e3).toISOString(); +const m = (id, i) => ({ id, name: id, on: i < 4 }); +const ids = ["glm-5", "kimi-k3", "qwen4-max", "deepseek-v4", "minimax-m3", "gpt-oss-200b"]; +const relay = { + id: "mixed", name: "Mixed Relay", icon: "generic", host: "mixed.example.com", chat: "https://mixed.example.com/v1", responses: "", anthropic: "", catalog: "", + models: ids.map(m), chosen: ids.slice(0, 4), fetched, agents: [], fallback: [], headers: {}, + key: { set: true, masked: "sk-…one" }, keyList: [], balanceToken: { takes: false, set: false }, proxy: "", +}; +// what the vendor answered: two of the four picks fail +const answers = { + "glm-5": { ok: true, ms: 410, protocol: "openai", queued: "Qoder queued the request for glm-5 (this plan's queue: p4, 1 ahead); try again in 60s" }, + "kimi-k3": { ok: false, status: 404, error: "model not found", protocol: "openai" }, + "qwen4-max": { ok: true, ms: 380, protocol: "openai" }, + "deepseek-v4": { ok: false, status: 503, error: "no available channel", protocol: "openai" }, +}; +const KEPT = ["glm-5", "minimax-m3", "qwen4-max"]; + +function serve(lang, posts) { + const providers = { providers: [relay], presets: [], excluded: [], gateway: { running: true, window: true } }; + const state = { agents: [], profiles: [], settings: { lang, theme: "light" } }; + return async (route) => { + const req = route.request(), url = new URL(req.url()); + const json = (data) => route.fulfill({ json: data }); + if (url.pathname === "/boot.js") return route.fulfill({ contentType: "text/javascript", body: `window.bootPrefs = {lang:"${lang}",theme:"light",web:true};` }); + if (url.pathname === "/wails/runtime.js") return route.fulfill({ contentType: "text/javascript", body: "export const Window = {};" }); + if (req.method() === "POST" && url.pathname.startsWith("/api/")) posts.push({ path: url.pathname, body: req.postDataJSON() || {} }); + if (url.pathname === "/api/state") return json(state); + if (url.pathname === "/api/plugins") return json({ plugins: [] }); + if (url.pathname === "/api/providers") return json(providers); + if (url.pathname === "/api/groups") return json({ groups: [] }); + if (url.pathname === "/api/provider/test") { + const body = req.postDataJSON(); + return json({ results: body.test.map((model) => ({ model, ...answers[model] })) }); + } + if (url.pathname.startsWith("/api/")) return json({}); + const file = path.join(assets, url.pathname === "/" ? "index.html" : url.pathname); + const contentType = { ".html": "text/html", ".js": "text/javascript", ".css": "text/css", ".svg": "image/svg+xml", ".png": "image/png" }[path.extname(file)]; + await route.fulfill({ body: await fs.readFile(file), contentType }); + }; +} + + +for (const engine of (process.env.BROWSER ? [process.env.BROWSER] : ["chromium", "webkit"])) { + test(`${engine}: a queued model's test is green and says the queue`, async (t) => { + const browser = await (engine === "webkit" ? webkit.launch() : chromium.launch({ channel: "chromium" })); + t.after(() => browser.close()); + const page = await (await browser.newContext({ viewport: { width: 900, height: 700 }, reducedMotion: "reduce" })).newPage(); + page.setDefaultTimeout(5000); + page.setDefaultNavigationTimeout(60000); + await page.route("**/*", serve("en", [])); + await page.goto("http://magpie.test/?view=providers"); + const editor = page.locator("#modal:not([hidden]) .editor"); + await page.locator(".row.provider", { hasText: "Mixed Relay" }).click(); + await editor.locator(".mchips .mchip").first().waitFor(); + await editor.getByRole("button", { name: "Test models", exact: true }).click(); + await editor.locator(".mchips .tdot.ok").first().waitFor(); + const chip = editor.locator(".mchips .mchip", { hasText: "glm-5" }); + assert.equal(await chip.locator(".tdot.ok").count(), 1); + assert.match(await chip.getAttribute("title"), /queued the request for glm-5/); + }); +} diff --git a/internal/provider/plugin_model_test_test.go b/internal/provider/plugin_model_test_test.go index a90be5052..828e3cffe 100644 --- a/internal/provider/plugin_model_test_test.go +++ b/internal/provider/plugin_model_test_test.go @@ -81,8 +81,8 @@ func TestPluginModelTestSaysQueued(t *testing.T) { got[r.Model] = r } q := got["fake-1"] - if q.OK || !strings.Contains(q.Error, "queued the request for fake-1") { - t.Errorf("the queued model's test: ok %v, %q (%v); want the plugin's queue message", q.OK, q.Error, took) + if !q.OK || q.Error != "" || !strings.Contains(q.Queued, "queued the request for fake-1") { + t.Errorf("the queued model's test: ok %v, error %q, queued %q (%v); want OK with the plugin's queue message", q.OK, q.Error, q.Queued, took) } if strings.Contains(q.Error, "deadline") { t.Errorf("the queued model's test ran out of time: %q", q.Error) diff --git a/internal/provider/test.go b/internal/provider/test.go index ad442b332..403d90263 100644 --- a/internal/provider/test.go +++ b/internal/provider/test.go @@ -38,6 +38,11 @@ type Result struct { // otherAPI: the vendor said the model isn't served on the API asked // (catalog.WrongEndpoint), so another may be asked instead otherAPI bool + // Queued is the vendor's queue message when a plugin's model was + // queued instead of answered (Qoder's "queued the request for ..."). + // The model is served, so the test is OK: it waits where an agent's + // turn waits it out. + Queued string `json:"queued,omitempty"` // V1 is the base the request was answered at once the /v1 it was // typed without was added (missingV1): the editor's URL takes it V1 string `json:"v1,omitempty"` @@ -1008,6 +1013,14 @@ func probeOnce(ctx context.Context, p Provider, proto Protocol, url string, body } b, _ := io.ReadAll(io.LimitReader(res.Body, 4096)) r.Error = APIError(b, res.Status) + if p.IsPlugin() && res.StatusCode == http.StatusServiceUnavailable && res.Header.Get("Retry-After") != "" && strings.Contains(strings.ToLower(r.Error), "queued") { + // asked not to wait (FallbackHeader), a plugin says its vendor's + // queue at once. A model in a queue is served, and an agent's + // turn waits it out: not a failed test (Mr7Faith on X: Qoder's + // models were red all day while queued) + r.OK, r.Queued, r.Error = true, r.Error, "" + return r + } r.otherAPI = catalog.WrongEndpoint(res.StatusCode, b) return r }