Files
plugins/packages
yetone 8989cc1d92 trae 0.2.44: a chat is sent its model's max_tokens, so an enterprise reply isn't cut at 2000
@liuyuexue2020 on X (0.2.43, Trae CN enterprise seat, console.enterprise.trae.cn,
model AI/deekseek-v4.1-flash): in Trae the model writes past 2000 tokens;
through magpie every reply stopped at exactly 2,000 output tokens (their
Usage rows: 26,037 / 2,000, 24,870 / 2,000, 23,097 / 2,000, streamed).

Cause: chatBody sent max_tokens only when the agent named one, held to the
__dev detail's max_tokens (`most`). An enterprise model has no __dev
detail, so it had no `most`, its listed output limit was 0, and an agent
naming no limit sent llm_utils_chat none. Trae's own client always sends
one: the ai-agent's ModelConfig carries the detail's max_tokens with every
model ("[ModelConfig] Received config_name=, model_name=, max_turn=,
prompt_max_tokens=, max_tokens=" in Trae CN 3.4.20's ai-agent strings;
CloudModelDetailInfo has max_tokens beside model_name and provider). The
2000 is most likely what Trae gives a request naming none; that wasn't
measured, having no seat.

Now:
- an enterprise model's `most` and listed output come from its own detail
  (enterpriseDetail: the __dev one, else the first naming a model);
- every chat whose model has a known `most` sends it when the agent names
  no limit, and holds a larger ask to it, as Max mode already did. A
  preset asked through the function naming its __dev detail now sends
  that detail's max_tokens too, the value Trae's client sends; a function
  that doesn't name it still sends nothing.
- a detail with no max_tokens sends the agent's limit or none, as before.

Siblings: Trae CN and Trae international are one plugin (both sites go
through chatBody); SOLO's functions (solo_agent, solo_coder, ...) too. No
other plugin in the repo sets a fixed max_tokens/max_output_tokens cap
(grep for 1000/1024/2000/2048/4000/4096 near those keys). magpie's gateway
sends no fixed 2000 (its fill-in, askedOutput, is Anthropic-only).

Run (mote, HOME=$(mktemp -d), this tree on 62645ece):
packages/trae bun test: 287 pass, 0 fail (24 files);
bun scripts/check.mjs trae: ok;
root bun test: 9058 pass, 0 fail, 9078 tests across 636 files (514s);
bun scripts/check.mjs (all packages): ok.

Broken by hand: with 0.2.43's index.mjs, entmodels.test.mjs has 2 of 10
red: the enterprise test (max_tokens 0 listed / none sent, expected 8192)
and the preset test (undefined, expected 32000).

Not tried: a real enterprise seat (we have none), so the detail's
max_tokens in the fixture (8192) is invented and the 2000 default
is inferred from the reporter's numbers. If their detail carries no
max_tokens, a request naming none still goes without one.
2026-11-19 10:39:05 +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