trae 0.2.43: an enterprise model's chat sends its detail's model_name and provider (#1258)
On 0.2.42 the reporter's enterprise seat (@liuyuexue2020 on X, Trae CN,
console.enterprise.trae.cn) got past 4001: both of its enterprise models,
AI/deekseek-v4.1-flash and volc/deepseek-v4-1-flash, now got 502 with
Trae's 4023 "We're sorry, something went wrong. Please try again later or
contact our support team for assistance." on chat_v3, solo_work_lite,
solo_agent, solo_agent_lite and solo_coder (their two screenshots on
#1258). config_source 2 was accepted; what the server then needed was
missing.
Trae CN 3.4.20's list types (libharness, serde field order) are
CloudModelConfigInfo { usage, is_default, display_config, ...,
model_detail_list, config_source, ... } and CloudModelDetailInfo
{ model_name, provider, icon, prompt_max_tokens, max_tokens, ... }:
provider sits on each model_detail_list item, not on the config. 0.2.42
read entry.provider off the config (so sent none), and model_name comes
only from a __dev detail, which an enterprise model doesn't have (so
none was sent either). Trae's own llm_utils_chat sends config_name,
model_name, config_source, is_custom_model and provider.
chatBody now sends, for an enterprise model, the model_name and provider
of its detail (the __dev one if any, else the first naming a model),
the config's provider still first when present. A preset's body is
unchanged.
Run (mote, HOME=$(mktemp -d), at this tree on 50f1ec18):
packages/trae bun test, 284 pass, 0 fail (24 files);
bun scripts/check.mjs trae ok.
Broken by hand: with 0.2.42's index.mjs, the two new entmodels tests
fail (the fake answers the reporter's 4023 text to an enterprise chat
without its detail's model_name and provider); the other five pass.
Not tried: a real enterprise seat; we have none, and the reporter can't
capture the list entry or the chat (the native ai-agent process sends
them). The detail values in the fixture (provider "AI"/"volc") are
inferred from their config names; the real entry hasn't been seen.
This commit is contained in:
@@ -246,11 +246,13 @@ custom-model slots. An enterprise's own built-in models
|
||||
since 0.2.41 (#1258), unless the admin switched one off (`status` false); a
|
||||
personal custom model (`config_source` 3) is not, its key being in the
|
||||
user's IDE only. A chat with an enterprise model carries `config_source`
|
||||
2, `is_custom_model` true and the entry's `provider` at the top of the
|
||||
body, as Trae CN 3.4.20's own `llm_utils_chat` request does (0.2.42; 0.2.41
|
||||
2, `is_custom_model` true, and the `model_name` and `provider` of its
|
||||
`model_detail_list` entry (its `__dev` one, else the first) at the top of the
|
||||
body, as Trae CN 3.4.20's own `llm_utils_chat` request does (0.2.43; 0.2.41
|
||||
put them under `user_message_context.model_info`, and an enterprise seat got
|
||||
4001 "the param is invalid" on every function) — **not verified with a real
|
||||
enterprise seat**. A refused chat's error names
|
||||
4001 "the param is invalid" on every function; 0.2.42 read `provider` off the
|
||||
config, where Trae's list doesn't carry it, sent no `model_name`, and got
|
||||
4023 "something went wrong") — **not verified with a real enterprise seat**. A refused chat's error names
|
||||
the model, the functions tried and the host, and says when the account's
|
||||
list doesn't have the model. Context is the list's `context_window_tokens.dev`,
|
||||
output the `__dev` model's `max_tokens`. A model with a `__max` model and
|
||||
|
||||
@@ -98,3 +98,51 @@ test("a refused chat names the model, the functions tried and the host", async (
|
||||
expect(msg).toContain("model Acme-Qwen-72B asked through chat_v3")
|
||||
expect(msg).toContain("this account's model list doesn't have Acme-Qwen-72B")
|
||||
})
|
||||
|
||||
// the reporter's next error (#1258, 0.2.42, console.enterprise.trae.cn): with
|
||||
// config_source sent, both of their enterprise models got 4023 on every
|
||||
// function. Trae's list types carry provider and model_name on each
|
||||
// model_detail_list item, not on the config, and 0.2.42 sent neither. The
|
||||
// entries' detail values are inferred from the config names they gave
|
||||
// (provider/model); their real list entry hasn't been seen.
|
||||
const WENT_WRONG = "We're sorry, something went wrong. Please try again later or contact our support team for assistance."
|
||||
const listed = [
|
||||
{ config_name: "AI/deekseek-v4.1-flash", usage: "chat_completion", config_source: 2, is_preset: false, is_custom_model: true, status: true,
|
||||
display_config: { display_name: "deekseek-v4.1-flash", is_custom_model: true },
|
||||
model_detail_list: [{ model_name: "deekseek-v4.1-flash", provider: "AI", max_tokens: 8192 }] },
|
||||
{ config_name: "volc/deepseek-v4-1-flash", usage: "chat_completion", config_source: 2, is_preset: false, is_custom_model: true, status: true,
|
||||
display_config: { display_name: "deepseek-v4-1-flash", is_custom_model: true },
|
||||
model_detail_list: [{ model_name: "deepseek-v4-1-flash", provider: "volc", max_tokens: 8192 }] },
|
||||
]
|
||||
|
||||
test("a chat with an enterprise model sends its detail's model_name and provider", async () => {
|
||||
const hooks = await plugin([preset, ...listed])
|
||||
await hooks.provider.models({ models: {} }, { auth: signedIn() })
|
||||
// Trae as the reporter met it on 0.2.42: an enterprise config without the
|
||||
// model and provider it is served by went wrong
|
||||
f.route("POST /api/agent/v3/llm_utils_chat", (r) => {
|
||||
const e = listed.find((m) => m.config_name === r.json.config_name)
|
||||
const d = e?.model_detail_list[0]
|
||||
if (e && (r.json.model_name !== d.model_name || r.json.provider !== d.provider)) return sse([["error", { code: 4023, message: WENT_WRONG }]])
|
||||
return sse([["output", { response: "ok" }], ["done", {}]])
|
||||
})
|
||||
const opts = await hooks.auth.loader(async () => signedIn())
|
||||
for (const m of listed) {
|
||||
const res = await opts.fetch(opts.baseURL + "/chat/completions", { method: "POST", body: JSON.stringify({ model: m.config_name, messages: [{ role: "user", content: "hi" }] }) })
|
||||
expect(res.status).toBe(200)
|
||||
expect((await res.json()).choices[0].message.content).toBe("ok")
|
||||
}
|
||||
const chats = f.seen.filter((r) => r.path === "/api/agent/v3/llm_utils_chat")
|
||||
expect(chats.length).toBe(2)
|
||||
expect(chats[0].json).toMatchObject({ config_name: "AI/deekseek-v4.1-flash", config_source: 2, is_custom_model: true, model_name: "deekseek-v4.1-flash", provider: "AI" })
|
||||
expect(chats[1].json).toMatchObject({ config_name: "volc/deepseek-v4-1-flash", config_source: 2, is_custom_model: true, model_name: "deepseek-v4-1-flash", provider: "volc" })
|
||||
})
|
||||
|
||||
test("an enterprise model's __dev detail is the one asked by; a preset's body gains nothing", () => {
|
||||
const two = { ...listed[1], model_detail_list: [{ model_name: "deepseek-v4-1-flash__max", provider: "volc" }, { model_name: "deepseek-v4-1-flash__dev", provider: "volc" }] }
|
||||
const body = _internal.chatBody({ model: two.config_name, messages: [{ role: "user", content: "hi" }] }, "chat_v3", "", 0, null, "s", false, null, two)
|
||||
expect(body.model_name).toBe("deepseek-v4-1-flash__dev")
|
||||
expect(body.provider).toBe("volc")
|
||||
const p = _internal.chatBody({ model: "glm-5", messages: [{ role: "user", content: "hi" }] }, "chat_v3", "", 0, null, "s", false, null, preset)
|
||||
for (const k of ["model_name", "provider", "config_source", "is_custom_model"]) expect(k in p).toBe(false)
|
||||
})
|
||||
|
||||
+16
-1
@@ -1649,10 +1649,22 @@ function chatBody(req, fn, modelName, most = 0, max = null, session = "", sees =
|
||||
// under user_message_context.model_info, the agent task's shape). Not yet
|
||||
// seen answering from a real enterprise seat: a Trae preset is sent as
|
||||
// before.
|
||||
//
|
||||
// model_name and provider are the entry's model detail's: Trae's list
|
||||
// types (libharness CloudModelConfigInfo / CloudModelDetailInfo) carry
|
||||
// provider on each model_detail_list item, beside its model_name, and
|
||||
// not on the config, and an enterprise model's detail has no __dev name
|
||||
// for modelName to come from. 0.2.42 read provider off the config and
|
||||
// sent no model_name, so both were missing, and the reporter's seat got
|
||||
// 4023 "We're sorry, something went wrong" on every function (#1258,
|
||||
// AI/deekseek-v4.1-flash and volc/deepseek-v4-1-flash).
|
||||
if (enterpriseModel(entry)) {
|
||||
body.config_source = ENTERPRISE
|
||||
body.is_custom_model = true
|
||||
if (entry.provider) body.provider = String(entry.provider)
|
||||
const detail = enterpriseDetail(entry)
|
||||
if (!body.model_name && detail?.model_name) body.model_name = String(detail.model_name)
|
||||
const provider = entry.provider || detail?.provider
|
||||
if (provider) body.provider = String(provider)
|
||||
}
|
||||
if (typeof req.temperature === "number") body.temperature = req.temperature
|
||||
if (Array.isArray(req.tools) && req.tools.length && req.tool_choice !== "none") {
|
||||
@@ -3085,6 +3097,9 @@ const wrongFunction = (code) => ["4001", "4023", "1005"].includes(String(code))
|
||||
// One the admin switched off (status false) stays out, as in the IDE.
|
||||
const ENTERPRISE = 2
|
||||
const enterpriseModel = (m) => Number(m?.config_source) === ENTERPRISE
|
||||
// enterpriseDetail is the model detail an enterprise model is asked by: its
|
||||
// __dev one when it names one, else the first that names a model
|
||||
const enterpriseDetail = (m) => devModel(m) ?? (Array.isArray(m?.model_detail_list) ? m.model_detail_list : []).find((d) => d?.model_name)
|
||||
function chatModel(m, site) {
|
||||
const id = String(m?.config_name ?? "")
|
||||
if (!id) return false
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@magpie-community/opencode-trae-auth",
|
||||
"version": "0.2.42",
|
||||
"version": "0.2.43",
|
||||
"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": "./opencode.mjs",
|
||||
|
||||
Reference in New Issue
Block a user