opendesign 0.1.11: cap glm-5.3-flash and gemini-3.8-flash output at what amr-link takes (#827)

amr-link's /v1/models publishes context_budget 232000 for glm-5.3-flash
and 264000 for gemini-3.8-flash. Its API refuses anything over 131072 and
65536 with a 400, "Open Design: The request could not be completed.",
which names no field. Gitleonan measured this on 2026-11-09 with two
accounts (one of them took 232000 for GLM). A client that sends no limit,
such as Codex, gets the published number from magpie
(forwardTranslated's askedOutput), so every turn on those models failed.

modelOf now caps limit.output for those two models (CAP). It applies to
the seed and to every live catalog entry. A copy an earlier version kept
in the provider's config is capped too: config hands kept models back as
they were. models.mjs is left alone because refresh-models.mjs writes the
vendor's number back into it, and the live catalog's number overrides the
seed's anyway. A catalog number under the cap is used as it is.

This does not fix the red test dot through a Remote magpie. That comes
from the stream glm-5.3-flash sends when it reaches max_tokens: it ends
after content_block_stop with no message_delta or message_stop. magpie's
test asks for 16 tokens, and the model always thinks first, so it always
reaches the limit. On the issue I point to the magpie code for that path.

Run (on mote): bun test packages/opendesign gives 30 pass, 0 fail.
Broken by hand: with origin/main's index.mjs, the new test fails, and
with the config cap removed (the modelOf cap kept), it fails on the kept
gemini copy's 264000.
Not tried: a real amr-link request. There's no Open Design account here,
so the caps are the reporter's measurements, not ours.

Reported-by: Gitleonan
This commit is contained in:
yetone
2026-11-09 09:56:29 +08:00
parent e2d15ba653
commit e68748a78e
3 changed files with 47 additions and 3 deletions
+18 -2
View File
@@ -280,6 +280,18 @@ function levelsOf(m) {
return Array.isArray(m?.efforts) ? m.efforts.filter((e) => typeof e === "string" && e) : []
}
// CAP is the most output a model may be asked for where amr-link's catalog
// (metadata.context_budget) says more than its API takes. Asking for more is
// a 400 "Open Design: The request could not be completed." that names no
// field, so nothing can lower it and retry. A client that names no limit
// (Codex) is given the published one by magpie, so every turn would fail
// (#827, Gitleonan, measured 2026-11-09 on two accounts): glm-5.3-flash took
// 131072 and refused 132000 (one account took 232000), and gemini-3.8-flash
// took 65536 and refused 65537 on both. The cap is applied here, not in
// models.mjs: the live catalog's number overrides the seed's (withSeed), and
// refresh-models.mjs writes the vendor's number back into the seed.
const CAP = { "glm-5.3-flash": 131072, "gemini-3.8-flash": 65536 }
// modelOf turns one model's facts — models.mjs's, or amr-link's catalog
// read again — into the model magpie shows, as the provider's config has
// it. A model reasons when it has levels, or else when the vendor calls it
@@ -305,7 +317,7 @@ function modelOf(id, m) {
...(rate && { rate }),
limit: {
context: Number.isFinite(context) && context > 0 ? context : 200_000,
output: Number.isFinite(output) && output > 0 ? output : 32_000,
output: Math.min(Number.isFinite(output) && output > 0 ? output : 32_000, CAP[id] ?? Infinity),
},
modalities: { input: ["text", ...input], output: ["text"] },
}
@@ -480,7 +492,11 @@ export const OpenDesignAuthPlugin = async () => {
const models = { ...seed(), ...(was.models ?? {}) }
for (const [id, m] of Object.entries(models)) {
const rate = RATES[id] === undefined ? undefined : "x" + RATES[id]
models[id] = { ...m, api: { ...(m.api ?? {}), npm: wireOf(id) }, provider: { ...(m.provider ?? {}), npm: wireOf(id) }, ...(rate && { rate }) }
// a kept copy's limit is capped too: an earlier version wrote the
// catalog's 232000 for glm-5.3-flash, which amr-link refuses (CAP)
const out = Number(m.limit?.output)
const limit = CAP[id] && !(out > 0 && out <= CAP[id]) ? { limit: { ...(m.limit ?? {}), output: CAP[id] } } : {}
models[id] = { ...m, ...limit, api: { ...(m.api ?? {}), npm: wireOf(id) }, provider: { ...(m.provider ?? {}), npm: wireOf(id) }, ...(rate && { rate }) }
}
cfg.provider[ID] = {
name: "Open Design",
+28
View File
@@ -284,6 +284,34 @@ test("a kept model's rate is re-declared, so a charge an earlier version wrote c
expect(models["brand-new-9"].rate).toBe("x1")
})
// #827 (Gitleonan): amr-link's catalog publishes more output than its API
// takes for two models, and asking for the published number is a 400 that
// names no field. The catalog entries are the reporter's numbers; the caps
// are what they measured on 2026-11-09 (131072 and 65536 taken, one more
// refused).
test("a model's output is capped where amr-link takes less than its catalog says (#827)", async () => {
const models = I.modelsOf({
data: [
{ id: "glm-5.3-flash", architecture: { input_modalities: ["text", "image", "video"] }, metadata: { cost: "low", capability: "advanced", context_limit: 1048000, context_budget: 232000 } },
{ id: "gemini-3.8-flash", architecture: { input_modalities: ["text"] }, metadata: { cost: "low", capability: "standard", context_limit: 1048576, context_budget: 264000 } },
// a catalog that says less than the cap is taken as it says
{ id: "deepseek-v4.1-flash", metadata: { context_limit: 1048000, context_budget: 232000 } },
],
})
expect(models["glm-5.3-flash"].limit).toEqual({ context: 1048000, output: 131072 })
expect(models["gemini-3.8-flash"].limit).toEqual({ context: 1048576, output: 65536 })
expect(models["deepseek-v4.1-flash"].limit.output).toBe(232000)
expect(I.modelsOf({ data: [{ id: "glm-5.3-flash", metadata: { context_budget: 100000 } }] })["glm-5.3-flash"].limit.output).toBe(100000)
// the seed, and a copy an earlier version kept with the catalog's number
const cfg = { provider: { opendesign: { models: { "gemini-3.8-flash": { id: "gemini-3.8-flash", name: "gemini-3.8-flash", limit: { context: 1048576, output: 264000 } } } } } }
await (await OpenDesignAuthPlugin({})).config(cfg)
const served = cfg.provider.opendesign.models
expect(served["glm-5.3-flash"].limit.output).toBe(131072)
expect(served["gemini-3.8-flash"].limit).toEqual({ context: 1048576, output: 65536 })
expect(served["deepseek-v4.1-flash"].limit.output).toBe(232000)
})
// #829 (exposir): the signed-in catalog's DeepSeek V4.1 Flash Eco entry
// left image out, so it was served text-only and magpie sent another model's
// description of the image instead, while amr-link took the image itself
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/opencode-opendesign-auth",
"version": "0.1.10",
"version": "0.1.11",
"description": "Open Design Cloud (Design Plan) in OpenCode and magpie: the account's device sign-in, its models, and the plan's 5-hour and 7-day allowance",
"type": "module",
"main": "./opencode.mjs",