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,