Skip to content

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

Codex compact: the test-only timeout knob follows the FAKE_CODEX_ convention

milind-soni1f03dec3ca8d
diff --git a/server/bot-box/env.test.ts b/server/bot-box/env.test.ts
index bc6aabf84e..e0851d8c76 100644
--- a/server/bot-box/env.test.ts
+++ b/server/bot-box/env.test.ts
@@ -27,7 +27,7 @@ const SERVER_ONLY_OMB: ReadonlySet<string> = new Set([
"OMB_CLOUD_PUBLIC_HOST", "OMB_CLOUD_ROLE", "OMB_CLOUD_SECRETS_FD", "OMB_CLOUD_STAGING",
"OMB_CLOUD_STOPPED_HOLD_DAYS", "OMB_CLOUD_TEAM_ID", "OMB_CLOUD_TEAM_LANGUAGE", "OMB_CLOUD_TEAM_NAME",
"OMB_CLOUD_TRUSTED_PROXIES", "OMB_CLOUD_TUNNEL_BIN", "OMB_CLOUD_TUNNEL_TOKEN", "OMB_CLOUD_VOICE_TOKEN",
- "OMB_CLOUD_VOICE_URL", "OMB_CLOUD_X_TOKEN", "OMB_CLOUD_X_URL", "OMB_CODEX_COMPACT_TIMEOUT_MS", "OMB_CODEX_LAUNCH_SLOTS", "OMB_CODEX_SESSION_IDLE_", "OMB_CODEX_SESSION_KEEP", "OMB_COMPANION_DIR",
+ "OMB_CLOUD_VOICE_URL", "OMB_CLOUD_X_TOKEN", "OMB_CLOUD_X_URL", "OMB_CODEX_LAUNCH_SLOTS", "OMB_CODEX_SESSION_IDLE_", "OMB_CODEX_SESSION_KEEP", "OMB_COMPANION_DIR",
"OMB_COMPANION_HOSTED_URL", "OMB_COMPANION_INTERNAL_ORIGIN", "OMB_COMPANION_PORT", "OMB_COMPANION_ROUTES",
"OMB_COMPANION_TAILNET_NAME", "OMB_COMPOSIO_API", "OMB_COMPOSIO_BROKER", "OMB_COMPOSIO_BROKER_TOKEN",
"OMB_COMPOSIO_BROKER_URL", "OMB_COMPOSIO_TOOLKITS_API", "OMB_COMPUTER_CALL_ACT_WITHIN_MS",
diff --git a/server/drivers/codex-compact.test.ts b/server/drivers/codex-compact.test.ts
index 4ec8e7ad94..9346d5c1c6 100644
--- a/server/drivers/codex-compact.test.ts
+++ b/server/drivers/codex-compact.test.ts
@@ -239,7 +239,7 @@ describe("Codex's own compaction of a kept app-server's thread (fake app-server)
describe("a configuration read that never answers", () => {
it.each(["deadline", "stop", "exit", "stopAll"] as const)("ends on %s with the connection closed, and the conversation's next message goes through", async (how) => {
- if (how === "deadline") vi.stubEnv("OMB_CODEX_COMPACT_TIMEOUT_MS", "300");
+ if (how === "deadline") vi.stubEnv("FAKE_CODEX_COMPACT_TIMEOUT_MS", "300");
const { threadId, session, pid } = await kept({ FAKE_CODEX_CONFIG_HANG_AFTER_TURNS: "1" });
const stop = new AbortController();
const pending = compact(threadId, session, { signal: stop.signal });
@@ -259,7 +259,7 @@ describe("Codex's own compaction of a kept app-server's thread (fake app-server)
describe("the compaction's own configuration read never answering", () => {
it.each(["deadline", "stop", "exit"] as const)("ends on %s with the connection closed and no request sent, and the conversation's next message goes through", async (how) => {
- if (how === "deadline") vi.stubEnv("OMB_CODEX_COMPACT_TIMEOUT_MS", "300");
+ if (how === "deadline") vi.stubEnv("FAKE_CODEX_COMPACT_TIMEOUT_MS", "300");
const hang = join(scratch, "config-hang");
const { threadId, session, pid } = await kept({ FAKE_CODEX_CONFIG_HANG_FILE: hang });
writeFileSync(hang, "");
@@ -315,7 +315,7 @@ describe("Codex's own compaction of a kept app-server's thread (fake app-server)
});
it("fails at its deadline, with the connection closed", async () => {
- vi.stubEnv("OMB_CODEX_COMPACT_TIMEOUT_MS", "400");
+ vi.stubEnv("FAKE_CODEX_COMPACT_TIMEOUT_MS", "400");
const { threadId, session, pid } = await kept({ FAKE_CODEX_COMPACT: "hang" });
await expect(compact(threadId, session)).resolves.toMatchObject({ ok: false, reason: "timed out" });
expect(alive(pid)).toBe(false);
diff --git a/server/drivers/codex-compact.ts b/server/drivers/codex-compact.ts
index e7011398dc..96701d902c 100644
--- a/server/drivers/codex-compact.ts
+++ b/server/drivers/codex-compact.ts
@@ -3,7 +3,7 @@ import { codexConfigDigest, codexOutsideIdentity, type CodexConnection, type Cod
import { appendNative } from "./native.ts";
const DEFAULT_TIMEOUT_MS = 120_000;
-const timeoutMs = (): number => Number(process.env.OMB_CODEX_COMPACT_TIMEOUT_MS) > 0 ? Number(process.env.OMB_CODEX_COMPACT_TIMEOUT_MS) : DEFAULT_TIMEOUT_MS;
+const timeoutMs = (): number => Number(process.env.FAKE_CODEX_COMPACT_TIMEOUT_MS) > 0 ? Number(process.env.FAKE_CODEX_COMPACT_TIMEOUT_MS) : DEFAULT_TIMEOUT_MS;
const graceMs = (): number => Math.max(1, Number(process.env.FAKE_CODEX_INTERRUPT_GRACE_MS ?? 750) || 750);
const sleep = (ms: number) => new Promise<void>((wake) => { const timer = setTimeout(wake, ms); timer.unref?.(); });