Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(models): mark models the organization turned off, and say when another model answered (#4172)

Milind Soniab1138ce396f
diff --git a/server/contracts.ts b/server/contracts.ts
index 73d583e41f..cac56bdce2 100644
--- a/server/contracts.ts
+++ b/server/contracts.ts
@@ -462,6 +462,8 @@ export interface ModelCatalog {
contextWindow?: number;
/** Discovery hints; the native session revalidates these before each turn. */
variants?: ModelVariantOption[];
+ /** The organization of the signed-in account turned this model off: the engine would answer with another. */
+ orgBlocked?: true;
}>;
}
diff --git a/server/drivers/claude-auth.test.ts b/server/drivers/claude-auth.test.ts
index 30c43299ee..04b4bda6b5 100644
--- a/server/drivers/claude-auth.test.ts
+++ b/server/drivers/claude-auth.test.ts
@@ -3,7 +3,8 @@ import { describe, expect, it } from "vitest";
import { claudeSignedIn } from "./claude-auth-status.ts";
import { claudeAuthFailure } from "./claude-auth-recovery.ts";
-import { claudeResultError, claudeVersionTooOld } from "./claude.ts";
+import { claudeVersionTooOld } from "./claude-limits.ts";
+import { claudeResultError } from "./claude.ts";
import { claudeApiErrorMessage, claudeEngineReset, claudeLimitFacts, claudeLimitMessage, claudeLimitRefusal, claudeUsageLimit } from "./claude-limits.ts";
import { classifyError } from "./retry.ts";
diff --git a/server/drivers/claude-limits.ts b/server/drivers/claude-limits.ts
index a4e9e82b83..e4b7d312d1 100644
--- a/server/drivers/claude-limits.ts
+++ b/server/drivers/claude-limits.ts
@@ -79,6 +79,16 @@ export function claudeLimitMessage(limit: ClaudeLimit | null, said?: string, now
return `This Claude account has reached its ${name}${words ? ` (Claude says: "${words}")` : ""}. For now, ${meanwhile}.`;
}
+/** The API refusing a model newer than the installed CLI, relayed as an api-error frame ("Claude
+ * Code 2.1.268 does not support this model; version 2.1.280 or newer is required…"); it names no model. */
+export function claudeVersionTooOld(
+ frame: { error?: unknown; is_api_error_message?: unknown },
+ text: string,
+): boolean {
+ if (frame.is_api_error_message !== true && typeof frame.error !== "string") return false;
+ return /\bClaude Code v?\d+(?:\.\d+)+ does not support this model\b/i.test(text);
+}
+
/** Claude Code 2.1.295's api-error kinds (the assistant frame's `error`) that say the cause outright. */
const CLAUDE_ERROR_KINDS: Record<string, EngineFailureKind> = {
billing_error: "credits",
diff --git a/server/drivers/claude-model-access.test.ts b/server/drivers/claude-model-access.test.ts
new file mode 100644
index 0000000000..108172df67
--- /dev/null
+++ b/server/drivers/claude-model-access.test.ts
@@ -0,0 +1,215 @@
+import { chmodSync, mkdtempSync, utimesSync, writeFileSync } from "node:fs";
+import { tmpdir } from "node:os";
+import { dirname, join } from "node:path";
+import { fileURLToPath } from "node:url";
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+import { ensureDirs } from "../config.ts";
+import type { ModelCatalog, ProviderInstance } from "../contracts.ts";
+import { removeTempDir } from "../testing/cleanup.ts";
+import { recordEvents, type EventRecorder } from "../testing/events.ts";
+import { addServerLinePacks, setConversationLanguage } from "../server-lines.ts";
+import { claudeAccountFiles, createOrgModelBlocks, modelSwapNotice, otherModelAnswered, parseOrgBlockedModels, withOrgBlocks } from "./claude-model-access.ts";
+import { ClaudeDriver } from "./claude.ts";
+
+const FAKE_CLI = join(dirname(fileURLToPath(import.meta.url)), "..", "testing", "fake-claude-cli.ts");
+const scratch: string[] = [];
+const tempDir = () => {
+ const dir = mkdtempSync(join(tmpdir(), "omb-model-access-"));
+ scratch.push(dir);
+ return dir;
+};
+const access = (...entries: unknown[]) => JSON.stringify({ projects: { "/a": { history: ["]{"] } }, modelAccessCache: entries, numStartups: 3 });
+
+const catalog: ModelCatalog = {
+ default: "claude-sonnet-5",
+ options: [
+ { id: "claude-fable-5-1", label: "Claude Fable 5.1" },
+ { id: "claude-sonnet-5", label: "Claude Sonnet 5" },
+ { id: "claude-opus-5-5", label: "Claude Opus 5.5" },
+ ],
+};
+
+afterEach(async () => {
+ for (const dir of scratch.splice(0)) await removeTempDir(dir);
+ setConversationLanguage(() => undefined);
+ addServerLinePacks({ de: {} });
+ vi.unstubAllEnvs();
+});
+
+describe("what the organization turned off", () => {
+ it("names only the models the cache explicitly denies, as catalog ids", () => {
+ const blocked = parseOrgBlockedModels(access(
+ { apiName: "claude-fable-5-1", entitled: false },
+ { apiName: "claude-opus-5-5", entitled: true },
+ { apiName: "claude-haiku-4-5-20251001", entitled: false },
+ { apiName: "Claude-Sonnet-5[1m]", entitled: false },
+ { apiName: "claude-opus-5", entitled: "false" },
+ { apiName: "claude-opus-4" },
+ { entitled: false },
+ null,
+ ));
+ expect([...blocked]).toEqual(["claude-fable-5-1", "claude-haiku-4-5", "claude-sonnet-5"]);
+ });
+
+ it.each([
+ ["malformed JSON", "{"],
+ ["no cache", '{"oauthAccount":{}}'],
+ ["a cache that is not a list", '{"modelAccessCache":{"claude-fable-5-1":false}}'],
+ ["nothing", ""],
+ ])("hides nothing for %s", (_, text) => {
+ expect(parseOrgBlockedModels(text).size).toBe(0);
+ });
+
+ it("marks a blocked model and moves a blocked default to one the organization allows", () => {
+ const marked = withOrgBlocks(catalog, new Set(["claude-sonnet-5"]));
+ expect(marked.options.find((option) => option.id === "claude-sonnet-5")?.orgBlocked).toBe(true);
+ expect(marked.options.filter((option) => option.orgBlocked)).toHaveLength(1);
+ expect(marked.default).toBe("claude-fable-5-1");
+ });
+
+ it("takes a mark back once the organization allows the model again, and never marks a local model", () => {
+ const local = { ...catalog, options: [...catalog.options, { id: "claude-local", label: "Local", custom: true }] };
+ const marked = withOrgBlocks(local, new Set(["claude-fable-5-1", "claude-local"]));
+ expect(marked.options.map((option) => Boolean(option.orgBlocked))).toEqual([true, false, false, false]);
+ expect(withOrgBlocks(marked, new Set()).options.some((option) => option.orgBlocked)).toBe(false);
+ });
+});
+
+describe("reading the account config", () => {
+ it("looks where the CLI keeps it", () => {
+ expect(claudeAccountFiles({ HOME: "/h" })).toEqual(["/h/.claude/.config.json", "/h/.claude.json"]);
+ expect(claudeAccountFiles({ HOME: "/h", CLAUDE_CONFIG_DIR: "/c" })).toEqual(["/c/.config.json", "/c/.claude.json"]);
+ });
+
+ const watch = (env: Record<string, string | undefined>[]) => {
+ const seen: string[][] = [];
+ return { seen, blocks: createOrgModelBlocks(() => env, (blocked) => seen.push([...blocked])) };
+ };
+
+ it("reads again only when the file changed", async () => {
+ const home = tempDir();
+ const file = join(home, ".claude.json");
+ writeFileSync(file, access({ apiName: "claude-fable-5-1", entitled: false }));
+ const { seen, blocks } = watch([{ HOME: home }]);
+ await blocks.refresh();
+ await blocks.refresh();
+ expect(seen).toEqual([["claude-fable-5-1"]]);
+ writeFileSync(file, access());
+ utimesSync(file, new Date(), new Date(Date.now() + 5_000));
+ await blocks.refresh();
+ expect(seen.at(-1)).toEqual([]);
+ });
+
+ it("on a cloud provider's backend ignores a list an earlier sign-in left", async () => {
+ const home = tempDir();
+ writeFileSync(join(home, ".claude.json"), access({ apiName: "claude-fable-5-1", entitled: false }));
+ const { seen, blocks } = watch([{ HOME: home, CLAUDE_CODE_USE_BEDROCK: "1" }]);
+ await blocks.refresh();
+ expect(seen).toEqual([[]]);
+ });
+
+ it("takes the newest answer among a Team Cloud's engine homes", async () => {
+ const [older, newer] = [tempDir(), tempDir()];
+ writeFileSync(join(older, ".claude.json"), access({ apiName: "claude-opus-5", entitled: false }));
+ utimesSync(join(older, ".claude.json"), new Date(1_000), new Date(1_000));
+ writeFileSync(join(newer, ".claude.json"), access({ apiName: "claude-fable-5", entitled: false }));
+ const { seen, blocks } = watch([{ HOME: older }, { HOME: newer }]);
+ await blocks.refresh();
+ expect(seen).toEqual([["claude-fable-5"]]);
+ });
+});
+
+describe("a turn answered by another model", () => {
+ it.each([
+ ["claude-fable-5-1", "claude-opus-5-5", true],
+ ["claude-opus-5-5", "claude-opus-5-5", false],
+ ["claude-opus-5-5", "claude-opus-5-5[1m]", false],
+ ["claude-haiku-4-5", "claude-haiku-4-5-20251001", false],
+ ["claude-fable-5-1", "<synthetic>", false],
+ ["sonnet", "claude-sonnet-5", false],
+ ["ollama::qwen", "qwen", false],
+ ["claude-opus-5-5", "us.anthropic.claude-opus-5-5-v1:0", false],
+ [null, "claude-opus-5-5", false],
+ ["claude-opus-5-5", undefined, false],
+ ])("%s then %s: %s", (picked, answered, other) => {
+ expect(otherModelAnswered(picked as string | null, answered)).toBe(other);
+ });
+
+ it("says the organization turned it off only when it did, by the models' names, once per session for each pair", () => {
+ const blocked = withOrgBlocks(catalog, new Set(["claude-fable-5-1"]));
+ const session = {};
+ const by = (model: string) => ({ message: { model } });
+ expect(modelSwapNotice(session, "t", "claude-fable-5-1", by("claude-opus-5-5-20260101"), blocked))
+ .toBe("Claude Fable 5.1 is turned off by your organization, so Claude Opus 5.5 answered instead. Choose another model to stop seeing this.");
+ expect(modelSwapNotice(session, "t", "claude-fable-5-1", by("claude-opus-5-5"), blocked)).toBeNull();
+ expect(modelSwapNotice(session, "t", "claude-sonnet-5", by("claude-opus-5-5"), blocked)).toBe("You chose Claude Sonnet 5, but Claude Opus 5.5 answered instead.");
+ expect(modelSwapNotice({}, "t", "claude-fable-5-1", by("claude-opus-5-5"), blocked)).toContain("turned off");
+ });
+
+ it("ignores a subagent's model", () => {
+ expect(modelSwapNotice({}, "t", "claude-fable-5-1", { parent_tool_use_id: "toolu_1", message: { model: "claude-haiku-5-5" } }, catalog)).toBeNull();
+ });
+
+ it("speaks the conversation's language", () => {
+ addServerLinePacks({ de: { "server.model.otherAnswered": "Gewählt: {picked}, geantwortet: {answered}." } });
+ setConversationLanguage(() => "de");
+ expect(modelSwapNotice({}, "t", "claude-sonnet-5", { message: { model: "claude-opus-5-5" } }, catalog)).toBe("Gewählt: Claude Sonnet 5, geantwortet: Claude Opus 5.5.");
+ });
+});
+
+describe("the Claude driver", () => {
+ let instance: ProviderInstance | undefined;
+ let recorder: EventRecorder | undefined;
+
+ afterEach(async () => {
+ recorder?.stop();
+ await instance?.dispose();
+ instance = recorder = undefined;
+ });
+
+ const start = async (answeredBy: string | undefined, cache: unknown[]) => {
+ ensureDirs();
+ chmodSync(FAKE_CLI, 0o755);
+ const configDir = tempDir();
+ writeFileSync(join(configDir, ".claude.json"), access(...cache));
+ if (answeredBy) vi.stubEnv("FAKE_CLAUDE_ANSWER_MODEL", answeredBy);
+ instance = await ClaudeDriver.create({
+ instanceId: `claude-access-${Math.random().toString(36).slice(2, 10)}`,
+ displayName: "Claude", environment: {}, enabled: true,
+ config: { cli: FAKE_CLI, permissionMode: "acceptEdits", configDir },
+ });
+ await instance.startupModelRefresh;
+ await instance.refreshModels?.();
+ recorder = recordEvents(instance.adapter);
+ return { instance, recorder, configDir };
+ };
+
+ it("lists a model the account's organization turned off as blocked, and tells the person who answered instead", async () => {
+ const { instance, recorder } = await start("claude-opus-5-5", [{ apiName: "claude-fable-5-1", entitled: false }]);
+ expect(instance.models.options.find((option) => option.id === "claude-fable-5-1")?.orgBlocked).toBe(true);
+ await instance.adapter.sendTurn({ threadId: "t-swap", text: "hi", model: "claude-fable-5-1" });
+ await recorder.until((event) => event.type === "turn.completed");
+ expect(recorder.events.filter((event) => event.type === "runtime.notice")).toEqual([
+ expect.objectContaining({ message: expect.stringContaining("Claude Fable 5.1 is turned off by your organization") }),
+ ]);
+ });
+
+ it("says nothing when the model picked is the model that answered", async () => {
+ const { instance, recorder } = await start("claude-opus-5-5[1m]", []);
+ await instance.adapter.sendTurn({ threadId: "t-same", text: "hi", model: "claude-opus-5-5" });
+ await recorder.until((event) => event.type === "turn.completed");
+ expect(recorder.events.filter((event) => event.type === "runtime.notice")).toEqual([]);
+ });
+
+ it("notices a block that arrives after the catalog was read, once a turn has ended", async () => {
+ const { instance, recorder, configDir } = await start(undefined, []);
+ expect(instance.models.options.some((option) => option.orgBlocked)).toBe(false);
+ const file = join(configDir, ".claude.json");
+ writeFileSync(file, access({ apiName: "claude-opus-5", entitled: false }));
+ utimesSync(file, new Date(), new Date(Date.now() + 5_000));
+ await instance.adapter.sendTurn({ threadId: "t-later", text: "hi", model: "claude-sonnet-5" });
+ await recorder.until((event) => event.type === "turn.completed");
+ await vi.waitFor(() => expect(instance.models.options.find((option) => option.id === "claude-opus-5")?.orgBlocked).toBe(true));
+ });
+});
diff --git a/server/drivers/claude-model-access.ts b/server/drivers/claude-model-access.ts
new file mode 100644
index 0000000000..dc506e6a9e
--- /dev/null
+++ b/server/drivers/claude-model-access.ts
@@ -0,0 +1,119 @@
+// Claude Code keeps what an organization allows in its account config: `modelAccessCache`, `[{ apiName, entitled }]`, as
+// it stood at the CLI's last start (2.1.312). The CLI answers a turn on a denied model with the organization's default.
+import { readFile, stat } from "node:fs/promises";
+import { homedir } from "node:os";
+import { join } from "node:path";
+
+import type { ModelCatalog } from "../contracts.ts";
+import { conversationLanguage, serverLine } from "../server-lines.ts";
+import { topLevelJsonMember } from "../setup-import.ts";
+
+/** The account config of a very long project history: too large to scan on the server's thread for this list. */
+const ACCOUNT_FILE_MAX_BYTES = 32 * 1024 * 1024;
+
+/** 2.1.312 builds its deny list only on its first-party and gateway backends: on these the cloud account decides, and a
+ * list left by an earlier claude.ai login means nothing. */
+const CLOUD_BACKEND_ENV = [
+ "CLAUDE_CODE_USE_BEDROCK",
+ "CLAUDE_CODE_USE_FOUNDRY",
+ "CLAUDE_CODE_USE_ANTHROPIC_AWS",
+ "CLAUDE_CODE_USE_ANTHROPIC_GOOGLE_CLOUD",
+ "CLAUDE_CODE_USE_MANTLE",
+ "CLAUDE_CODE_USE_VERTEX",
+];
+
+/** How 2.1.312 matches names: API ids may carry a release date (`claude-haiku-4-5-20251001`) and a `[1m]` suffix that
+ * catalog ids leave out. */
+export function claudeModelKey(id: string): string {
+ return id.trim().toLowerCase().replace(/(?:\[1m\])+$/, "").replace(/-\d{8}$/, "");
+}
+
+/** Fails open: a missing or malformed file hides nothing, and only an explicit `entitled: false` counts. */
+export function parseOrgBlockedModels(text: string): Set<string> {
+ const blocked = new Set<string>();
+ const cache = topLevelJsonMember(text, "modelAccessCache");
+ if (!Array.isArray(cache)) return blocked;
+ for (const entry of cache as Array<{ apiName?: unknown; entitled?: unknown } | null>) {
+ if (typeof entry?.apiName === "string" && entry.entitled === false) blocked.add(claudeModelKey(entry.apiName));
+ }
+ return blocked;
+}
+
+/** Where 2.1.312 keeps its account config: `.config.json` in its config folder when that has content (older installs), else
+ * `.claude.json` in `CLAUDE_CONFIG_DIR` or the home folder. */
+export function claudeAccountFiles(env: Record<string, string | undefined>): string[] {
+ const home = env.HOME || env.USERPROFILE || homedir();
+ const folder = env.CLAUDE_CONFIG_DIR?.trim();
+ return [join(folder || join(home, ".claude"), ".config.json"), join(folder || home, ".claude.json")];
+}
+
+/** The catalog as this account may use it. A blocked default gives way to the first model the organization allows, so a
+ * new bot never starts on one. */
+export function withOrgBlocks(catalog: ModelCatalog, blocked: ReadonlySet<string>): ModelCatalog {
+ const options: ModelCatalog["options"] = catalog.options.map(({ orgBlocked: _stale, ...option }) =>
+ !option.custom && blocked.has(claudeModelKey(option.id)) ? { ...option, orgBlocked: true as const } : option);
+ const usable = (id: string) => options.some((option) => option.id === id && !option.orgBlocked);
+ const fallback = options.find((option) => !option.orgBlocked && !option.custom)?.id;
+ return { ...catalog, default: usable(catalog.default) ? catalog.default : fallback ?? catalog.default, options };
+}
+
+type AccountEnv = Record<string, string | undefined>;
+
+/** Keeps the catalog in step with the account config. `environments` names every place the CLI may have written it: on a
+ * Team Cloud each audience's engine home holds its own copy of the same organization's answer, and the newest speaks. */
+export function createOrgModelBlocks(environments: () => AccountEnv[], apply: (blocked: ReadonlySet<string>) => void) {
+ let lastRead = "";
+ return {
+ async refresh(force = false): Promise<void> {
+ let newest: { path: string; mtimeMs: number; size: number } | null = null;
+ for (const env of environments()) {
+ if (CLOUD_BACKEND_ENV.some((key) => env[key])) return apply(new Set());
+ for (const path of claudeAccountFiles(env)) {
+ const found = await stat(path).catch(() => null);
+ if (!found?.isFile() || found.size === 0) continue;
+ if (!newest || found.mtimeMs > newest.mtimeMs) newest = { path, mtimeMs: found.mtimeMs, size: found.size };
+ break;
+ }
+ }
+ const read = newest ? `${newest.path}:${newest.mtimeMs}` : "none";
+ if (!force && read === lastRead) return;
+ lastRead = read;
+ if (!newest || newest.size > ACCOUNT_FILE_MAX_BYTES) return apply(new Set());
+ apply(parseOrgBlockedModels(await readFile(newest.path, "utf8").catch(() => "")));
+ },
+ };
+}
+
+const OFFICIAL_MODEL = /^claude-[a-z0-9.-]+$/;
+
+/** Both ids name Anthropic's own models and they differ. An alias, a local model, a cloud provider's id or the CLI's
+ * `<synthetic>` frames promise nothing to compare. */
+export function otherModelAnswered(picked: string | null | undefined, answered: unknown): answered is string {
+ if (!picked || typeof answered !== "string") return false;
+ const [asked, got] = [claudeModelKey(picked), claudeModelKey(answered)];
+ return OFFICIAL_MODEL.test(asked) && OFFICIAL_MODEL.test(got) && asked !== got;
+}
+
+const told = new WeakMap<object, Set<string>>();
+
+/** The line telling the person a turn came back from another model: once per engine session for each pair, since the
+ * model menu shows the same thing until they choose. A subagent's frame says nothing about the turn's own model. Null when
+ * there is nothing to tell. */
+export function modelSwapNotice(
+ session: object,
+ threadId: string,
+ picked: string | null | undefined,
+ frame: { parent_tool_use_id?: unknown; message?: { model?: unknown } },
+ catalog: ModelCatalog,
+): string | null {
+ const answered = frame.message?.model;
+ if (frame.parent_tool_use_id || !otherModelAnswered(picked, answered)) return null;
+ const said = told.get(session) ?? new Set<string>();
+ told.set(session, said);
+ const pair = `${claudeModelKey(picked!)} ${claudeModelKey(answered)}`;
+ if (said.has(pair)) return null;
+ said.add(pair);
+ const option = (id: string) => catalog.options.find((candidate) => claudeModelKey(candidate.id) === claudeModelKey(id));
+ const names = { picked: option(picked!)?.label ?? picked!, answered: option(answered)?.label ?? answered };
+ return serverLine(conversationLanguage(threadId), option(picked!)?.orgBlocked ? "server.model.orgBlockedAnswered" : "server.model.otherAnswered", names);
+}
diff --git a/server/drivers/claude.ts b/server/drivers/claude.ts
index ca2ee2e8ee..4823d840d1 100644
--- a/server/drivers/claude.ts
+++ b/server/drivers/claude.ts
@@ -39,7 +39,9 @@ import { assertToolScopeSupported } from "../../shared/tool-scope-support.ts";
import { newEventId, newId } from "../contracts.ts";
import { askInputSummary, commandSummary, toolDetailPreview } from "../tool-summary.ts";
import { classifyError, computeBackoff, interruptibleDelay, RETRY_MAX_ATTEMPTS, USAGE_LIMIT } from "./retry.ts";
-import { claudeApiErrorMessage, claudeLimitFacts, claudeLimitRefusal, claudeUsageLimit, claudeLimitMessage, type ClaudeLimit } from "./claude-limits.ts";
+import { claudeApiErrorMessage, claudeLimitFacts, claudeLimitRefusal, claudeUsageLimit, claudeLimitMessage, claudeVersionTooOld, type ClaudeLimit } from "./claude-limits.ts";
+import { createOrgModelBlocks, modelSwapNotice, withOrgBlocks } from "./claude-model-access.ts";
+import { engineHomes } from "../engine-homes/engine-homes.ts";
import { TEAM_TOOLS_FAILED, failedCustomMcp, teamToolsFailed } from "./team-tools.ts";
import { engineIdleMs, sessionIdlePolicy } from "./session-idle.ts";
import { promptHalves, withVolatileNote } from "./prompt-split.ts";
@@ -93,16 +95,6 @@ export function resolveClaudeConfigDir(configDir?: string, env: NodeJS.ProcessEn
return normalize(expanded);
}
-/** The API refusing a model newer than the installed CLI, relayed as an api-error frame ("Claude
- * Code 2.1.268 does not support this model; version 2.1.280 or newer is required…"); it names no model. */
-export function claudeVersionTooOld(
- frame: { error?: unknown; is_api_error_message?: unknown },
- text: string,
-): boolean {
- if (frame.is_api_error_message !== true && typeof frame.error !== "string") return false;
- return /\bClaude Code v?\d+(?:\.\d+)+ does not support this model\b/i.test(text);
-}
-
/** What an error `result` says failed: its `errors` (2.1.295: "No conversation found with session ID: …"), else its
* text in plain words, else its kind; never its synthetic message's "stop_sequence", nor the subtype "success". */
export function claudeResultError(frame: { errors?: unknown; result?: unknown; subtype?: unknown; terminal_reason?: unknown; api_error_status?: unknown }): string {
@@ -825,11 +817,13 @@ export const ClaudeDriver: ProviderDriver<ClaudeConfig> = {
console.error(`claude (${instanceId}): OMB_CLAUDE_INHERIT_USER_CONFIG=1 — bots inherit this machine's Claude Code MCP servers, skills, hooks and CLAUDE.md on every turn; remove it unless a bot needs a user-scope server`);
}
let models = config.managedModels ? { default: config.managedModels[0], options: config.managedModels.map(id => ({ id, label: id })) } : STATIC_CLAUDE_MODELS;
+ const orgBlocks = createOrgModelBlocks(() => engineHomes.everyHome(catalogEnv), (blocked) => { models = withOrgBlocks(models, blocked); });
const refreshModels = async () => {
if (config.managed) return;
try {
const resolved = await mergeLocalInject(readClaudeModelCatalog(catalogEnv), catalogEnv);
if (resolved.options.length) models = resolved;
+ await orgBlocks.refresh(true);
} catch {}
try { writeStartupModelCache(instanceId, models); } catch {}
};
@@ -1541,6 +1535,8 @@ export const ClaudeDriver: ProviderDriver<ClaudeConfig> = {
case "assistant": {
const msg = o.message ?? {};
const text = firstText(msg.content);
+ const swap = modelSwapNotice(session, threadId, session.turn?.input.model, o, models);
+ if (swap) emit({ ...base(threadId, currentTurnId()), type: "runtime.notice", message: swap });
// Signed out, the CLI answers with an api-error frame whose only content is "run /login".
if (claudeAuthFailure(o, text)) {
if (session.turn) session.turn.authFailed = session.turn.explained = true;
@@ -1633,6 +1629,7 @@ export const ClaudeDriver: ProviderDriver<ClaudeConfig> = {
session.turn.explained = true;
emit({ ...base(threadId, currentTurnId()), type: "runtime.error", message: claudeResultError(o) });
}
+ if (!config.managed) void orgBlocks.refresh();
// result.usage is per turn "in streaming-input sessions" (2.1.282) even on a retained
// process; total_cost_usd is the process's running total.
noteCostState(o.total_cost_usd, o.modelUsage, {
diff --git a/server/engine-homes/engine-homes.test.ts b/server/engine-homes/engine-homes.test.ts
index 5810ff9d3d..9a97152f51 100644
--- a/server/engine-homes/engine-homes.test.ts
+++ b/server/engine-homes/engine-homes.test.ts
@@ -36,6 +36,16 @@ describe("engine homes at run time", () => {
expect(withEngineHomes(instance, homes).adapter).toBe(adapter);
});
+ it("name every place an engine can run from: the server's HOME alone off a Team Cloud, each audience's home on one", () => {
+ const homes = new EngineHomes();
+ const env = { HOME: home };
+ expect(homes.everyHome(env)).toEqual([env]);
+ homes.start(setup());
+ const memberHome = audienceHome(dataDir, "member:p_bob");
+ mkdirSync(memberHome, { recursive: true });
+ expect(homes.everyHome(env)).toEqual([env, expect.objectContaining({ HOME: memberHome })]);
+ });
+
it("on a Team Cloud give a conversation's spawns its audience's home, made private, with the team's sign-in in it", () => {
const homes = new EngineHomes();
homes.start(setup());
diff --git a/server/engine-homes/engine-homes.ts b/server/engine-homes/engine-homes.ts
index d959607163..f6a910bcd9 100644
--- a/server/engine-homes/engine-homes.ts
+++ b/server/engine-homes/engine-homes.ts
@@ -68,6 +68,14 @@ export class EngineHomes {
return this.#migration;
}
+ /** The environment as an engine sees it from each place it can run: the server's HOME, and on a Team Cloud every
+ * audience's home too. */
+ everyHome(env: Record<string, string | undefined>): Array<Record<string, string | undefined>> {
+ const setup = this.#setup;
+ if (!setup) return [env];
+ return [env, ...audienceHomes(setup.dataDir).map((home) => homedSpawn(env, { dataDir: setup.dataDir, serverHome: setup.serverHome, home }).env)];
+ }
+
/** On a Team Cloud, inside a conversation: the spawn with HOME and the engines' folders in its audience's home, the
* home made, and the team's sign-ins in it. Null otherwise. */
forSpawn(env: Record<string, string | undefined>): HomedSpawn | null {
diff --git a/server/index.ts b/server/index.ts
index 1dc618abae..7aab33b3aa 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -9306,7 +9306,7 @@ const chiefPeerTargetRule = (noun: string) => (proposerBotId: string, targetBotI
};
const validateModelProposal = (selection: ModelSelection, current?: BotRecord): string | null => {
const checked = checkedModelSelection(selection, undefined, true);
- if (!checked.ok) return checked.error;
+ if (!checked.ok) return checked.error; if (registry.get(selection.instanceId)?.models.options.some((option) => option.id === selection.model && option.orgBlocked)) return "This account's organization turned that model off. Propose another one.";
if (current?.approvalGrant) return "Wait for the approval-level confirmation before changing this bot's model";
if (current) {
const mode = approvalModeFor(current);
diff --git a/server/startup-model-catalog.test.ts b/server/startup-model-catalog.test.ts
index af1e5e6a9a..d02d093961 100644
--- a/server/startup-model-catalog.test.ts
+++ b/server/startup-model-catalog.test.ts
@@ -8,7 +8,7 @@ import { createAcpDriver, type AcpSupport } from "./drivers/acp/core.ts";
import { ProviderRegistry } from "./harness/registry.ts";
import * as procs from "./procs.ts";
import { holdUntilFirstEngineRead } from "./first-engine-read.ts";
-import { openStartupModelCatalog, writeStartupModelCache } from "./startup-model-catalog.ts";
+import { openStartupModelCatalog, readStartupModelCache, writeStartupModelCache } from "./startup-model-catalog.ts";
const CACHED: ModelCatalog = {
default: "cached-model",
@@ -110,6 +110,11 @@ describe("startup model catalogs", () => {
rmSync(join(DATA_DIR, "providers", "engine-models"), { recursive: true, force: true });
});
+ it("keeps a model the organization turned off marked in the saved list, so no start offers it while its refresh waits", () => {
+ writeStartupModelCache("org-blocked", { default: "a", options: [{ id: "a", label: "A" }, { id: "b", label: "B", orgBlocked: true }] });
+ expect(readStartupModelCache("org-blocked")?.options[1]).toEqual({ id: "b", label: "B", orgBlocked: true });
+ });
+
it("does not wait for a slow refresh when a later start already has a catalog", async () => {
seedBots();
writeStartupModelCache("slow", CACHED);
diff --git a/server/startup-model-catalog.ts b/server/startup-model-catalog.ts
index fb4b9ff295..6fe3692390 100644
--- a/server/startup-model-catalog.ts
+++ b/server/startup-model-catalog.ts
@@ -49,6 +49,7 @@ function catalogFrom(value: unknown): ModelCatalog | null {
provider?: unknown;
contextWindow?: unknown;
variants?: unknown;
+ orgBlocked?: unknown;
};
if (typeof option.id !== "string" || typeof option.label !== "string") return null;
const variants = variantList(option.variants);
@@ -62,6 +63,7 @@ function catalogFrom(value: unknown): ModelCatalog | null {
? { contextWindow: option.contextWindow }
: {}),
...(variants ? { variants } : {}),
+ ...(option.orgBlocked === true ? { orgBlocked: true as const } : {}),
});
}
return { default: raw.default, options };
diff --git a/server/testing/fake-claude-cli.ts b/server/testing/fake-claude-cli.ts
index 5529482c48..55638a430b 100755
--- a/server/testing/fake-claude-cli.ts
+++ b/server/testing/fake-claude-cli.ts
@@ -10,6 +10,7 @@
// FAKE_CLAUDE_RATE_LIMIT JSON rate_limit_info reported in a `rate_limit_event` after init
// FAKE_CLAUDE_LIMITED_FILE path: while it exists, every turn plays usage-limit with the file's JSON rate_limit_info
// FAKE_CLAUDE_MCP_FAILED comma list of MCP servers init reports as failed (`mcp_servers`)
+// FAKE_CLAUDE_ANSWER_MODEL the `model` of its assistant frames, as when the CLI answers with another model than asked
// FAKE_CLAUDE_RELEASE with hang: the turn ends normally once this file exists; a scripted call's `hold` ends then too
// FAKE_CLAUDE_DUMP path for the latest turn's {argv, env, cwd, prompt, systemPrompt, mcpConfig}
// FAKE_CLAUDE_EXIT_AFTER_TURN 1: exit once the turn is answered, so later turns relaunch with --resume
@@ -257,7 +258,8 @@ const argAfter = (flag: string): string | null => {
return i === -1 ? null : (argv[i + 1] ?? null);
};
-const out = (obj: unknown) => process.stdout.write(JSON.stringify(obj) + "\n");
+const answerModel = process.env.FAKE_CLAUDE_ANSWER_MODEL;
+const out = (obj: any) => process.stdout.write(JSON.stringify(answerModel && obj.type === "assistant" && !obj.message?.model ? { ...obj, message: { ...obj.message, model: answerModel } } : obj) + "\n");
const contextGrowth = (() => {
const [start, perTurn] = (process.env.FAKE_CLAUDE_CONTEXT_GROWTH ?? "").split(":").map(Number);
return Number.isSafeInteger(start) && start! > 0 ? { start: start!, perTurn: Number.isSafeInteger(perTurn) ? perTurn! : 0 } : null;
diff --git a/src/components/AutomaticRecoverySettings.tsx b/src/components/AutomaticRecoverySettings.tsx
index 349f83c797..ff4d49381c 100644
--- a/src/components/AutomaticRecoverySettings.tsx
+++ b/src/components/AutomaticRecoverySettings.tsx
@@ -15,7 +15,7 @@ export function AutomaticRecoverySettings() {
const value = draft ?? state.config?.automaticRecovery ?? { enabled: false };
const engines = state.instances.filter((instance) => instance.snapshot.state === "available" && !instance.policy);
const engine = engines.find((instance) => instance.instanceId === value.backup?.instanceId);
- const models = engine?.models.options.filter((model) => engine.snapshot.authenticated !== false || model.custom) ?? [];
+ const models = engine?.models.options.filter((model) => !model.orgBlocked && (engine.snapshot.authenticated !== false || model.custom)) ?? [];
const ready = models.some((model) => model.id === value.backup?.model);
const change = (next: Recovery) => { setDraft(next); setError(""); };
const save = async () => {
diff --git a/src/components/ModelPicker.dom.test.ts b/src/components/ModelPicker.dom.test.ts
index 9e64d6cc53..7a06f135e7 100644
--- a/src/components/ModelPicker.dom.test.ts
+++ b/src/components/ModelPicker.dom.test.ts
@@ -315,3 +315,63 @@ describe("the floating menu and the pointer", () => {
expect(focused()).toBe(rows[1]);
});
});
+
+describe("a model the organization turned off", () => {
+ const blockedThree: Option[] = three.map((option) => option.id === "claude-sonnet-5-5" ? { ...option, orgBlocked: true } : option);
+ const row = () => document.querySelector<HTMLButtonElement>("[data-org-blocked]")!;
+
+ for (const advanced of [false, true]) {
+ const name = advanced ? "the full picker" : "the Simple menu";
+ it(`${name} keeps it visible, disabled, with the reason, and it cannot be picked`, async () => {
+ fixture.advanced = advanced;
+ fixture.instances = [claude(blockedThree)];
+ render();
+ await openWith("click");
+ expect(row().disabled).toBe(true);
+ expect(row().textContent).toContain("Sonnet 5.5");
+ expect(row().textContent).toContain("Turned off by your organization");
+ flushSync(() => row().click());
+ await settle();
+ expect(fixture.dispatch).not.toHaveBeenCalled();
+ expect(menu()).not.toBeNull();
+ });
+
+ it(`${name}: the arrows go past it`, async () => {
+ fixture.advanced = advanced;
+ fixture.instances = [claude(blockedThree)];
+ render();
+ await openWith("ArrowDown");
+ press("ArrowDown");
+ expect(focused()?.hasAttribute("data-org-blocked")).toBe(false);
+ expect(focused()?.textContent).toContain("Haiku 5.5");
+ });
+ }
+
+ it("a selection the organization turned off shows on the chip and the current row", async () => {
+ fixture.instances = [claude(blockedThree)];
+ render(scout("claude-sonnet-5-5"));
+ expect(chip().querySelector("[data-model-attention]")).not.toBeNull();
+ expect(chip().title).toContain("Turned off by your organization");
+ await openWith("click");
+ expect(document.querySelector("[data-current-model]")?.textContent).toContain("Turned off by your organization");
+ });
+
+ it("the current row of a blocked model has nothing to set up: tapping it just closes the menu", async () => {
+ fixture.instances = [claude(blockedThree)];
+ render(scout("claude-sonnet-5-5"));
+ await openWith("click");
+ flushSync(() => document.querySelector<HTMLButtonElement>("[data-current-model]")!.click());
+ await settle();
+ expect(menu()).toBeNull();
+ expect(fixture.dispatch).not.toHaveBeenCalled();
+ });
+
+ it("the full picker opens on a row it can focus when the selection is the blocked one", async () => {
+ fixture.advanced = true;
+ fixture.instances = [claude(blockedThree)];
+ render(scout("claude-sonnet-5-5"));
+ await openWith("ArrowDown");
+ expect(focused()?.hasAttribute("data-menu-row")).toBe(true);
+ expect((focused() as HTMLButtonElement).disabled).toBe(false);
+ });
+});
diff --git a/src/components/ModelPicker.tsx b/src/components/ModelPicker.tsx
index 09d7cf59e1..68afa834a6 100644
--- a/src/components/ModelPicker.tsx
+++ b/src/components/ModelPicker.tsx
@@ -300,7 +300,7 @@ export function ModelPicker({
focusOnPlace.current = null;
const find = (selector: string) => (selector ? menu?.querySelector<HTMLElement>(selector) : null);
const target = wanted === MENU_ITSELF ? menu
- : find(wanted) ?? find("[data-menu-search]") ?? find("[data-current-model]") ?? find("[data-menu-row]:not(:disabled)") ?? menu;
+ : find(wanted) ?? find("[data-menu-search]") ?? find("[data-current-model]:not(:disabled)") ?? find("[data-menu-row]:not(:disabled)") ?? menu;
target?.focus({ preventScroll: true });
target?.scrollIntoView?.({ block: "nearest" });
}, [open, placement]);
@@ -580,7 +580,7 @@ export function ModelPicker({
const attention = !active ? undefined
: active.policy ? t("policy.managedBy", { organization: active.policy.organizationName })
: needsCli(active) ? t("model.setupRequired")
- : needsSignIn(active) && !isCustomOnly(active) && !currentOption?.custom ? t("model.signInRequired") : undefined;
+ : needsSignIn(active) && !isCustomOnly(active) && !currentOption?.custom ? t("model.signInRequired") : currentOption?.orgBlocked ? t("model.orgBlocked") : undefined;
const summary = active
? `${active.displayName} · ${modelLabel(active, selection.model)}${
modelProvider(active, selection.model) ? ` · ${modelProvider(active, selection.model)}` : ""
diff --git a/src/components/ModelPickerFull.tsx b/src/components/ModelPickerFull.tsx
index 44c243f169..4bfe92a2c1 100644
--- a/src/components/ModelPickerFull.tsx
+++ b/src/components/ModelPickerFull.tsx
@@ -27,14 +27,18 @@ export function ModelRow({ option, current, defaultId, botModel = false, onPick
botModel?: boolean;
onPick: () => void;
}) {
- const meta = [option.provider, option.id === defaultId ? t("model.effort.default") : undefined].filter(Boolean).join(" · ");
+ const blocked = option.orgBlocked === true;
+ const meta = blocked ? t("model.orgBlocked") : [option.provider, option.id === defaultId ? t("model.effort.default") : undefined].filter(Boolean).join(" · ");
return (
<button
type="button"
data-menu-row
data-current-model={current || undefined}
+ data-org-blocked={blocked || undefined}
+ disabled={blocked}
aria-pressed={current}
- title={option.provider ? t("model.provider", { name: option.provider }) : undefined}
+ aria-label={blocked ? `${option.label} · ${t("model.orgBlocked")}` : undefined}
+ title={blocked ? t("model.orgBlocked") : option.provider ? t("model.provider", { name: option.provider }) : undefined}
onClick={onPick}
className={MENU_ROW}
>
diff --git a/src/components/SimpleModelMenu.tsx b/src/components/SimpleModelMenu.tsx
index fe87113b25..244b8fe6b4 100644
--- a/src/components/SimpleModelMenu.tsx
+++ b/src/components/SimpleModelMenu.tsx
@@ -51,13 +51,16 @@ function RowLines({ label, children }: { label: ReactNode; children?: ReactNode
function MenuModel({ instance, row, onPick }: { instance: InstanceInfo; row: MenuModelRow; onPick: SimpleMenuActions["onPick"] }) {
const { option } = row;
+ const reason = row.blocked ? t("model.orgBlocked") : undefined;
return (
<button
type="button"
data-menu-row
+ data-org-blocked={row.blocked || undefined}
+ disabled={row.blocked}
aria-pressed={row.current}
- aria-label={[option.label, option.provider].filter(Boolean).join(" · ")}
- title={[option.label, option.provider, modelBlurb(option)].filter(Boolean).join(" · ")}
+ aria-label={[option.label, option.provider, reason].filter(Boolean).join(" · ")}
+ title={[option.label, option.provider, reason ?? modelBlurb(option)].filter(Boolean).join(" · ")}
tabIndex={-1}
onClick={() => onPick(instance, row.model ?? option.id, row.variant)}
className={SIMPLE_MENU_ROW}
@@ -65,6 +68,7 @@ function MenuModel({ instance, row, onPick }: { instance: InstanceInfo; row: Men
<Gutter />
<RowLines label={row.label}>
{row.route && <span data-simple-route className={SIMPLE_MENU_META}>{row.route}</span>}
+ {reason && <span data-simple-org-blocked className={SIMPLE_MENU_META}>{reason}</span>}
</RowLines>
{row.current && <Check size={14} className="shrink-0 text-accent" aria-hidden="true" />}
</button>
@@ -228,7 +232,7 @@ export function SimpleModelMenu(props: SimpleModelMenuProps) {
aria-pressed="true"
title={current.title}
onClick={(event) => {
- const setUp = current.warning && current.instance && !current.instance.policy ? current.instance : undefined;
+ const setUp = current.warning && current.instance && !current.instance.policy && !current.blocked ? current.instance : undefined;
if (setUp) props.onSetUp(setUp, event.detail === 0);
else props.onPickCurrent();
}}
diff --git a/src/components/bot-settings/ModelSection.tsx b/src/components/bot-settings/ModelSection.tsx
index 281d315f3f..1f2a59fd63 100644
--- a/src/components/bot-settings/ModelSection.tsx
+++ b/src/components/bot-settings/ModelSection.tsx
@@ -83,7 +83,7 @@ export function FallbackChain({ bot, onChange }: { bot: Bot; onChange: (fallback
const nameOf = (instanceId: string) => state.instances.find((instance) => instance.instanceId === instanceId)?.displayName ?? instanceId;
const modelsOf = (entry: NonNullable<Bot["fallback"]>[number]) => {
const instance = state.instances.find((candidate) => candidate.instanceId === entry.instanceId);
- const offered = instance?.models.options.filter((model) => instance.snapshot.authenticated !== false || model.custom) ?? [];
+ const offered = instance?.models.options.filter((model) => !model.orgBlocked && (instance.snapshot.authenticated !== false || model.custom)) ?? [];
return offered.some((model) => model.id === entry.model) ? offered : [{ id: entry.model, label: entry.model }, ...offered];
};
diff --git a/src/lib/simple-model-menu.test.ts b/src/lib/simple-model-menu.test.ts
index 0563f47dee..1465a94faa 100644
--- a/src/lib/simple-model-menu.test.ts
+++ b/src/lib/simple-model-menu.test.ts
@@ -223,3 +223,24 @@ describe("the Simple model menu", () => {
expect(menu([claude(), codex, many], { query: "zzz" })).toMatchObject({ groups: [], results: 0 });
});
});
+
+describe("a model the organization turned off", () => {
+ const blockedModels = claudeModels.map((option) => option.id === "opus-5-5" ? { ...option, orgBlocked: true as const } : option);
+ const pick = (model: string) => ({ instanceId: "claude", model });
+ const menuOn = (model: string) => simpleModelMenu({
+ instances: [claude({}, blockedModels)], listed: [claude({}, blockedModels)], selection: pick(model),
+ bot: { name: "Scout", selection: pick(model) }, query: "", expanded: new Set(["claude"]), probing: new Set(), loading: false,
+ });
+
+ it("stays listed, marked, among the others", () => {
+ const body = menuOn("sonnet-5").groups[0]!.body;
+ if (body.kind !== "models") throw new Error("expected the models");
+ expect(body.rows.filter((row) => row.blocked).map((row) => row.option.id)).toEqual(["opus-5-5"]);
+ expect(body.rows.length).toBeGreaterThan(1);
+ });
+
+ it("says so on the current row, with nothing to set up", () => {
+ expect(menuOn("opus-5-5").current).toMatchObject({ warning: true, blocked: true, meta: "Turned off by your organization" });
+ expect(menuOn("sonnet-5").current?.blocked).toBeUndefined();
+ });
+});
diff --git a/src/lib/simple-model-menu.ts b/src/lib/simple-model-menu.ts
index c57c6393fe..2191463e76 100644
--- a/src/lib/simple-model-menu.ts
+++ b/src/lib/simple-model-menu.ts
@@ -19,6 +19,7 @@ export interface MenuModelRow {
label: string;
route?: string;
current: boolean;
+ blocked: boolean;
}
export type MenuGroupBody =
@@ -51,6 +52,8 @@ export interface MenuCurrent {
meta?: string;
warning: boolean;
pending: boolean;
+ /** The organization turned the selected model off: nothing to set up, only another model to pick. */
+ blocked?: boolean;
}
export interface SimpleMenu {
@@ -126,6 +129,7 @@ function currentRow(input: SimpleMenuInput): MenuCurrent {
const row = { instance: active, label: modelName(active, selection.model), title: active ? `${active.displayName} · ${name}` : name, warning: false, pending: false };
if (!active) return loading ? { ...row, pending: true } : { ...row, meta: t("model.simple.unavailable"), warning: true };
if (!option && input.refreshing === active.instanceId) return { ...row, pending: true };
+ if (option?.orgBlocked) return { ...row, meta: t("model.orgBlocked"), warning: true, blocked: true };
if (active.policy) return { ...row, meta: t("policy.managedBy", { organization: active.policy.organizationName }), warning: true };
if (needsCli(active)) return { ...row, meta: t("model.setupRequired"), warning: true };
if (needsSignIn(active) && !isCustomOnly(active) && !option?.custom) return { ...row, meta: t("model.signInRequired"), warning: true };
@@ -162,6 +166,7 @@ export function simpleModelMenu(input: SimpleMenuInput): SimpleMenu {
label: shortModelLabel(option.label, provider),
...(repeated.has(option.label) && option.provider ? { route: option.provider } : {}),
current: currentSelection ? choiceIsSelected(option, currentSelection) : false,
+ blocked: option.orgBlocked === true,
});
const mixed = own.length > 0 && own.length < all.length;
if (query) {
diff --git a/src/lib/team-bulk-settings.test.ts b/src/lib/team-bulk-settings.test.ts
index 4ae7174d8e..ef2633a153 100644
--- a/src/lib/team-bulk-settings.test.ts
+++ b/src/lib/team-bulk-settings.test.ts
@@ -128,6 +128,14 @@ describe("team-wide settings", () => {
expect(planTeamChange([bot("busy", { busy: true })], instances, { kind: "model", model: "sonnet" })[0]).toMatchObject({ status: "skip" });
});
+ it("offers no model the organization turned off, nor applies one", () => {
+ const blocked = instances.map((instance) => instance.instanceId === "claude"
+ ? { ...instance, models: { default: "sonnet", options: instance.models.options.map((option) => option.id === "opus" ? { ...option, orgBlocked: true as const } : option) } }
+ : instance);
+ expect(teamModelChoices([bot("a")], blocked).map((choice) => choice.id)).not.toContain("opus");
+ expect(planTeamChange([bot("a")], blocked, { kind: "model", model: "opus" })[0]).toMatchObject({ status: "skip" });
+ });
+
it("lists each model once with the engines offering it, and only effort levels some engine offers", () => {
const bots = [bot("a"), bot("b", { modelSelection: { instanceId: "codex", model: "gpt-5" } })];
expect(teamModelChoices(bots, instances).map((choice) => `${choice.id}:${choice.engines.join("+")}`))
diff --git a/src/lib/team-bulk-settings.ts b/src/lib/team-bulk-settings.ts
index d963f2c06b..e039bbc892 100644
--- a/src/lib/team-bulk-settings.ts
+++ b/src/lib/team-bulk-settings.ts
@@ -42,7 +42,7 @@ export function teamModelChoices(bots: readonly Bot[], instances: readonly Insta
const engine = engineOf(bot, instances);
if (!engine || seen.has(engine.instanceId)) continue;
seen.add(engine.instanceId);
- const ids = [engine.models.default, ...engine.models.options.map((option) => option.id)].filter((id) => id.trim());
+ const ids = [engine.models.default, ...engine.models.options.filter((option) => !option.orgBlocked).map((option) => option.id)].filter((id) => id.trim());
for (const id of new Set(ids)) {
const label = engine.models.options.find((option) => option.id === id)?.label ?? id;
const entry = choices.get(id) ?? { id, label, engines: [] };
@@ -77,7 +77,7 @@ export function planTeamChange(bots: readonly Bot[], instances: readonly Instanc
const current = bot.modelSelection;
if (!engine) return { bot, status: "skip", reason: t("teamSettings.skip.engineMissing") };
const model = change.model ?? current.model;
- const offered = model === engine.models.default || engine.models.options.some((option) => option.id === model);
+ const offered = model === engine.models.default || engine.models.options.some((option) => option.id === model && !option.orgBlocked);
if (!offered) return { bot, status: "skip", reason: t("teamSettings.skip.modelUnsupported", { engine: engineName, model }) };
const next: ModelSelection = { instanceId: current.instanceId, model };
if (current.variant && model === current.model) next.variant = current.variant;
diff --git a/src/locales/de.json b/src/locales/de.json
index 61461aca31..68649287a6 100644
--- a/src/locales/de.json
+++ b/src/locales/de.json
@@ -73,6 +73,8 @@
"server.runs.state.queued": "wartet auf den Start",
"server.runs.state.running": "läuft",
"server.incidents.failed": "Vorfall: Die Ausführung von {bot} {where} ist fehlgeschlagen",
+ "server.model.orgBlockedAnswered": "{picked} wurde von deiner Organisation deaktiviert, daher hat stattdessen {answered} geantwortet. Wähle ein anderes Modell, damit dieser Hinweis nicht mehr erscheint.",
+ "server.model.otherAnswered": "Du hast {picked} gewählt, aber {answered} hat stattdessen geantwortet.",
"server.incidents.failedWhy": "Vorfall: Die Ausführung von {bot} {where} ist fehlgeschlagen: „{detail}“",
"server.incidents.stalled": "Vorfall: Die Ausführung von {bot} {where} wurde gestoppt, weil sie keine Aktivität mehr zeigte",
"server.incidents.stalledWhy": "Vorfall: Die Ausführung von {bot} {where} wurde gestoppt, weil sie keine Aktivität mehr zeigte: „{detail}“",
diff --git a/src/locales/en.json b/src/locales/en.json
index aae02c4772..e7f0b5e0f8 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -170,6 +170,8 @@
"server.runs.state.queued": "queued",
"server.runs.state.running": "running",
"server.incidents.failed": "Incident: {bot}'s run {where} failed",
+ "server.model.orgBlockedAnswered": "{picked} is turned off by your organization, so {answered} answered instead. Choose another model to stop seeing this.",
+ "server.model.otherAnswered": "You chose {picked}, but {answered} answered instead.",
"server.incidents.failedWhy": "Incident: {bot}'s run {where} failed: \"{detail}\"",
"server.incidents.stalled": "Incident: {bot}'s run {where} stopped after showing no activity",
"server.incidents.stalledWhy": "Incident: {bot}'s run {where} stopped after showing no activity: \"{detail}\"",
@@ -2748,6 +2750,7 @@
"model.simple.reasoning": "Reasoning",
"model.simple.botsModel": "{name}'s model",
"model.simple.unavailable": "Unavailable",
+ "model.orgBlocked": "Turned off by your organization",
"model.simple.signIn": "Sign in",
"model.simple.lookingModels": "Looking for models…",
"model.simple.useDefault": "Use default",
diff --git a/src/locales/ko.json b/src/locales/ko.json
index 39ccab8658..7dd05255fa 100644
--- a/src/locales/ko.json
+++ b/src/locales/ko.json
@@ -2622,6 +2622,7 @@
"model.simple.reasoning": "추론",
"model.simple.botsModel": "{name}의 모델",
"model.simple.unavailable": "사용 불가",
+ "model.orgBlocked": "조직에서 꺼 둔 모델이에요",
"model.simple.signIn": "로그인",
"model.simple.lookingModels": "모델 찾는 중…",
"model.simple.useDefault": "기본값 사용",
diff --git a/src/locales/zh.json b/src/locales/zh.json
index 31c550027e..cb64fe0097 100644
--- a/src/locales/zh.json
+++ b/src/locales/zh.json
@@ -170,6 +170,8 @@
"server.runs.state.queued": "正在排队",
"server.runs.state.running": "正在运行",
"server.incidents.failed": "事件:{bot} {where} 的执行失败了",
+ "server.model.orgBlockedAnswered": "{picked} 已被你的组织关闭,因此改由 {answered} 回答。选择其他模型后就不会再看到这条提示。",
+ "server.model.otherAnswered": "你选择的是 {picked},但实际由 {answered} 回答。",
"server.incidents.failedWhy": "事件:{bot} {where} 的执行失败了:「{detail}」",
"server.incidents.stalled": "事件:{bot} {where} 的执行因没有任何活动而被停止",
"server.incidents.stalledWhy": "事件:{bot} {where} 的执行因没有任何活动而被停止:「{detail}」",
@@ -2744,6 +2746,7 @@
"model.simple.reasoning": "推理",
"model.simple.botsModel": "{name} 的模型",
"model.simple.unavailable": "不可用",
+ "model.orgBlocked": "已被你的组织关闭",
"model.simple.signIn": "登录",
"model.simple.lookingModels": "正在查找模型…",
"model.simple.useDefault": "使用默认",
diff --git a/src/state/store.tsx b/src/state/store.tsx
index a73ac97ecb..16f33eadd1 100644
--- a/src/state/store.tsx
+++ b/src/state/store.tsx
@@ -490,7 +490,7 @@ export interface InstanceInfo {
aiTest?: import("../../shared/ai-ranking").AiTestState;
/** Why it didn't answer, in plain words, when it said (signed out, a used-up limit…). */
aiTestError?: string;
- models: { default: string; options: Array<{ id: string; label: string; custom?: boolean; loaded?: boolean; provider?: string; variants?: ModelVariantOption[] }> };
+ models: { default: string; options: Array<{ id: string; label: string; custom?: boolean; loaded?: boolean; provider?: string; variants?: ModelVariantOption[]; orgBlocked?: true }> };
capabilities?: {
computerMcp?: boolean;
agentsMcp?: boolean;