Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
fix(codex): strip the Fast tier only from an official tiered id
Bugfixer 2cddc83f1b48e
diff --git a/server/drivers/codex-catalog.ts b/server/drivers/codex-catalog.tsindex dd82d0d735..e5360c02ea 100644--- a/server/drivers/codex-catalog.ts+++ b/server/drivers/codex-catalog.ts@@ -8,7 +8,7 @@ import type { ModelCatalog } from "../contracts.ts";import { qualifiedModelLabel } from "../contracts.ts";import { killCliTree, spawnCli } from "../procs.ts";import { codexHome } from "./codex-identity.ts";-import { TIERED_ID } from "./codex-tier.ts";+import { MODEL_ID, SEP, TIERED_ID, codexTierOf } from "./codex-tier.ts";import { unconfirmedModelCatalog } from "../startup-model-catalog.ts";import { codexLocalProviderArgs, mergeLocalInject } from "./local-inject.ts";@@ -32,8 +32,6 @@ export const STATIC_CODEX_MODELS: ModelCatalog = {/** Official rows force this provider, so a local `model_provider = "omlx"` cannot swallow GPT-5.6. */export const OFFICIAL_CODEX_PROVIDER = "openai";-const SEP = "::";-const MODEL_ID = /^[\w][\w./:+-]*$/;const PROVIDER_ID = /^[a-z][a-z0-9_-]*$/i;export function encodeCodexSelection(provider: string, model: string): string {@@ -52,8 +50,8 @@ export function decodeCodexSelection(id: string | null | undefined): {}// A bare id is official: a new cloud model must not fall through to the user's local provider.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] };+ const tiered = codexTierOf(id);+ if (tiered) return { model: tiered.model, modelProvider: OFFICIAL_CODEX_PROVIDER, serviceTier: tiered.tier };return { model: id, modelProvider: OFFICIAL_CODEX_PROVIDER };}diff --git a/server/drivers/codex-tier.ts b/server/drivers/codex-tier.tsindex 885d66afd9..ff7ab48357 100644--- a/server/drivers/codex-tier.ts+++ b/server/drivers/codex-tier.ts@@ -1,3 +1,12 @@/** An official Codex 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. */export const TIERED_ID = /^(.+)\+([a-z][a-z0-9_-]*)$/i;+export const SEP = "::";+export const MODEL_ID = /^[\w][\w./:+-]*$/;++/** The base model and tier of an official Fast row; null for any other id, so a provider-qualified `local::foo+priority` keeps its `+`. */+export function codexTierOf(id: string): { model: string; tier: string } | null {+ if (id.includes(SEP) || !MODEL_ID.test(id)) return null;+ const tiered = TIERED_ID.exec(id);+ return tiered ? { model: tiered[1], tier: tiered[2] } : null;+}diff --git a/server/model-prices.test.ts b/server/model-prices.test.tsindex c704a8aba4..2ad201f65a 100644--- a/server/model-prices.test.ts+++ b/server/model-prices.test.ts@@ -81,6 +81,8 @@ describe("what the ledger books for a settled turn", () => {expect(ledgerCost(fast, operator).costUsd).toBeCloseTo(1 * 1 + 0.1 * 2, 9);expect(estimatePriceFor({ driverKind: "codex", model: "gpt-5.5+priority" }, { "codex/gpt-5.5+priority": { inputPerMillion: 7, outputPerMillion: 7 } })?.inputPerMillion).toBe(7);expect(estimatePriceFor({ driverKind: "acp", model: "gpt-5.5+priority" }, null)).toBeNull();+ // A provider-qualified custom model keeps its `+`: it is not a Fast row, so another model's price must not apply.+ expect(estimatePriceFor({ driverKind: "codex", model: "local::foo+priority" }, { "codex/local::foo": { inputPerMillion: 9, outputPerMillion: 9 } })).toBeNull();});it("books an unpriced model as unpriced, not as free", () => {diff --git a/server/model-prices.ts b/server/model-prices.tsindex 1e809fde09..7cd82ffc17 100644--- a/server/model-prices.ts+++ b/server/model-prices.ts@@ -1,5 +1,5 @@import type { ModelPrice, PriceList, PricedTurn } from "./prices.ts";-import { TIERED_ID } from "./drivers/codex-tier.ts";+import { codexTierOf } from "./drivers/codex-tier.ts";import { currentPrices } from "./model-manifest/manifest.ts";import { billableFor } from "./prices.ts";@@ -32,7 +32,7 @@ export type CostSource = "reported" | "estimated";export function estimatePriceFor(turn: Pick<PricedTurn, "driverKind" | "model">, operatorPrices: PriceList | null, at: Date = new Date()): ModelPrice | null {// A Codex Fast row (`gpt-5.5+priority`) costs what its base model costs; the usage row keeps the full id.- const model = turn.driverKind === "codex" ? TIERED_ID.exec(turn.model)?.[1] ?? turn.model : turn.model;+ const model = turn.driverKind === "codex" ? codexTierOf(turn.model)?.model ?? turn.model : turn.model;return operatorPrices?.[`${turn.driverKind}/${turn.model}`] ?? operatorPrices?.[turn.model] ??operatorPrices?.[`${turn.driverKind}/${model}`] ?? operatorPrices?.[model] ??listPriceFor(model, at) ?? operatorPrices?.default ?? null;