From c490e2a85ec7fe754c5f495070640cbd094439c1 Mon Sep 17 00:00:00 2001 From: yetone Date: Sat, 14 Nov 2026 11:13:50 +0800 Subject: [PATCH] codearts 0.3.19: the mainland station gets no stop at all (#1120) The mainland gateway (snap-access cn-north-4) now answers every non-empty stop with InferHub.001001005.400, a string too: Glueo measured "x", "###", "\n\n", "Observation:", "" and ["x"] on five models, all refused, and the same body without stop answered. 0.3.15's string-only rule (magpie#6342) no longer holds. Claude Code's auto-mode classifier always sends stop_sequences [""], so every classifier call on a mainland account was refused. normalizeStop now leaves stop out on the mainland; the international station still takes a list (#998), unchanged. Run: wsl-run bun test in packages/codearts, 211 pass. Broken by hand: main's index.mjs under the new test, 1 fail. scripts/check.mjs codearts ok. Not tried: a real mainland account here; the measurement is the reporter's. --- packages/codearts/index.mjs | 18 ++++++++++-------- packages/codearts/index.test.mjs | 8 +++----- packages/codearts/package.json | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/packages/codearts/index.mjs b/packages/codearts/index.mjs index 7401ec2..f85697e 100644 --- a/packages/codearts/index.mjs +++ b/packages/codearts/index.mjs @@ -1109,19 +1109,21 @@ function prepareChatBody(parsed, { thinking = true, station = "mainland" } = {}) } /** - * `stop` in the shape the credential's station takes; the other shape comes + * `stop` in the shape the credential's station takes; another shape comes * back as HTTP 200 with `InferHub.001001005.400` "The request param is - * invalid". The mainland gateway takes a string only (magpie#6342, measured - * with every model), so a list goes as its first non-empty string. The - * international one takes a list only (#998, GLM-5.1: `["zzz"]` answered, - * `"zzz"` refused), so a string goes as a list of one. An empty or blank - * value, or one of another kind, is left out on both. + * invalid". The mainland gateway refuses every non-empty `stop`, a string + * included (#1120, measured with every model; magpie#6342's string-only + * rule held for `"\n\n"` once and no longer does), so it is left out there: + * a reply that runs past a stop word beats one refused. The international + * gateway takes a list only (#998, GLM-5.1: `["zzz"]` answered, `"zzz"` + * refused), so a string goes as a list of one. An empty or blank value, or + * one of another kind, is left out on both. */ function normalizeStop(body, station = "mainland") { if (!("stop" in body)) return const all = (Array.isArray(body.stop) ? body.stop : [body.stop]).filter((x) => typeof x === "string" && x !== "") - if (!all.length) delete body.stop - else body.stop = station === "international" ? all : all[0] + if (station === "international" && all.length) body.stop = all + else delete body.stop } // ---- tool names over the gateway's limit (#432) ----------------------------- diff --git a/packages/codearts/index.test.mjs b/packages/codearts/index.test.mjs index 628967b..0a541a6 100644 --- a/packages/codearts/index.test.mjs +++ b/packages/codearts/index.test.mjs @@ -244,12 +244,10 @@ test("a dated model only the agent lists keeps its date, named or not (#677)", a assert.equal(names["deepseek-v4.1-flash-0930"], "Deepseek V4.1 Flash 0930") }) -test("stop goes as the string the gateway takes, and an empty one not at all (magpie#6342)", () => { +test("stop never reaches the mainland gateway, which refuses any (#1120, magpie#6342)", () => { const stop = (v) => x.prepareChatBody({ model: "GLM-5.2", messages: [], stop: v }).body - assert.equal(stop(["\n\n"]).stop, "\n\n") - assert.equal(stop(["", "###", "Observation:"]).stop, "###") - assert.equal(stop("###").stop, "###") - for (const v of [[], [""], [null, 3], "", null, 7]) assert.equal("stop" in stop(v), false, JSON.stringify(v)) + for (const v of [["\n\n"], ["", "###", "Observation:"], "###", "x", "", [], [""], [null, 3], "", null, 7]) + assert.equal("stop" in stop(v), false, JSON.stringify(v)) assert.equal("stop" in x.prepareChatBody({ model: "GLM-5.2", messages: [] }).body, false) // the international station takes a list only (#998) const intl = (v) => x.prepareChatBody({ model: "GLM-5.1", messages: [], stop: v }, { station: "international" }).body diff --git a/packages/codearts/package.json b/packages/codearts/package.json index 98ba7a5..0332b25 100644 --- a/packages/codearts/package.json +++ b/packages/codearts/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-codearts-auth", - "version": "0.3.18", + "version": "0.3.19", "description": "Huawei Cloud in OpenCode and magpie: CodeArts (码道) and OfficeAce (AgentArts), each from its own Huawei Cloud OAuth sign-in — models, credit rates, credit usage and the daily check-in (unofficial)", "type": "module", "main": "./opencode.mjs",