From 71851ff56e1d184e1d00581a468562a6288eaa1f Mon Sep 17 00:00:00 2001 From: LehaoLin Date: Sat, 21 Mar 2026 00:55:33 +0800 Subject: [PATCH] fix(gateway): reject 'list' and 'status' as invalid model refs (#51126) When sessions.patch receives model='list' or model='status' from Control UI, it now returns a clear error message instead of failing with a confusing 'model not allowed: openai-codex/list' error. These are chat command aliases, not model identifiers. Fixes #51126 --- src/gateway/sessions-patch.test.ts | 15 +++++++++++++++ src/gateway/sessions-patch.ts | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/src/gateway/sessions-patch.test.ts b/src/gateway/sessions-patch.test.ts index 478e360ecaf..67057d1fcc2 100644 --- a/src/gateway/sessions-patch.test.ts +++ b/src/gateway/sessions-patch.test.ts @@ -273,6 +273,21 @@ describe("gateway sessions patch", () => { expect(entry.modelOverride).toBe("claude-sonnet-4-6"); }); + test.each([ + { name: "list", model: "list" }, + { name: "LIST (uppercase)", model: "LIST" }, + { name: "List (mixed case)", model: "List" }, + { name: "status", model: "status" }, + { name: "STATUS (uppercase)", model: "STATUS" }, + { name: "Status (mixed case)", model: "Status" }, + ])("rejects model command alias '$name' as invalid model", async ({ model }) => { + const result = await runPatch({ + patch: { key: MAIN_SESSION_KEY, model }, + }); + expectPatchError(result, `invalid model`); + expectPatchError(result, `command alias`); + }); + test("sets spawnDepth for subagent sessions", async () => { const entry = expectPatchOk( await runPatch({ diff --git a/src/gateway/sessions-patch.ts b/src/gateway/sessions-patch.ts index 18b542302f6..e07977253fb 100644 --- a/src/gateway/sessions-patch.ts +++ b/src/gateway/sessions-patch.ts @@ -389,6 +389,11 @@ export async function applySessionsPatchToStore(params: { if (!trimmed) { return invalid("invalid model: empty"); } + if (trimmed.toLowerCase() === "list" || trimmed.toLowerCase() === "status") { + return invalid( + `invalid model: "${trimmed}" is a command alias, not a model. Use /models list or /model status in chat instead.`, + ); + } if (!params.loadGatewayModelCatalog) { return { ok: false,