Fix master agent model switch availability copy

This commit is contained in:
kris
2026-04-16 04:45:41 +08:00
parent 39be49630f
commit 514971bef8
2 changed files with 53 additions and 3 deletions

View File

@@ -176,6 +176,50 @@ test("master-agent 明确要求切快模型时直接更新 controls 并返回完
assert.equal(reply?.senderLabel ?? "", "主Agent·gpt-5.4-mini");
});
test("master-agent 切换模型成功时不会因为当前在线账号为空就回报可用模型暂无", async () => {
await saveAiAccount({
accountId: "master-codex-offline-switch",
label: "主 GPT",
role: "primary",
provider: "master_codex_node",
displayName: "Mac 上的 Master Codex Node",
nodeId: "offline-master-node",
nodeLabel: "离线 Codex",
model: "gpt-5.4",
enabled: true,
setActive: true,
loginStatusNote: "用于离线主节点模型切换文案测试。",
});
const response = await POST(
await createAuthedRequest("master-agent", {
body: "把主agent模型换成gpt5.4-mini",
}),
{ params: Promise.resolve({ projectId: "master-agent" }) },
);
assert.equal(response.status, 200);
const payload = (await response.json()) as {
ok: boolean;
task?: { taskId: string } | null;
masterReplyState?: "queued" | "running" | "completed" | null;
};
assert.equal(payload.ok, true);
assert.equal(payload.task ?? null, null);
assert.equal(payload.masterReplyState, "completed");
const controls = await getProjectAgentControls("master-agent", "17600003315");
assert.equal(controls?.modelOverride ?? null, "gpt-5.4-mini");
const state = await readState();
const masterProject = state.projects.find((project) => project.id === "master-agent");
const reply = masterProject?.messages.at(-1);
assert.ok(reply, "expected the master-agent offline switch reply to be persisted");
assert.match(reply?.body ?? "", /已把主 Agent 的当前主模型切到 gpt-5\.4-mini/);
assert.doesNotMatch(reply?.body ?? "", /当前可用模型:暂无/);
assert.match(reply?.body ?? "", /已登记\/可选模型:/);
});
test("master-agent 识别自然写法的模型名并切当前主模型", async () => {
await saveAiAccount({
accountId: "openai-main-switch",