trae 0.1.5: a model chat_v3 gives another model's name is named and asked as SOLO lists it (yetone/magpie#681, ChenstarMr: Trae's usage page booked magpie's DeepSeek V4.1 Flash as "DeepSeek-V4-Flash 正式版") — Trae CN's chat_v3 list names deepseek-v4.1-flash "DeepSeek-V4-Flash 正式版", the name it gives DeepSeek-V4-Flash-Official too, while solo_work_lite, solo_agent and solo_agent_lite name it DeepSeek-V4.1-Flash (the reporter's batch_get_detail_param answer). Both entries name the same upstream model, deepseek-v4.1-flash__dev, so the request reached V4.1 Flash, but the list showed two models with one name, and Trae's usage page booked the request under chat_v3's name (TraeCode), where SOLO's request was booked as DeepSeek-V4.1-Flash (TraeWork). liveModels now marks an entry misnamed when another model in the same list has its name and another list names it otherwise, and takes for each model the first function whose entry names a __dev model and isn't misnamed (else the first naming a __dev model, else the first, as before): deepseek-v4.1-flash is named DeepSeek-V4.1-Flash and asked through solo_work_lite with deepseek-v4.1-flash__dev, while DeepSeek-V4-Flash-Official, named alike everywhere, stays on chat_v3. usage.test.mjs gains the reporter's shape; it fails on 0.1.4 and passes; bun test (29 pass) and bun scripts/check.mjs trae pass. Not tried with a real Trae CN account (none here).

This commit is contained in:
yetone
2026-10-04 10:26:56 +08:00
parent a5f3321af3
commit d2449d53e6
3 changed files with 64 additions and 3 deletions
+25 -2
View File
@@ -930,7 +930,8 @@ export const TraeCNAuthPlugin = async ({ client }) => {
// The lists come from batch_get_detail_param, as TRAE SOLO CN asks them;
// when that gives none, from get_detail_param, one function at a time.
// A model several functions list is asked through the first whose entry
// names a __dev model (one Trae serves), else the first.
// names a __dev model (one Trae serves) and isn't misnamed, else the
// first that names one, else the first.
const liveModels = async (a) => {
let lists = null
try {
@@ -948,13 +949,35 @@ export const TraeCNAuthPlugin = async ({ client }) => {
if (g.status === "fulfilled") lists[FUNCTIONS[i]] = g.value
})
}
// a function can give a model another's name: chat_v3 calls
// 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.
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
for (const fn of FUNCTIONS) {
for (const m of lists[fn] ?? []) {
if (!chatModel(m)) continue
const id = String(m.config_name)
names.set(id, (names.get(id) ?? new Set()).add(nameOf(m)))
}
}
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) && 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)
const out = new Map()
for (const fn of FUNCTIONS) {
for (const m of lists[fn] ?? []) {
if (!chatModel(m)) continue
const id = String(m.config_name)
const was = out.get(id)
if (!was || (!devModel(was.m) && devModel(m))) out.set(id, { m, fn })
if (!was || worth(fn, m) > was.worth) out.set(id, { m, fn, worth: worth(fn, m) })
}
}
for (const [id, { m, fn }] of out) {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@magpie-community/opencode-trae-auth",
"version": "0.1.4",
"version": "0.1.5",
"description": "OpenCode provider plugin for Trae CN (trae.cn): your Trae CN account's models, free tier included, with Trae's own browser sign-in",
"type": "module",
"main": "./index.mjs",
+38
View File
@@ -173,3 +173,41 @@ test("when the list can't be read, the known models stand", async () => {
const p = await given(hooks)
expect(await hooks.provider.models(p, { auth: signedIn() })).toBe(p.models)
})
// as Trae CN answered the reporter (yetone/magpie#681): chat_v3 lists
// deepseek-v4.1-flash with its __dev model but under DeepSeek-V4-Flash-Official's
// name, and Trae's usage page books it under that name; SOLO's lists name it
// DeepSeek-V4.1-Flash
const SAME_NAME = { function_configs: [
{ function: "chat_v3", config_info_list: [
{ config_name: "deepseek-v4.1-flash", usage: "chat_completion", display_config: { display_name: "DeepSeek-V4-Flash 正式版" }, model_detail_list: [{ model_name: "deepseek-v4.1-flash__dev" }, { model_name: "deepseek-v4.1-flash__max" }] },
{ 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" }] },
] },
{ function: "solo_work_lite", config_info_list: [
{ config_name: "deepseek-v4.1-flash", usage: "chat_completion", display_config: { display_name: "DeepSeek-V4.1-Flash" }, model_detail_list: [{ model_name: "deepseek-v4.1-flash__dev" }] },
{ 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" }] },
] },
{ function: "solo_agent", config_info_list: [
{ config_name: "deepseek-v4.1-flash", usage: "chat_completion", display_config: { display_name: "DeepSeek-V4.1-Flash" }, model_detail_list: [{ model_name: "deepseek-v4.1-flash__dev" }] },
] },
] }
test("a model chat_v3 gives another's name is named and asked as SOLO lists it (yetone/magpie#681)", async () => {
f = fakeTrae()
f.route("POST /api/ide/v1/batch_get_detail_param", () => json(SAME_NAME))
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-Flash-Official"].name).toBe("DeepSeek-V4-Flash 正式版")
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, messages: [{ role: "user", content: "hi" }] }) })
return (await res.json()).choices[0].message.content
}
// the first list that names it rightly, with its __dev model
expect(await ask("deepseek-v4.1-flash")).toBe("solo_work_lite deepseek-v4.1-flash__dev")
// named alike everywhere: kept on chat_v3, as before
expect(await ask("DeepSeek-V4-Flash-Official")).toBe("chat_v3 DeepSeek-V4-Flash-Official__dev")
})