Files
plugins/packages
yetone ea805ecc92 trae 0.2.45: an enterprise chat names its limit where Trae's client does, and a cut reply says length
@liuyuexue2020 on X (0.2.44, Trae CN enterprise seat): their own request,
volc/deepseek-v4-1-flash with max_tokens 4096, temperature 0, stream
false, asking for 120 long lines. Four enterprise models
(AI/deekseek-v4.1-flash, volc/deepseek-v4-1-flash,
AI/deekseek-v4-flash-0731, AI/GLM-5.3-Flash) each answered exactly 2000
completion tokens, finish_reason "stop", mid-answer (24, 27 and 52 of
120 lines; deekseek-v4.1-flash no content at all).

What 0.2.44 sent: top-level max_tokens = min(4096, the detail's
max_tokens), so 4096 unless the list gives the model less. magpie's
gateway only lowers a limit (the user's Max output, withMaxOutput) and
fills one in on the Anthropic API only (askedOutput); it has no 2000.
The plugin passes Trae's completion_tokens and finish_reason through, and
reads the stream to Trae's done event; it doesn't cut it.

Cause (inferred, no enterprise seat to measure): Trae CN 3.4.22's own
client never sends llm_utils_chat a max_tokens (its request struct in
libharness has none), and its agent task carries an enterprise model's
limit as enterprise_custom_hyper_params {max_tokens, prompt_max_tokens,
multimodal} beside config_source and is_custom_model (AgentSpec,
CreateTaskRequest). So Trae most likely ignores the top-level max_tokens
for an enterprise model and gives it 2000, and says "stop" when it cuts.
The other reading, the list giving these models max_tokens 2000, would
show as 2000 output in /v1/models; the reporter is asked for it.

Now:
- an enterprise model's chat also sends enterprise_custom_hyper_params
  (max_tokens as sent, the detail's prompt_max_tokens, multimodal from
  the list) when a limit is known; the top-level max_tokens stays. A
  preset gets nothing new.
- a reply Trae ends with "stop" or no reason, having used every token it
  was let have (the max_tokens sent, or 2000 for an enterprise model),
  finishes "length" in a body and in a stream, so the agent knows it was
  cut. Tool calls, content_filter and shorter replies are unchanged; a
  preset's 2000 isn't taken for a cut.

Tests (entmodels.test.mjs), from the reporter's request: a fake Trae
that reads the limit from enterprise_custom_hyper_params only and cuts
at 2000 with "stop". On 0.2.44's index.mjs all three new tests are red
(3100 expected, 2000 received; "length" expected, "stop" received).

Not tried: a real enterprise seat (none here). Whether Trae honours
enterprise_custom_hyper_params on llm_utils_chat is read from the
binary, not measured; if it doesn't, the reply is still cut at 2000 but
now says length.

Siblings: Trae CN and Trae international share chatBody and openai();
SOLO functions too.

Run (mica, HOME=$(mktemp -d), this tree on 67fb1258; mote was over its
cores):
packages/trae bun test: 290 pass, 0 fail (24 files);
bun scripts/check.mjs trae: ok;
root bun test: 9060 pass, 3 fail, 20 skip (636 files, 533s). The 3 reds
are in untouched packages and pass alone at once (agent-office jump.test
12/12, doubao-work 59/59): agent-office's jumpRequest is #642,
doubao-work's two are filed as #1350.
Broken by hand: 0.2.44's index.mjs with these tests, 3 of 13 red in
entmodels.test.mjs (above).
2026-11-19 13:57:20 +08:00
..
middleware: param-override, model-map, system-prompt, word-guard and think-tags — gateway middleware that magpie runs on every agent's requests and replies, mostly New API's channel settings with the same JSON (the owner) — magpie can now run a plugin as gateway middleware (onRequest, onEvent, onResponse, in-process on moejs), and these are the first ones: param-override is New API's param_override (both forms, operations with gjson paths and conditions, return_error); model-map is model_mapping (chains, /regex/ keys with $1) and puts the asked-for name back into replies; system-prompt adds a prompt in each API's own place, keeping an agent's own unless override (New API's semantics), by agent or model; word-guard is the sensitive-word filter (reject or mask the user's text, optionally replies); think-tags strips a leading <think>…</think> from replies across stream chunks, or puts Chat reasoning_content into the text (thinking_to_content). Each is one file with no imports, named @magpie-community/middleware-<name>, with magpie.options as the example the app's editor starts from; registry.json lists them with "kind": "middleware" and no providers; check.mjs skips middleware-only packages. scripts/middleware.mjs calls the hooks as the gateway does (events split, [DONE] passed by) and runs each package's cases.json. Tested with a real DeepSeek account and real Claude Code through magpie's gateway: a mapped model named back in message_start, max_tokens capped, a system prompt appended for claude only, a word turned away as a 400 in Anthropic's shape, return_error as a 403 in Chat's, <think> stripped from Chat and Responses streams and an Anthropic whole reply, reasoning_content moved into the text. bun test (61 for these five) and bun scripts/check.mjs pass; packages/devin's two image tests fail on this machine only, as on main. Their first npm version has to be published by hand (trusted publishing can't create a package); until then magpie shows them as Coming soon.
2026-10-05 20:49:42 +08:00