Files
vscode-workbench/mcp-demo/repro-1214.mjs
T

35 lines
1.7 KiB
JavaScript

// Reproduce the 1214 role error: same endpoint, glm-5.3-flash, with a
// realistic harness-shaped conversation (system + tool_calls + tool result),
// once WITH the zai thinking param and once WITHOUT it.
import { readFileSync } from "node:fs";
const cred = readFileSync("C:/Users/12914/.dsh/.credentials.yaml", "utf8");
const key = cred.match(/\sB_API_KEY: ([^\s]+)/)[1];
const base = "http://156.225.30.43:65423/bai/v1";
const convo = [
{ role: "system", content: "You are a helpful coding agent." },
{ role: "user", content: "List the files in the project." },
{ role: "assistant", content: null, tool_calls: [
{ id: "call_1", type: "function", function: { name: "ls", arguments: "{}" } }
] },
{ role: "tool", tool_call_id: "call_1", content: "src/\npackage.json" }
];
async function call(label, extra) {
const r = await fetch(`${base}/chat/completions`, {
method: "POST",
headers: { "Content-Type": "application/json", Authorization: `Bearer ${key}` },
body: JSON.stringify({ model: "glm-5.3-flash", messages: convo, max_tokens: 64, ...extra })
});
const text = await r.text();
let j = null; try { j = JSON.parse(text); } catch {}
const code = j?.code ?? j?.error?.code ?? r.status;
console.log(`${label}: status=${r.status} code=${JSON.stringify(code)} msg=${(j?.message ?? j?.error?.message ?? (j?.choices?.[0]?.message?.content ?? "")).slice(0, 60)}`);
}
await call("with-thinking-enabled ", { thinking: { type: "enabled", clear_thinking: false } });
await call("with-thinking-disabled ", { thinking: { type: "disabled" } });
await call("without-thinking-param ", {});
await call("with-enable-thinking ", { enable_thinking: true });
console.log("REPRO_DONE");