zen-free 0.1.23: DSH's tools Zen refuses by name go under other names (#632)
jdld-ybd saw every DSH call to a Zen free model answered 429 FreeUsageLimitError while other agents through the same magpie, plugin and address were served, and a plain request on the same model was served too: the refusal is in DSH's own request body, as #624's was. A real 80-tool DSH request was bisected against Zen on 2026-10-30 (Ebony-Vinyl/dsh-our-free-model#709): DSH's subagent_fork on its own, and its read_image offered beside working_directory, each got 429 at once; the same names with only description or parameters changed still got 429; the whole request with just those two names changed was served. DSH 0.2.1 offers all three by default (and terminal_*, which 0.1.22 already sends as console_*). The #624 pair becomes one table of names Zen refuses together: subagent_fork goes as conversation_delegate, and working_directory as workspace_directory when read_image is offered too (the names that request was served under), in past calls and tool_choice too, on Chat, Responses and Messages; a call of one comes back under DSH's name. read_image or working_directory alone keeps its name. Run at this head on mote (bun 1.4.2, HOME=$(mktemp -d)): - packages/zen-free bun test: 212 pass, 0 fail. - whole repo bun test: 4795 pass, 14 skip, 0 fail. - bun scripts/check.mjs zen-free: ok. Broken by hand: - origin/main's provider.mjs: the three per-protocol #632 tests red. - working_directory renamed without read_image: "read_image or working_directory alone goes as named" red. Not tried: a request to the real Zen or with DSH. Every probe from this network, a plain request without tools included, is answered 429 FreeUsageLimitError today (the address's allowance is spent until 00:00 UTC), so the gate rests on that bisection, not on one of ours.
This commit is contained in:
@@ -97,7 +97,9 @@ offered beside `ScheduleWakeup`, as Claude Code desktop offers them
|
||||
(#624). Those tools go to Zen under other names of the same words
|
||||
(`mcp__ide__console_run`, `findings_report`, `wakeup_schedule`), in the
|
||||
agent's past calls and `tool_choice` too, and a call of one reaches the
|
||||
agent under its own name.
|
||||
agent under its own name. DSH's `subagent_fork`, and its `read_image`
|
||||
offered beside `working_directory`, are refused the same way (#632); they
|
||||
go as `conversation_delegate` and `workspace_directory`.
|
||||
|
||||
Zen's free tier also tells OpenCode's own requests by the environment
|
||||
block every OpenCode prompt ends with (`<env>`, a `Working directory:`
|
||||
|
||||
@@ -1028,3 +1028,99 @@ test("a request without a refused name goes with its tools as named (#624)", asy
|
||||
await response.text();
|
||||
assert.deepEqual(state.calls.at(-1).body.tools.slice(0, tools.length), tools);
|
||||
});
|
||||
|
||||
// DSH's own tools Zen refuses by name (jdld-ybd, plugins#632): its
|
||||
// subagent_fork on its own, and its read_image beside working_directory, as
|
||||
// a real 80-tool DSH request was bisected (Ebony-Vinyl/dsh-our-free-model
|
||||
// #709). Its terminal_* tools go as console_* (#624). The rest of its tools,
|
||||
// read_image included, keep their names.
|
||||
for (const { protocol, path, model } of protocols) {
|
||||
test(`${protocol}: DSH's tools Zen refuses by name go under other names and come back as DSH's (#632)`, async (t) => {
|
||||
const { plugin, state, origin } = await fixture(t);
|
||||
await plugin.provider.models({ models: {} }, { auth: await publicAuth() });
|
||||
const loader = await plugin.auth.loader(publicAuth);
|
||||
const schema = { type: "object", properties: { prompt: { type: "string" } } };
|
||||
const names = ["bash", "read", "read_image", "working_directory", "subagent", "subagent_fork", "terminal_open", "todo_write"];
|
||||
const tools = names.map((name) => {
|
||||
const tool = { name, description: `DSH ${name}` };
|
||||
if (protocol === "chat") return { type: "function", function: { ...tool, parameters: schema } };
|
||||
if (protocol === "anthropic") return { ...tool, input_schema: schema };
|
||||
return { type: "function", ...tool, parameters: schema };
|
||||
});
|
||||
const body = { model, stream: false, tools };
|
||||
if (protocol === "chat") {
|
||||
body.messages = [
|
||||
{ role: "system", content: "You are an AI agent powered by DeepSeek Harness." },
|
||||
{ role: "user", content: "hi" },
|
||||
{ role: "assistant", content: [], tool_calls: [{ id: "c0", type: "function", function: { name: "working_directory", arguments: "{}" } }] },
|
||||
{ role: "tool", tool_call_id: "c0", content: "ok" },
|
||||
];
|
||||
body.tool_choice = { type: "function", function: { name: "subagent_fork" } };
|
||||
} else if (protocol === "anthropic") {
|
||||
body.messages = [
|
||||
{ role: "user", content: "hi" },
|
||||
{ role: "assistant", content: [{ type: "tool_use", id: "c0", name: "working_directory", input: {} }] },
|
||||
{ role: "user", content: [{ type: "tool_result", tool_use_id: "c0", content: "ok" }] },
|
||||
];
|
||||
body.tool_choice = { type: "tool", name: "subagent_fork" };
|
||||
} else {
|
||||
body.input = [
|
||||
{ role: "user", content: "hi" },
|
||||
{ type: "function_call", call_id: "c0", name: "working_directory", arguments: "{}" },
|
||||
{ type: "function_call_output", call_id: "c0", output: "ok" },
|
||||
];
|
||||
body.tool_choice = { type: "function", name: "subagent_fork" };
|
||||
}
|
||||
const send = () => loader.fetch(`${origin}/v1/${path}`, { method: "POST", body: JSON.stringify(body) });
|
||||
for (const [upstream, expected] of [
|
||||
["conversation_delegate", "subagent_fork"],
|
||||
["workspace_directory", "working_directory"],
|
||||
["console_open", "terminal_open"],
|
||||
["read_image", "read_image"],
|
||||
["subagent", "subagent"],
|
||||
]) {
|
||||
state.reply = toolReply(protocol, upstream, true);
|
||||
const response = await send();
|
||||
assert.equal(response.status, 200);
|
||||
const text = await response.text();
|
||||
assert.match(text, new RegExp(`"name"\\s*:\\s*"${expected}"`), upstream);
|
||||
}
|
||||
const sent = state.calls.at(-1).body;
|
||||
const sentNames = sent.tools.map((tool) => (protocol === "chat" ? tool.function.name : tool.name));
|
||||
assert.deepEqual(sentNames.slice(0, names.length), [
|
||||
"bash",
|
||||
"read",
|
||||
"read_image",
|
||||
"workspace_directory",
|
||||
"subagent",
|
||||
"conversation_delegate",
|
||||
"console_open",
|
||||
"todo_write",
|
||||
]);
|
||||
const described = sent.tools.find((tool) => (tool.function?.name ?? tool.name) === "conversation_delegate");
|
||||
assert.equal(described.function?.description ?? described.description, "DSH subagent_fork");
|
||||
const past =
|
||||
protocol === "chat"
|
||||
? sent.messages.find((message) => message.tool_calls).tool_calls[0].function.name
|
||||
: protocol === "anthropic"
|
||||
? sent.messages[1].content[0].name
|
||||
: sent.input[1].name;
|
||||
assert.equal(past, "workspace_directory");
|
||||
assert.equal(sent.tool_choice.function?.name ?? sent.tool_choice.name, "conversation_delegate");
|
||||
});
|
||||
}
|
||||
|
||||
test("read_image or working_directory alone goes as named (#632)", async (t) => {
|
||||
const { plugin, state, origin } = await fixture(t);
|
||||
await plugin.provider.models({ models: {} }, { auth: await publicAuth() });
|
||||
const loader = await plugin.auth.loader(publicAuth);
|
||||
for (const name of ["read_image", "working_directory"]) {
|
||||
const tools = [...declaredTools("chat"), { type: "function", function: { name, parameters: { type: "object" } } }];
|
||||
const response = await loader.fetch(`${origin}/v1/chat/completions`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ model: "chat-free", stream: false, tools }),
|
||||
});
|
||||
await response.text();
|
||||
assert.deepEqual(state.calls.at(-1).body.tools.slice(0, tools.length), tools, name);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@magpie-community/opencode-zen-free-auth",
|
||||
"version": "0.1.22",
|
||||
"version": "0.1.23",
|
||||
"description": "OpenCode Zen free models through the public credential, with native streaming protocols",
|
||||
"type": "module",
|
||||
"main": "./index.mjs",
|
||||
|
||||
@@ -264,22 +264,41 @@ function normalizeTools(body, protocol) {
|
||||
}
|
||||
|
||||
// Tool names Zen's free tier refuses to serve under, whatever else the
|
||||
// request says, as alonewolfsy-web bisected a real Claude Code desktop
|
||||
// request on 2026-11-01 (plugins#624): a name with "terminal" in it, in
|
||||
// any case (an MCP server's terminal tools), and ReportFindings and
|
||||
// ScheduleWakeup offered together, as Claude Code desktop's own tools are
|
||||
// (either alone was served). Each got 429 FreeUsageLimitError at once, and
|
||||
// the same request with those tools under other names was served. They go to Zen
|
||||
// under a name of the same words (ReportFindings as findings_report,
|
||||
// mcp__x__terminal_run as mcp__x__console_run), in the agent's past calls
|
||||
// and tool_choice too, and a call of one comes back under the agent's own
|
||||
// name (toolPolicy.renamed, read by tool-response.mjs's nameGuard).
|
||||
const REFUSED_NAMES = { ReportFindings: "findings_report", ScheduleWakeup: "wakeup_schedule" };
|
||||
// request says: it answers 429 FreeUsageLimitError at once, the same reply
|
||||
// as a spent allowance, and the same request with those tools under other
|
||||
// names is served. Renaming the description or parameters instead doesn't
|
||||
// help; the name is what is read. Found so far, each by bisecting a real
|
||||
// agent's request against Zen, one name at a time:
|
||||
//
|
||||
// - a name with "terminal" in it, in any case (an MCP server's terminal
|
||||
// tools, DSH's terminal_open), and ReportFindings offered beside
|
||||
// ScheduleWakeup, as Claude Code desktop does (either alone was
|
||||
// served): alonewolfsy-web, 2026-11-01, plugins#624;
|
||||
// - DSH's subagent_fork on its own, and its read_image offered beside
|
||||
// working_directory (either alone was served): a real 80-tool DSH
|
||||
// request bisected on 2026-10-30 (Ebony-Vinyl/dsh-our-free-model#709),
|
||||
// served whole with only those two names changed, as jdld-ybd saw DSH
|
||||
// refused while other agents were served from the same address
|
||||
// (plugins#632).
|
||||
//
|
||||
// Such a tool goes to Zen under another name (the ones those bisections
|
||||
// were served under), in the agent's past calls and tool_choice too, and a
|
||||
// call of one comes back under the agent's own name (toolPolicy.renamed,
|
||||
// read by tool-response.mjs's nameGuard). A rule renames its tools only
|
||||
// when every name it lists is offered. A new finding is one more entry.
|
||||
const REFUSED_TOGETHER = [
|
||||
{
|
||||
names: ["ReportFindings", "ScheduleWakeup"],
|
||||
as: { ReportFindings: "findings_report", ScheduleWakeup: "wakeup_schedule" },
|
||||
},
|
||||
{ names: ["subagent_fork"], as: { subagent_fork: "conversation_delegate" } },
|
||||
{ names: ["read_image", "working_directory"], as: { working_directory: "workspace_directory" } },
|
||||
];
|
||||
const REFUSED_WORD = /terminal/i;
|
||||
|
||||
function servedName(name, taken) {
|
||||
if (Object.hasOwn(REFUSED_NAMES, name))
|
||||
return Object.keys(REFUSED_NAMES).every((pair) => taken.has(pair)) ? REFUSED_NAMES[name] : undefined;
|
||||
for (const rule of REFUSED_TOGETHER)
|
||||
if (Object.hasOwn(rule.as, name) && rule.names.every((other) => taken.has(other))) return rule.as[name];
|
||||
if (!REFUSED_WORD.test(name)) return undefined;
|
||||
return name.replace(new RegExp(REFUSED_WORD.source, "gi"), (word) =>
|
||||
word === word.toUpperCase() ? "CONSOLE" : word[0] === "T" ? "Console" : "console",
|
||||
|
||||
Reference in New Issue
Block a user