00f4d84b8f0e875cf0d42e8bfbce2e41ecb8c796
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
57598ad410 |
zcode 0.1.30: a coding plan's requests name the device in metadata.user_id, as ZCode's do (#387)
wendyeq measured BigModel's GLM Coding Plan through magpie hitting the
prompt cache 1 time in 19 without metadata.user_id and 13 in 16 with it;
the official ZCode on the same account reads 95-98% of input from cache.
The plugin only put user_id on the Start Plan's dressed body; a coding
plan or team request went as the agent sent it, and Pi sends none.
ZCode 3.14.3 (glm/zcode.cjs) sets it on every Anthropic-format request,
not only the Start Plan's: Pst() returns MLs({deviceMid, sessionId}) for
any providerKind "anthropic", and vWr() puts it in
providerOptions.anthropic.metadata.userId for both generateText and
streamText. The value is {"device_id":<machine id>,"account_uuid":"",
"session_id":...}.
Now a coding plan or team request to .../v1/messages gets
metadata.user_id = {"device_id":<sign-in's saved device>,
"account_uuid":"","session_id":""}, the same value dress() puts on the
Start Plan's, when the agent sent no user_id of its own; other metadata
is kept and content-length dropped when the body changed. count_tokens
and non-Messages bodies go as they were. An account known only by a key
(a pasted API key, or a saved state with no device) gets a device id
hashed from the key, so it is the same on every start rather than
anyDevice, which was new per process.
Differences from ZCode, kept on purpose: ZCode overwrites any user_id
and fills session_id with its session (sess_ prefix stripped); this
keeps an agent's own user_id and sends session_id "" as dress() does,
one stable value per account.
Tests: userid.test.mjs (new, 6 tests; 5 red on origin/main's index.mjs,
the count_tokens one passes there as it should). start, toolsearch and
dual tests that pinned coding plan bodies byte for byte now expect the
agent's body plus the device's user_id.
Run at this tree: HOME=$(mktemp -d) bun test -> 2672 pass, 1 skip,
0 fail across 229 files; bun scripts/check.mjs ok.
Not tried: a real BigModel or Z.ai coding plan request, so the cache
hit rate after the change is the reporter's measurement, not mine.
|
||
|
|
d1b65007ff |
zcode 0.1.24: Claude Code's tool search goes to ZCode's plans as ToolSearchTool, so a subagent sees Bash, Read and Write
小八 (Discord #general, 10-24): Claude Code through magpie on ZCode (glm-5.3, glm-5.3-flash) gave subagents only the deferred MCP tools; Bash, Read and Write were missing. Another upstream worked. Cause, measured against api.z.ai with a real GLM Coding Plan account: when a request's tools include one named exactly "ToolSearch", z.ai shows the model none of the other tools except those a tool_reference loaded. Claude Code 2.1.310's subagent request (captured from the real binary in a sandbox HOME) has Agent, Bash, Edit, Read, Skill, ToolSearch, DeferredToolPlaceholder (defer_loading) and Write. Input tokens for that request: 2886 with ToolSearch, 2439 with no tools at all, 5995 without ToolSearch. ToolSearch plus Bash also counts 2886. Renaming the tool (tool_search, ToolSearchTool, SearchTools, ...) gives 6346, every tool counted. The anthropic-beta header changes nothing (with or without advanced-tool-use: 2886), and neither does defer_loading. So 0.1.22's dropped beta on the Start Plan is not the cause; the coding plan path, which keeps the agent's headers, fails the same way. ZCode 3.14.3's own client sends no ToolSearch tool and no defer_loading (glm/zcode.cjs). Now every path (GLM Coding Plan, team, Start Plan and gift) sends Claude Code's ToolSearch as ToolSearchTool, in the tools and in the assistant turns that called it. Tools go without defer_loading, as ZCode's do; Claude Code sends a deferred tool's schema only after a search loaded it. DeferredToolPlaceholder is left out. The tool_reference results stay. The model's calls to ToolSearchTool come back to Claude Code as ToolSearch, in a stream's content_block_start or a whole message's content. A request without ToolSearch, or one that already has a tool named ToolSearchTool, goes as before. Run: - toolsearch.test.mjs: 4 of 5 fail on 0.1.23's index.mjs (the passthrough test passes on both). bun test packages/zcode under a scratch HOME: 97 pass. bun scripts/check.mjs zcode: ok. - Real, through the plugin's fetch to api.z.ai (GLM Coding Plan), real Claude Code 2.1.310 in a sandbox HOME with a stdio MCP server: on 0.1.23, "spawn a subagent to run ls -a with Bash" ended with the model saying it had no Agent tool. On this change the subagent ran Bash and returned the listing. A deferred MCP tool loaded through ToolSearch (now sent as ToolSearchTool) and was then called. Not tried: the Start Plan against z.ai. The account's Start Plan quota is spent (1005 exceed quota limit), so that path has only the fake-server test. BigModel (open.bigmodel.cn) was not tried either. |