Trae CN users see cache read 0 / write 0 on every call since 10-28
(modeyang: 786 trae-cn calls on 10-29 all 0, 77 hits on 10-27; an
identical resend also 0). The plugin passes on what token_usage says:
cache_read_input_tokens / cache_creation_input_tokens. A token_usage
with no cache field at all (chansee97's real super_completion_query
capture in #455: {"prompt_tokens":1717,"completion_tokens":2,
"total_tokens":1719}) came out as a usage with no cache field, which
magpie can only read as a counted miss. CDX-5 (#434) reports Trae's
chat replies switched to that shape at 10-27 23:07; not verified with
raw bytes. Trae's own client (3.5.20, libai_agent.dylib) still has the
9-field TokenUsageEvent, so the fields exist in the protocol.
Now:
- no cache field named at all -> magpie_cache_unknown: true (as the
Kiro plugin does), so magpie shows the cache as unknown;
- DeepSeek's prompt_cache_hit_tokens, cached_tokens and
prompt/input_tokens_details.cached_tokens are read as cache reads
(largest of them, so a 0 in one spelling never hides a hit);
- an explicit 0 stays a counted miss.
This cannot make Trae cache; if Trae no longer reports cache, the
plugin cannot know the hit rate.
Run (mote, bun 1.4.2):
- packages/trae bun test: 230 pass, 0 fail
- whole repo HOME=$(mktemp -d) bun test: 4324 pass, 9 skip, 0 fail
- bun scripts/check.mjs: exit 0
Broken by hand: the old index.mjs with the new tests fails 4 (3 new
cases + request.test's stream usage).
Not tried: a real Trae CN account (none available), so whether Trae
now omits the cache fields or sends 0 is not confirmed.
Releases #257 (WuJian1421), #260 and #273 (moxuanchen), with three fixes on
top of #257's native tool turns:
- A tool result with no text went out as an empty text part. wangjianjq
measured on live Trae CN (#251) that Trae then refuses the whole request
with 4027 ("insufficient tool messages following tool_calls message"),
for either of two parallel results; " " or "0" passes. An empty result
now goes as "(no output)", or "(the result's image follows)" when its
image rides the user turn after the run. Credit wangjianjq (#251).
- A request whose body names no tools (none sent, or tool_choice "none",
such as a summary) still sends past calls and results as text, as 0.2.17
did: every live run of the native turns carried the tools in the body.
- A tool result answering no call the history sends goes back as a user
text turn ("Result of ... (call id)"), not as a tool turn naming no call.
- A Windows APPDATA spelled with other case, separators or a trailing
separator is the same root as the home's AppData\Roaming (test for #273's
fix; it fails on 0.2.17's clientStoragePaths).
Run at this commit on origin/main c7a7379: bun test in packages/trae 175
pass 0 fail; bun scripts/check.mjs trae ok. Broken by hand: with the
merged #257 index.mjs, the three new request tests and the image placeholder
test fail (4 of 28 in request+images); with 0.2.17's index.mjs the new
APPDATA case fails. Not tried against a live Trae account (none here); the
live evidence is the PR authors'.
Trae accepts an assistant tool_calls turn and a role:"tool" result turn on
llm_utils_chat, and answers such a history with native calls; the text-form
bridge prompt is dropped. Assistant text folds into the calls turn after it,
consecutive calls turns join one list, a nameless call is dropped with its
result, and a tool result's images ride a user turn after the run of results
(Doubao-Seed doesn't read an image_url in a tool turn). Refs #38.
Run at the reviewed head d5d755a, merged with #260 and #273 on main 68170b3:
bun test in packages/trae 173 pass 0 fail; bun scripts/check.mjs trae ok.
Not tried live here (no Trae account); the live runs are the author's (CN and
Global, multi-turn, parallel calls) and wangjianjq's on #251. Follow-up on main:
an empty result's 4027, a request without tools, and a result answering no call.
Trae's llm_utils_chat streams a call's arguments as snapshots, and may send
the whole call again written apart from the partial one (U+2212 for -,
U+2032 for '), which neither extends it nor follows a whole one, so
NativeCalls joined the two and the call's arguments came out twice. A
whole JSON object under the same first key as the partial arguments, which
the two joined don't make whole, now replaces them. A piece that is a
JSON value of its own (12, "ls", {}) still joins the call: it doesn't
open with the call's first key. The new test of the resent snapshot fails
without the change; the one of pieces that are values of their own
passes either way. bun test (trae: 68) and bun scripts/check.mjs pass.
Sign-in is trae.cn's authorization page back to a 127.0.0.1 /authorize
callback (userJwt + userInfo, or a refresh token exchanged), with a device
made at sign-in and kept for the account. ExchangeToken renews the JWT
through auth.refresh (refreshLead 10 min, one renewal per refresh token).
Requests go to the IDE agent's llm_utils_chat (chat_v3, then
solo_work_lite on 4001/4023/1005), its SSE events turned into OpenAI
chunks; tools named natively and as <tool_call> blocks. Usage is the
entitlement packs' credits. Worked out from wangqi233/trae2api and
autumnsentiment/Trae2api-cn; not run against a real account.