trae 0.2.23: a model whose entry names max (or medium) offers it and sends it (#434)

huajii (#434): Trae's app offers DeepSeek V4.1 Flash at max, the plugin
does not.

Cause: LEVELS knew only light/high/extra_high, so levelsOf dropped any
other option an entry's reasoning_effort_config names, and effortOf never
sent it. Trae's client names five levels (its bundle's
reasoning_effort.{low,medium,high,extra_high,max}, handed out per model by
remote config, per dsh-connect-trae #60's read of the client bundle). An
entry naming max beside the three lost it.

Fix: LEVELS spells medium and max as themselves. They are offered only
for a model whose entry names them, and a model that names none still
sends nothing for them.

Run:
- packages/trae: bun test 215 pass, 0 fail. The two new tests in
  reasoning.test.mjs (levels/variants/chatBody with max and medium; max
  reaching llm_utils_chat through the loader's fetch) were red on the old
  LEVELS line (2 fail, max undefined), green with it.
- HOME=$(mktemp -d) bun test at the repo root: 2902 pass, 3 skip, 0 fail;
  bun scripts/check.mjs: ok.

Not tried: a real Trae account. The wire name "max" in options comes from
the client's i18n keys, not a captured list; on 10-25 a live CN list named
only light/high/extra_high (dsh-connect-trae #60, plugins #300). If Trae's
"max" in the app is the Max mode instead, the plugin's
deepseek-v4.1-flash-max model is that and is unchanged here.
This commit is contained in:
yetone
2026-10-28 00:46:08 +08:00
parent 214530edad
commit c20fa331a0
4 changed files with 44 additions and 4 deletions
+3 -1
View File
@@ -231,7 +231,9 @@ which levels it takes — its `reasoning_effort_config`, with the options
(`light`, `high`, `extra_high`) and the default. The request takes the same (`light`, `high`, `extra_high`) and the default. The request takes the same
names as `reasoning_effort`, so a level an agent picks is sent as Trae names as `reasoning_effort`, so a level an agent picks is sent as Trae
spells it: the plugin offers each model's own levels as `variants` spells it: the plugin offers each model's own levels as `variants`
(`low`/`high`/`xhigh` for `light`/`high`/`extra_high`), and sends nothing (`low`/`high`/`xhigh` for `light`/`high`/`extra_high`; `medium` and `max`
keep their names, offered only where the entry names them, as for DeepSeek
V4.1 Flash's `max` in Trae's app), and sends nothing
for a level the model doesn't name, or for a model whose entry names none — for a level the model doesn't name, or for a model whose entry names none —
Trae then serves it at its own default. An entry naming levels this map Trae then serves it at its own default. An entry naming levels this map
can't spell offers none, rather than being sent one Trae would reject. A can't spell offers none, rather than being sent one Trae would reject. A
+5 -2
View File
@@ -2593,13 +2593,16 @@ const MAX = "-max"
// (light, high, extra_high) and the one it defaults to. The request takes the // (light, high, extra_high) and the one it defaults to. The request takes the
// same names, as reasoning_effort, so a level an agent picks is sent as Trae // same names, as reasoning_effort, so a level an agent picks is sent as Trae
// spells it. OpenCode knows the three as low/high/xhigh, so the map goes both // spells it. OpenCode knows the three as low/high/xhigh, so the map goes both
// ways. // ways. Trae's client names two more, medium and max (its bundle's
// reasoning_effort.{low,medium,high,extra_high,max}), handed out per model:
// its app offers DeepSeek V4.1 Flash max (#434), so they are spelled here too,
// and still offered only for a model whose entry names them.
// //
// An entry without the config takes no level: Trae serves it at its own // An entry without the config takes no level: Trae serves it at its own
// default and nothing is sent. The plugin used to send none for every model, // default and nothing is sent. The plugin used to send none for every model,
// which read as "Trae takes no level" — it takes them, per model, and an // which read as "Trae takes no level" — it takes them, per model, and an
// entry that names none is the exception rather than the rule. // entry that names none is the exception rather than the rule.
const LEVELS = { light: "low", high: "high", extra_high: "xhigh" } const LEVELS = { light: "low", medium: "medium", high: "high", extra_high: "xhigh", max: "max" }
// levelsOf is an entry's levels in OpenCode's names, in Trae's order: [] when // levelsOf is an entry's levels in OpenCode's names, in Trae's order: [] when
// the entry names none, null when it names ones this map can't spell (so a // the entry names none, null when it names ones this map can't spell (so a
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@magpie-community/opencode-trae-auth", "name": "@magpie-community/opencode-trae-auth",
"version": "0.2.22", "version": "0.2.23",
"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", "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", "type": "module",
"main": "./index.mjs", "main": "./index.mjs",
+35
View File
@@ -50,6 +50,41 @@ test("an entry's levels are offered as the variants agents pick, named as OpenCo
expect(m.capabilities.reasoning).toBe(true) expect(m.capabilities.reasoning).toBe(true)
}) })
// Trae's client names five levels (its bundle's
// reasoning_effort.{low,medium,high,extra_high,max}), handed out per model.
// Its app offers DeepSeek V4.1 Flash max (#434, huajii); a list naming max
// beside light/high/extra_high lost it, so no agent could pick it.
test("max and medium an entry names are offered and sent as Trae names them (#434)", async () => {
expect(levelsOf({ reasoning_effort_config: { options: ["light", "high", "extra_high", "max"] } })).toEqual(["low", "high", "xhigh", "max"])
expect(levelsOf({ reasoning_effort_config: { options: ["light", "medium", "high"] } })).toEqual(["low", "medium", "high"])
const ms = await live([entry("deepseek-v4.1-flash", ["light", "high", "extra_high", "max"], { default_level: "high" })])
expect(Object.keys(ms["deepseek-v4.1-flash"].variants)).toEqual(["low", "high", "xhigh", "max"])
expect(ms["deepseek-v4.1-flash"].variants.max).toEqual({ reasoningEffort: "max" })
const req = (effort) => ({ model: "deepseek-v4.1-flash", messages: [{ role: "user", content: "hi" }], reasoning_effort: effort })
const levels = ["low", "medium", "high", "xhigh", "max"]
expect(chatBody(req("max"), "chat_v3", "", 0, null, "s", false, levels).reasoning_effort).toBe("max")
expect(chatBody(req("medium"), "chat_v3", "", 0, null, "s", false, levels).reasoning_effort).toBe("medium")
// a model that names no max still sends nothing for it
expect(chatBody(req("max"), "chat_v3", "", 0, null, "s", false, ["low", "high", "xhigh"]).reasoning_effort).toBeUndefined()
})
test("max reaches Trae's request for a model whose entry names it (#434)", async () => {
f = fakeTrae()
f.route("POST /api/ide/v1/batch_get_detail_param", () => json({ function_configs: [
{ function: "chat_v3", config_info_list: [entry("deepseek-v4.1-flash", ["light", "high", "extra_high", "max"], { default_level: "high" })] },
] }))
f.route("POST /api/agent/v3/llm_utils_chat", () => sse([["output", { content: "ok" }], ["finish", { finish_reason: "stop" }]]))
const hooks = await TraeCNAuthPlugin({ client: {} })
const opts = await hooks.auth.loader(async () => signedIn())
await opts.fetch(opts.baseURL + "/chat/completions", {
method: "POST",
headers: { "content-type": "application/json" },
body: JSON.stringify({ model: "deepseek-v4.1-flash", stream: true, messages: [{ role: "user", content: "hi" }], reasoning_effort: "max" }),
})
const sent = f.seen.find((r) => r.path === "/api/agent/v3/llm_utils_chat")
expect(sent.json.reasoning_effort).toBe("max")
})
test("an entry with no levels carries no variants: Trae serves it at its own default", async () => { test("an entry with no levels carries no variants: Trae serves it at its own default", async () => {
const ms = await live([entry("glm-5.3", undefined)]) const ms = await live([entry("glm-5.3", undefined)])
expect(ms["glm-5.3"].variants).toEqual({}) expect(ms["glm-5.3"].variants).toEqual({})