Skip to content

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

Keep 200K compaction for other [1m] models; resolve the turn model before the CLI check

AdityaUmalebaf0898df7aa
diff --git a/server/drivers/claude.test.ts b/server/drivers/claude.test.ts
index cb284e0bd6..dc70339e70 100644
--- a/server/drivers/claude.test.ts
+++ b/server/drivers/claude.test.ts
@@ -1707,7 +1707,7 @@ describe("ClaudeDriver turns (fake CLI)", () => {
expect(seen.argv[seen.argv.indexOf("--autocompact") + 1]).toBe("200000");
});
- it("compacts a [1m] model's CLI session at 1M", async () => {
+ it("compacts a Claude Opus 5.5 (1M) CLI session at 1M", async () => {
await create();
await instance.snapshot();
const dump = join(scratch, "compact-1m.json");
@@ -1731,10 +1731,11 @@ describe("ClaudeDriver turns (fake CLI)", () => {
expect(autoCompactWindow({ OMB_CLAUDE_AUTOCOMPACT: "off" })).toBe(null);
});
- it("compacts at 1M by default only for a model picked with the [1m] suffix", () => {
+ it("compacts at 1M by default only for the Claude Opus 5.5 (1M) pick", () => {
expect(autoCompactWindow({}, "claude-opus-5-5[1m]")).toBe("1000000");
expect(autoCompactWindow({ OMB_CLAUDE_AUTOCOMPACT: "nonsense" }, "claude-opus-5-5[1m]")).toBe("1000000");
expect(autoCompactWindow({}, "claude-opus-5-5")).toBe("200000");
+ expect(autoCompactWindow({}, "claude-sonnet-4-6[1m]")).toBe("200000");
expect(autoCompactWindow({}, null)).toBe("200000");
expect(autoCompactWindow({ OMB_CLAUDE_AUTOCOMPACT: "300000" }, "claude-opus-5-5[1m]")).toBe("300000");
expect(autoCompactWindow({ OMB_CLAUDE_AUTOCOMPACT: "off" }, "claude-opus-5-5[1m]")).toBe(null);
diff --git a/server/drivers/claude.ts b/server/drivers/claude.ts
index 8427ddd327..241f31ffcf 100644
--- a/server/drivers/claude.ts
+++ b/server/drivers/claude.ts
@@ -179,13 +179,13 @@ export function readClaudeAuthSettings(
}
}
-/** OMB_CLAUDE_AUTOCOMPACT: a token count, "auto" (the CLI's own window) or "off"; unset, 1M for a `[1m]` model, else 200K.
+/** OMB_CLAUDE_AUTOCOMPACT: a token count, "auto" (the CLI's own window) or "off"; unset, 1M for the "Claude Opus 5.5 (1M)" pick, else 200K.
* The CLI rejects a window outside 100k-1M as an argument error, so a configured value is clamped. */
export function autoCompactWindow(env: NodeJS.ProcessEnv, model?: string | null): string | null {
const raw = (env.OMB_CLAUDE_AUTOCOMPACT ?? "").trim().toLowerCase();
if (raw === "off") return null;
if (raw === "auto") return "auto";
- const fallback = model && /\[1m\]$/i.test(model) ? 1_000_000 : DEFAULT_AUTOCOMPACT_TOKENS, parsed = raw ? Number(raw) : fallback;
+ const fallback = model?.toLowerCase() === "claude-opus-5-5[1m]" ? 1_000_000 : DEFAULT_AUTOCOMPACT_TOKENS, parsed = raw ? Number(raw) : fallback;
if (!Number.isFinite(parsed) || parsed <= 0) return String(fallback);
return String(Math.min(1_000_000, Math.max(100_000, Math.floor(parsed))));
}
@@ -1034,6 +1034,8 @@ export const ClaudeDriver: ProviderDriver<ClaudeConfig> = {
if (turn.guestConfined) args.push("--restricted", "--tools", GUEST_CLAUDE_TOOLS.join(","));
else if (config.tools !== undefined) args.push("--tools", config.tools.join(","));
const turnEnvironment = environment();
+ const turnModel = config.managed ? turn.model : await resolveClaudeTurnModel(turn.model, turnEnvironment, config.endpointModels);
+ const injected = config.managed || config.endpointModels ? { model: turnModel ?? null, injected: false } : applyClaudeInject({ ...turnEnvironment }, turnModel);
const launchCli = findCliCandidates(config.cli, turnEnvironment.PATH ?? "")[0]; await ensureCliVersion(turnEnvironment);
for (let tries = 0; tries < 2 && cliVersionChecked && cliProbedAt !== launchCli; tries++) await ensureCliVersion(turnEnvironment); // another copy's late check landed while this turn waited
const ownCli = cliProbedAt === launchCli, turnCliVersion = ownCli ? cliVersion : null; // still another copy's state: none of its flags, its version counts as unknown
@@ -1054,8 +1056,6 @@ export const ClaudeDriver: ProviderDriver<ClaudeConfig> = {
if (projectSettingsOnly) args.push("--setting-sources", "project");
if (turn.userSkillsDir) args.push("--add-dir", turn.userSkillsDir);
}
- const turnModel = config.managed ? turn.model : await resolveClaudeTurnModel(turn.model, turnEnvironment, config.endpointModels);
- const injected = config.managed || config.endpointModels ? { model: turnModel ?? null, injected: false } : applyClaudeInject({ ...turnEnvironment }, turnModel);
const compactWindow = autoCompactWindow(turnEnvironment, injected.model);
const passedAutocompact = Boolean(compactWindow) && ownCli && cliHasAutocompact === true; if (compactWindow && passedAutocompact) args.push("--autocompact", compactWindow);
// --resume keeps the recorded system prompt, so every turn refreshes it.
diff --git a/server/index.ts b/server/index.ts
index d235194968..05d5319fba 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -5208,7 +5208,7 @@ cacheKeepWarmStatus = (threadId) => cacheKeepWarm.status(threadId);
// Warm summaries (server/host/warm-summary-host.ts): a long conversation is summarized while it is idle, not at its next turn.
const warmSummaries = createWarmSummaryHost({ store, instance: (id) => registry.get(id), queued: hasQueuedSteeredMessages, coordinator, waits: () => botWaits, routines: () => routines,
enabled: () => cfg.context?.autoCompact !== false && process.env.OMB_WARM_SUMMARY !== "0" && spendState(cfg, DATA_DIR)?.exceeded !== true, memoryShort: () => engineMemory.headroom() < 0.3,
- nativeCompactAt: ({ botId, threadId, instanceId }) => { const instance = registry.get(instanceId), at = instance ? nativeCompactTokens(instance, botForThread(botId, threadId)?.modelSelection.model) : undefined; return at && Number.isFinite(at) ? at : undefined; },
+ nativeCompactAt: ({ botId, threadId, instanceId }) => { const instance = registry.get(instanceId), measured = store.taskByThread(botId, threadId)?.lastContextModel, at = instance ? nativeCompactTokens(instance, measured?.startsWith(`${instanceId}:`) ? measured.slice(instanceId.length + 1) : botForThread(botId, threadId)?.modelSelection.model) : undefined; return at && Number.isFinite(at) ? at : undefined; },
busy: (botId, threadId) => threadBusy(botId, threadId) || botHasActiveTurn(botId), keepWarmUntil: (threadId) => cacheKeepWarm.status(threadId)?.until, book: bookForkUsage, log: (line) => console.info(line), language: threadLanguage,
fold: async ({ botId, threadId, instanceId }, idle) => { const bot = store.projectBotForTask(botId, threadId), model = store.taskByThread(botId, threadId)?.lastContextModel, instance = registry.get(instanceId), before = latestCompaction(store.activePath(threadId))?.id;
if (bot && instance && model?.startsWith(`${instanceId}:`)) await compactConversation({ bot, threadId, generation: `idle:${randomUUID()}`, instance, model: model.slice(instanceId.length + 1), excludedIds: new Set(), manual: false, idle });