From 3e6a8d0e03249733a8c7e2633b6df9257fdb1d7e Mon Sep 17 00:00:00 2001 From: tearslee Date: Fri, 9 Oct 2026 22:32:20 +0800 Subject: [PATCH] trae: a model keeps the name its lists agree on (#62) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Trae's usage page books a request under the name of the list it was served through, and its lists name a model differently: chat_v3 calls deepseek-v4.1-flash "DeepSeek-V4-Flash 正式版", where the SOLO lists call it "DeepSeek-V4.1-Flash" (yetone/magpie#681). On 2026-10-09 Trae renamed its official entries — DeepSeek-V4-Flash-Official is "DeepSeek-V4-Flash" now — which left chat_v3 the only list still calling deepseek-v4.1-flash by another's name, so the collision the misnamed test leans on no longer matches and chat_v3's entry won on list order alone: the page then showed "DeepSeek-V4-Flash 正式版" for every request, where Trae's own client, served through a SOLO list, shows "DeepSeek-V4.1-Flash". A model's name is now the one most of its lists give it — the name Trae's own client is served under — and the entry carrying it is preferred for the model's window, reply limit and serving function, as is the Max entry asked for it. deepseek-v4.1-flash goes back to "DeepSeek-V4.1-Flash", a 200K window and a 32K reply limit (was 116K/16K from chat_v3's entry), asked through the SOLO list that names its __dev/__max models. Co-authored-by: 李 --- packages/trae/README.md | 10 ++++++++- packages/trae/index.mjs | 37 +++++++++++++++++++++++++-------- packages/trae/package.json | 2 +- packages/trae/usage.test.mjs | 40 ++++++++++++++++++++++++++++++++++++ 4 files changed, 78 insertions(+), 11 deletions(-) diff --git a/packages/trae/README.md b/packages/trae/README.md index a40ecc9..00df3c5 100644 --- a/packages/trae/README.md +++ b/packages/trae/README.md @@ -138,7 +138,15 @@ a bigger `context_window_tokens.max` is listed again as its Max, can name the `__max` model, a SOLO list the windows). It asks the `__max` model through the function that names it, with `max_tokens` set and `user_message_context.model_info.prompt_max_tokens` the window less -it, as Max mode does. +it, as Max mode does. The lists needn't agree on a model's *name*: chat_v3 +calls deepseek-v4.1-flash "DeepSeek-V4-Flash 正式版", as it once called +DeepSeek-V4-Flash-Official, where the SOLO lists call it +"DeepSeek-V4.1-Flash" (yetone/magpie#681). Trae's usage page books a +request under the name of the list it was served through, so the plugin +takes the name most of a model's lists give — the one Trae's own client is +served under — and asks that model, and its Max, through a list carrying +it. Trae renamed its official entries on 2026-10-09, leaving the name its +lists mostly agree on the only thing that tells a misnamed entry apart. Reasoning: the models reason, but Trae's request takes no effort or thinking level, so the plugin lists no variants and a level an agent diff --git a/packages/trae/index.mjs b/packages/trae/index.mjs index 8e1bb77..a7a44cd 100644 --- a/packages/trae/index.mjs +++ b/packages/trae/index.mjs @@ -2042,24 +2042,40 @@ const makePlugin = (site) => async ({ client }) => { // deepseek-v4.1-flash "DeepSeek-V4-Flash 正式版", as it does // DeepSeek-V4-Flash-Official, where SOLO's lists call it // DeepSeek-V4.1-Flash (yetone/magpie#681) — Trae's usage page then books - // it under that name too. Such an entry is misnamed: its name is another - // model's in the same list, and other lists name it otherwise. + // a request under the name of the list it was served through. Such an + // entry is misnamed: its name is another model's in the same list, and + // other lists name it otherwise. const nameOf = (m) => String(m.display_config?.display_name || m.display_name || m.display_model_name || m.config_name) - const names = new Map() // id → the names its lists give it + const names = new Map() // id → the names its lists give it, and how many give each for (const fn of site.functions) { for (const m of lists[fn] ?? []) { if (!chatModel(m, site)) continue - const id = String(m.config_name) - names.set(id, (names.get(id) ?? new Set()).add(nameOf(m))) + const id = String(m.config_name), name = nameOf(m) + const by = names.get(id) ?? new Map() + by.set(name, (by.get(name) ?? 0) + 1) + names.set(id, by) } } + // the name most of a model's lists give it: the one Trae's own client is + // served under, and so the one its usage page books it as. Trae renames + // entries when it likes, and its 2026-10-09 rename of + // DeepSeek-V4-Flash-Official left chat_v3 the only list still calling + // deepseek-v4.1-flash by another's name — which neither signal above + // catches. A tie leaves the name to its entry. + const agreed = new Map() // id → that name, "" when the lists tie + for (const [id, by] of names) { + const top = Math.max(...by.values()) + const most = [...by].filter(([, n]) => n === top) + agreed.set(id, most.length === 1 ? most[0][0] : "") + } const misnamed = (fn, m) => { const id = String(m.config_name), name = nameOf(m) return names.get(id).size > 1 && (lists[fn] ?? []).some((o) => chatModel(o, site) && String(o.config_name) !== id && nameOf(o) === name) } // a function's entry is worth more when it names a __dev model, then - // when it isn't misnamed; the first of the best is taken - const worth = (fn, m) => (devModel(m) ? 2 : 0) + (misnamed(fn, m) ? 0 : 1) + // when it isn't misnamed, then when it carries the name its lists agree + // on; the first of the best is taken + const worth = (fn, m) => (devModel(m) ? 2 : 0) + (misnamed(fn, m) ? 0 : 1) + (nameOf(m) === agreed.get(String(m.config_name)) ? 1 : 0) const out = new Map() for (const fn of site.functions) { for (const m of lists[fn] ?? []) { @@ -2075,8 +2091,11 @@ const makePlugin = (site) => async ({ client }) => { if (dev) modelNames.set(id, { fn, name: dev.model_name, most: Number(dev.max_tokens) || 0 }) else modelNames.delete(id) if (out.has(id + MAX)) continue - // its Max is asked through the function whose entry names the __max model - const entries = [{ m, fn }, ...site.functions.flatMap((f) => (lists[f] ?? []).filter((o) => o !== m && chatModel(o, site) && String(o.config_name) === id).map((o) => ({ m: o, fn: f })))] + // its Max is asked through the function whose entry names the __max + // model, the entries carrying the agreed name first: Trae books the + // Max under that name too + const plain = (e) => (nameOf(e.m) === agreed.get(id) ? 0 : 1) + const entries = [{ m, fn }, ...site.functions.flatMap((f) => (lists[f] ?? []).filter((o) => o !== m && chatModel(o, site) && String(o.config_name) === id).map((o) => ({ m: o, fn: f })))].sort((a, b) => plain(a) - plain(b)) const max = maxModel(...entries.map((e) => e.m)) maxes.set(id, max) if (max) { diff --git a/packages/trae/package.json b/packages/trae/package.json index e2590b2..5b8b19c 100644 --- a/packages/trae/package.json +++ b/packages/trae/package.json @@ -1,6 +1,6 @@ { "name": "@magpie-community/opencode-trae-auth", - "version": "0.2.6", + "version": "0.2.7", "description": "OpenCode provider plugins for Trae: Trae CN (trae.cn) and Trae Global (trae.ai), free tier included, with Trae's own browser sign-in", "type": "module", "main": "./index.mjs", diff --git a/packages/trae/usage.test.mjs b/packages/trae/usage.test.mjs index 5b24fe8..4c89f81 100644 --- a/packages/trae/usage.test.mjs +++ b/packages/trae/usage.test.mjs @@ -214,6 +214,46 @@ test("a model chat_v3 gives another's name is named and asked as SOLO lists it ( expect(await ask("DeepSeek-V4-Flash-Official")).toBe("chat_v3 DeepSeek-V4-Flash-Official__dev") }) +// what Trae CN answered on 2026-10-09, after it renamed its official entries +// (DeepSeek-V4-Flash-Official is "DeepSeek-V4-Flash" there now): chat_v3 is +// the only list still calling deepseek-v4.1-flash by another's name, and +// nothing in it carries that name any more, so the collision the case above +// leans on is gone. The name the lists mostly give is the one Trae's own +// client is served under, and the one its usage page books: the model is +// named, limited and asked as the three SOLO lists have it. +const RENAMED = { function_configs: [ + { function: "chat_v3", config_info_list: [ + { config_name: "deepseek-v4.1-flash", usage: "chat_completion", display_config: { display_name: "DeepSeek-V4-Flash 正式版" }, context_window_tokens: { dev: 116000, max: 1000000 }, model_detail_list: [{ model_name: "deepseek-v4.1-flash__dev", max_tokens: 16000 }, { model_name: "deepseek-v4.1-flash__max", max_tokens: 64000 }] }, + { config_name: "DeepSeek-V4-Flash-Official", usage: "chat_completion", display_config: { display_name: "DeepSeek-V4-Flash" }, model_detail_list: [{ model_name: "DeepSeek-V4-Flash-Official__dev", max_tokens: 16000 }] }, + ] }, + { function: "solo_work_lite", config_info_list: [ + { config_name: "deepseek-v4.1-flash", usage: "chat_completion", display_config: { display_name: "DeepSeek-V4.1-Flash" }, context_window_tokens: { dev: 200000 }, model_detail_list: [{ model_name: "deepseek-v4.1-flash__dev", max_tokens: 32000 }] }, + ] }, + { function: "solo_agent", config_info_list: [ + { config_name: "deepseek-v4.1-flash", usage: "chat_completion", display_config: { display_name: "DeepSeek-V4.1-Flash" }, context_window_tokens: { dev: 200000, max: 1000000 }, model_detail_list: [{ model_name: "deepseek-v4.1-flash__dev", max_tokens: 32000 }, { model_name: "deepseek-v4.1-flash__max", max_tokens: 64000 }] }, + ] }, +] } + +test("a model whose lists mostly name it alike keeps that name, its limit and its function after Trae renames another", async () => { + f = fakeTrae() + f.route("POST /api/ide/v1/batch_get_detail_param", () => json(RENAMED)) + f.route("POST /api/agent/v3/llm_utils_chat", (r) => sse([["output", { response: r.json.function + " " + (r.json.model_name ?? "-") }], ["done", {}]])) + const hooks = await TraeCNAuthPlugin({ client: {} }) + const p = await given(hooks) + const live = await hooks.provider.models(p, { auth: signedIn() }) + expect(live["deepseek-v4.1-flash"].name).toBe("DeepSeek-V4.1-Flash") + expect(live["deepseek-v4.1-flash"].limit).toEqual({ context: 200000, output: 32000 }) + expect(live["deepseek-v4.1-flash-max"].name).toBe("DeepSeek-V4.1-Flash (Max)") + const opts = await hooks.auth.loader(async () => signedIn()) + const ask = async (model) => { + const res = await opts.fetch(opts.baseURL + "/chat/completions", { method: "POST", body: JSON.stringify({ model, max_tokens: 64000, messages: [{ role: "user", content: "hi" }] }) }) + return (await res.json()).choices[0].message.content + } + // both asked through the SOLO lists, with the __dev/__max models they name + expect(await ask("deepseek-v4.1-flash")).toBe("solo_work_lite deepseek-v4.1-flash__dev") + expect(await ask("deepseek-v4.1-flash-max")).toBe("solo_agent deepseek-v4.1-flash__max") +}) + // ARNO on magpie's Discord: Trae CN's DeepSeek V4.1 Flash said a 32K reply // limit, one Trae never gave: a model whose list names no max_tokens says // none (0), and magpie tells agents models.dev's. One Trae gives is kept,