Skip to content

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

fix(limits): name a backup's refusal before saying it is signed out

laijsg12df80c2e64fb
diff --git a/server/host/limit-takeover.test.ts b/server/host/limit-takeover.test.ts
index 9a8180151f..2a8d601141 100644
--- a/server/host/limit-takeover.test.ts
+++ b/server/host/limit-takeover.test.ts
@@ -164,6 +164,20 @@ describe("which AI carries on while one is limited", () => {
]);
});
+ it("names what keeps a backup from running: the refusal before a sign-in, which a custom endpoint never needs", () => {
+ const custom = engine("cursor", "cursorAgent", ["auto"], { access: "custom", snapshot: { state: "available", authenticated: false } });
+ const signedOutCodex = engine("codex-2", "codex", ["gpt-6"], { snapshot: { state: "available", authenticated: false } });
+ const signedOutBlocked = engine("codex-3", "codex", ["gpt-6"], { snapshot: { state: "available", authenticated: false } });
+ const blocked = new Set(["cursor", "codex-3"]);
+ const { instance } = takeover({ engines: () => [CLAUDE, custom, signedOutCodex, signedOutBlocked], context: { refusal: (one) => blocked.has(one.instanceId) ? "Your organisation blocks this endpoint." : undefined },
+ chosen: () => [on("cursor", "auto"), on("codex-2", "gpt-6"), on("codex-3", "gpt-6")] });
+ expect(instance.weighBackups("kai", on("claude", "claude-opus-5-5")).skipped).toEqual([
+ { selection: on("cursor", "auto"), why: "not-ready", detail: "Your organisation blocks this endpoint." },
+ { selection: on("codex-2", "gpt-6"), why: "not-ready", detail: "signed out" },
+ { selection: on("codex-3", "gpt-6"), why: "not-ready", detail: "Your organisation blocks this endpoint." },
+ ]);
+ });
+
it("says a backup is at its own limit, holding that model, signed out, or one the thread's approval level must ask about", () => {
const chosen = { chosen: () => [on("claude", "claude-opus-5-5"), on("opencode", "go-default")] };
const limited = takeover({ blockedUntil: (id) => (id === "claude" ? NOW + HOUR : null), ...chosen }).instance;
diff --git a/server/host/limit-takeover.ts b/server/host/limit-takeover.ts
index ca993599f1..47f45e0a41 100644
--- a/server/host/limit-takeover.ts
+++ b/server/host/limit-takeover.ts
@@ -9,7 +9,7 @@ import { approvalModeFor, modelSwitchNeedsAsk, type ApprovalMode } from "../../s
import { writeFileAtomic } from "../atomic.ts";
import { recoveryCapabilityError } from "../automatic-recovery.ts";
import type { InstanceConfigMap, ProviderAdapter, RuntimeEvent } from "../contracts.ts";
-import { readyToRun, type DefaultSelectionContext, type SelectableInstance } from "../default-model-selection.ts";
+import { readyToRun, signedOut as statusSignedOut, type DefaultSelectionContext, type SelectableInstance } from "../default-model-selection.ts";
import { engineFailureKind } from "../drivers/engine-errors.ts";
import { classifyError } from "../drivers/retry.ts";
import { failoverLine, limitBackupAllowed, signedOutLine, type LimitFailover } from "../limit-failover.ts";
@@ -170,7 +170,7 @@ export function createLimitTakeover(deps: LimitTakeoverDeps) {
const notReady = (engine: TakeoverEngine): string => engine.enabled === false ? "switched off"
: engine.snapshot.state !== "available" ? engine.snapshot.reason ?? "unavailable"
- : engine.snapshot.authenticated === false ? "signed out" : deps.context.refusal?.(engine) ?? "not ready";
+ : deps.context.refusal?.(engine) ?? (statusSignedOut(engine) ? "signed out" : "not ready");
const skipped = (engines: TakeoverEngine[], current: TakeoverEngine, selection: ModelSelection, scope: TakeoverScope, approval?: ApprovalMode): Omit<SkippedBackup, "selection"> | null => {
const engine = engines.find((candidate) => candidate.instanceId === selection.instanceId);