Skip to content

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

feat(codex): a Fast row for each Codex model that offers Fast

Bugfixer 29816664cd4ac
diff --git a/server/drivers/codex-catalog.test.ts b/server/drivers/codex-catalog.test.ts
index 3d5adab70e..ff31e73178 100644
--- a/server/drivers/codex-catalog.test.ts
+++ b/server/drivers/codex-catalog.test.ts
@@ -48,6 +48,14 @@ describe("decodeCodexSelection", () => {
});
});
+ it("reads a Fast row as its base model on the Fast tier", () => {
+ expect(decodeCodexSelection("gpt-5.6-sol+priority")).toEqual({
+ model: "gpt-5.6-sol",
+ modelProvider: OFFICIAL_CODEX_PROVIDER,
+ serviceTier: "priority",
+ });
+ });
+
it("splits provider-encoded custom ids", () => {
expect(decodeCodexSelection("omlx::Qwen3.6-35B-A3B-bf16:qwen3-5-6-n-r-reasoning")).toEqual({
model: "Qwen3.6-35B-A3B-bf16:qwen3-5-6-n-r-reasoning",
@@ -80,6 +88,24 @@ describe("readCodexModelCatalog", () => {
});
});
+ it("adds a Fast row after each model that offers Fast and does not already run on it", async () => {
+ chmodSync(FAKE_CLI, 0o755);
+ const catalog = await readCodexModelCatalog(
+ { HOME: join(tmpdir(), "omb-codex-app-server-tiers"), PATH: process.env.PATH, FAKE_CODEX_TIERS: "1" },
+ fetch,
+ FAKE_CLI,
+ );
+
+ expect(catalog).toEqual({
+ default: "gpt-fake-default",
+ options: [
+ { id: "gpt-fake-default", label: "GPT Fake Default" },
+ { id: "gpt-fake-default+priority", label: "GPT Fake Default · Fast" },
+ { id: "gpt-page-two", label: "GPT Page Two" },
+ ],
+ });
+ });
+
it("appends the configured local model and cached catalog slugs as custom", async () => {
const home = scratchHome({
"config.toml": `
diff --git a/server/drivers/codex-catalog.ts b/server/drivers/codex-catalog.ts
index b2e4e91314..062b88fba4 100644
--- a/server/drivers/codex-catalog.ts
+++ b/server/drivers/codex-catalog.ts
@@ -39,9 +39,14 @@ export function encodeCodexSelection(provider: string, model: string): string {
return `${provider}${SEP}${model}`;
}
+/** An official row run on one of its model's service tiers (`gpt-5.5+priority`, the catalog's Fast). The driver sends
+ * the tier as turn/start's `serviceTierForTurn`: that turn only, so the thread's own tier stays and a plain row is standard. */
+const TIERED_ID = /^(.+)\+([a-z][a-z0-9_-]*)$/i;
+
export function decodeCodexSelection(id: string | null | undefined): {
model: string | null;
modelProvider: string | null;
+ serviceTier?: string;
} {
if (!id) return { model: null, modelProvider: null };
const sep = id.indexOf(SEP);
@@ -49,7 +54,10 @@ export function decodeCodexSelection(id: string | null | undefined): {
return { model: id.slice(sep + SEP.length), modelProvider: id.slice(0, sep) };
}
// A bare id is official: a new cloud model must not fall through to the user's local provider.
- return { model: id, modelProvider: MODEL_ID.test(id) ? OFFICIAL_CODEX_PROVIDER : null };
+ if (!MODEL_ID.test(id)) return { model: id, modelProvider: null };
+ const tiered = TIERED_ID.exec(id);
+ if (tiered) return { model: tiered[1], modelProvider: OFFICIAL_CODEX_PROVIDER, serviceTier: tiered[2] };
+ return { model: id, modelProvider: OFFICIAL_CODEX_PROVIDER };
}
/** Starts Codex on the chosen model's provider. codex-cli 0.167.0 refuses a turn whose thread provider differs from its
@@ -64,6 +72,21 @@ interface CodexAppServerModel {
displayName?: unknown;
hidden?: unknown;
isDefault?: unknown;
+ serviceTiers?: unknown;
+ defaultServiceTier?: unknown;
+}
+
+const FAST_TIER = /fast/i;
+
+/** The model's Fast tier (codex-cli 0.167 lists `{id: "priority", name: "Fast"}`), unless it already runs on it. */
+function fastTier(row: CodexAppServerModel): { id: string; name: string } | null {
+ if (!Array.isArray(row.serviceTiers)) return null;
+ for (const tier of row.serviceTiers) {
+ const id = tier?.id, name = tier?.name;
+ if (typeof id !== "string" || typeof name !== "string" || !FAST_TIER.test(name) || !PROVIDER_ID.test(id)) continue;
+ return id === row.defaultServiceTier ? null : { id, name };
+ }
+ return null;
}
/** The installed Codex CLI's own ChatGPT catalog, every page: it changes more often than our releases. */
@@ -154,10 +177,10 @@ export function readCodexAppServerModelCatalog(
for (const row of models) {
if (row.hidden === true || typeof row.id !== "string" || !MODEL_ID.test(row.id) || seen.has(row.id)) continue;
seen.add(row.id);
- options.push({
- id: row.id,
- label: typeof row.displayName === "string" && row.displayName.trim() ? row.displayName : row.id,
- });
+ const label = typeof row.displayName === "string" && row.displayName.trim() ? row.displayName : row.id;
+ options.push({ id: row.id, label });
+ const fast = fastTier(row);
+ if (fast && !TIERED_ID.test(row.id)) options.push({ id: `${row.id}+${fast.id}`, label: `${label} · ${fast.name}` });
if (row.isDefault === true) defaultModel = row.id;
}
if (!options.length) {
diff --git a/server/drivers/codex.test.ts b/server/drivers/codex.test.ts
index f37d5230cf..fca74a38cd 100644
--- a/server/drivers/codex.test.ts
+++ b/server/drivers/codex.test.ts
@@ -4174,4 +4174,36 @@ process.stdout.write(JSON.stringify({jsonrpc:'2.0',id:m.id,result})+'\\n');});`)
const turnStart = seen.calls.find((c: any) => c.method === "turn/start");
expect(turnStart.params).not.toHaveProperty("effort");
});
+
+ it("runs a Fast row on its base model with the Fast tier for that turn only", async () => {
+ await create();
+ const dump = join(scratch, "fast.json");
+ process.env.FAKE_CODEX_DUMP = dump;
+
+ await instance.adapter.sendTurn({ threadId: "t-fast", text: "hi", model: "gpt-5.5+priority", effort: "high" });
+ await recorder.until((e) => e.type === "turn.completed");
+
+ const seen = JSON.parse(readFileSync(dump, "utf8"));
+ const threadStart = seen.calls.find((c: any) => c.method === "thread/start");
+ const turnStart = seen.calls.find((c: any) => c.method === "turn/start");
+ expect(threadStart.params).toMatchObject({ model: "gpt-5.5", modelProvider: "openai" });
+ expect(threadStart.params).not.toHaveProperty("serviceTier");
+ expect(turnStart.params).toMatchObject({ serviceTierForTurn: "priority", effort: "high" });
+ expect(turnStart.params).not.toHaveProperty("serviceTier");
+ });
+
+ it("sends no service tier for a plain row", async () => {
+ await create();
+ const dump = join(scratch, "plain.json");
+ process.env.FAKE_CODEX_DUMP = dump;
+
+ await instance.adapter.sendTurn({ threadId: "t-plain", text: "hi", model: "gpt-5.5" });
+ await recorder.until((e) => e.type === "turn.completed");
+
+ const seen = JSON.parse(readFileSync(dump, "utf8"));
+ const turnStart = seen.calls.find((c: any) => c.method === "turn/start");
+ expect(seen.calls.find((c: any) => c.method === "thread/start").params.model).toBe("gpt-5.5");
+ expect(turnStart.params).not.toHaveProperty("serviceTierForTurn");
+ expect(turnStart.params).not.toHaveProperty("serviceTier");
+ });
});
diff --git a/server/drivers/codex.ts b/server/drivers/codex.ts
index e07da37d92..3dbf53c169 100644
--- a/server/drivers/codex.ts
+++ b/server/drivers/codex.ts
@@ -1378,7 +1378,7 @@ export const CodexDriver: ProviderDriver<CodexConfig> = {
// Codex's `never` means "do not ask to escalate", not "grant every requested permission":
// only Full may synthesize approvals.
autoAcceptPermissions = approvalMode === "full";
- const selection = routed
+ const selection: { model?: string | null; modelProvider: string | null; serviceTier?: string } = routed
? { model: turn.model, modelProvider: routedProvider }
: config.authMode === "chatgpt-plan"
? { model: turn.model, modelProvider: "openai_chatgpt_plan" }
@@ -1487,7 +1487,7 @@ export const CodexDriver: ProviderDriver<CodexConfig> = {
...(turn.guestConfined ? { environments: [] } : {}),
// Spread, not `effort ?? null`: codex-cli 0.146.0 treats null as absent (the thread keeps
// its effort), rejects "", and thread/start takes no effort, so a thread keeps its last level.
- ...(turn.effort ? { effort: turn.effort } : {}),
+ ...(turn.effort ? { effort: turn.effort } : {}), ...(selection.serviceTier ? { serviceTierForTurn: selection.serviceTier } : {}),
});
};
const waitNames = supportsMcpStartup(initialized?.userAgent) ? enabledMcpMounts([...selectedMcp.keys(), ...directMounts], effectiveConfig, turn.toolScope !== undefined) : [];
diff --git a/server/testing/fake-codex-app-server.ts b/server/testing/fake-codex-app-server.ts
index b43964b4f9..45a2ecc86f 100755
--- a/server/testing/fake-codex-app-server.ts
+++ b/server/testing/fake-codex-app-server.ts
@@ -52,6 +52,8 @@
// FAKE_CODEX_TEXT_REFUSE `codex exec`: comma-separated models answered with the 400 a ChatGPT account gets for gpt-5.4-mini
// FAKE_CODEX_TEXT_BLOCK `codex exec`: comma-separated models answered with the 403 OpenAI sends a region it does not serve
// FAKE_CODEX_LUNA "1": model/list also offers gpt-6-luna
+// FAKE_CODEX_TIERS "1": model/list rows list a Fast service tier, as codex-cli 0.167.2 does; gpt-page-two
+// already runs on it by default
// FAKE_CODEX_UPDATED_FILE while this file exists, the CLI was updated in place: --version answers codex-cli 0.162.1
// and model/list also offers gpt-6.1-sol
// FAKE_CODEX_MCP_START "1": on thread/start, start each `-c mcp_servers.*` mount as codex-cli 0.160.1 does
@@ -66,6 +68,8 @@ import { appendFileSync, existsSync, readFileSync, renameSync, unlinkSync, write
const mode = process.env.FAKE_CODEX_MODE ?? "happy";
+const tiers = process.env.FAKE_CODEX_TIERS === "1";
+const FAST_TIERS = [{ id: "priority", name: "Fast", description: "Fastest inference with increased plan usage" }];
// Follow the spawning server down; on Windows ppid does not change after parent exit.
{
@@ -566,7 +570,8 @@ process.stdin.on("data", (chunk) => {
result: {
data: [
{ id: "gpt-hidden", displayName: "Hidden", hidden: true, isDefault: false },
- { id: "gpt-page-two", displayName: "GPT Page Two", hidden: false, isDefault: false },
+ { id: "gpt-page-two", displayName: "GPT Page Two", hidden: false, isDefault: false,
+ ...(tiers ? { serviceTiers: FAST_TIERS, defaultServiceTier: "priority" } : {}) },
],
nextCursor: null,
},
@@ -581,7 +586,8 @@ process.stdin.on("data", (chunk) => {
...(hasAstra
? [{ id: "gpt-6-astra", displayName: "GPT-6 Astra", hidden: false, isDefault: true }]
: []),
- { id: "gpt-fake-default", displayName: "GPT Fake Default", hidden: false, isDefault: !hasAstra },
+ { id: "gpt-fake-default", displayName: "GPT Fake Default", hidden: false, isDefault: !hasAstra,
+ ...(tiers ? { serviceTiers: FAST_TIERS, defaultServiceTier: null } : {}) },
...(process.env.FAKE_CODEX_LUNA === "1"
? [{ id: "gpt-6-luna", displayName: "GPT-6 Luna", hidden: false, isDefault: false }]
: []),