The Open Framework for Building Agents
fix(eve): bump ChatGPT model catalog, fix `chatgpt()` Fast default (#4587)
Ben Pankow25b3f35d7b8e
diff --git a/.changeset/chatgpt-current-models.md b/.changeset/chatgpt-current-models.mdnew file mode 100644index 000000000..d81bd3d19--- /dev/null+++ b/.changeset/chatgpt-current-models.md@@ -0,0 +1,5 @@+---+"eve": patch+---++`/login chatgpt` now lists current subscription models such as `gpt-6-luna`, and the default `chatgpt()` model (`gpt-6-luna-fast`) works: eve sends it to Codex as `gpt-6-luna` on the priority service tier, since Codex rejects `-fast` model IDs.diff --git a/packages/eve/src/internal/model-auth/available-models.ts b/packages/eve/src/internal/model-auth/available-models.tsindex f4326b0f1..2af6f5d98 100644--- a/packages/eve/src/internal/model-auth/available-models.ts+++ b/packages/eve/src/internal/model-auth/available-models.ts@@ -43,7 +43,7 @@ export async function availableHelperModels(};if (token.accountId) headers["ChatGPT-Account-Id"] = token.accountId;const value = await authJson(- "https://chatgpt.com/backend-api/codex/models?client_version=0.148.0",+ "https://chatgpt.com/backend-api/codex/models?client_version=0.162.0",{ headers, signal },MODEL_CATALOG_MAX_BYTES,);diff --git a/packages/eve/src/public/models/openai/chatgpt/model.test.ts b/packages/eve/src/public/models/openai/chatgpt/model.test.tsindex 5f7bb6b90..391146435 100644--- a/packages/eve/src/public/models/openai/chatgpt/model.test.ts+++ b/packages/eve/src/public/models/openai/chatgpt/model.test.ts@@ -158,6 +158,23 @@ describe("Codex model", () => {expect(JSON.parse(requests[0]?.body ?? "{}").prompt_cache_key).toBe("session-key");});+ it("serves a -fast model id as the base slug on the priority tier", async () => {+ const requests: RecordedRequest[] = [];+ const model = createCodexSubscriptionModel(+ { model: "gpt-6-luna-fast" },+ { broker: fakeBroker(), fetch: createRecordingFetch(requests) },+ );++ await model.doGenerate({+ prompt: [{ role: "user", content: [{ type: "text", text: "hello" }] }],+ });++ // Codex rejects `gpt-6-luna-fast` with a ChatGPT account.+ const body = JSON.parse(requests[0]?.body ?? "{}");+ expect(body.model).toBe("gpt-6-luna");+ expect(body.service_tier).toBe("priority");+ });+it("groups summaries by reasoning item and preserves encrypted-only items", async () => {const requests: RecordedRequest[] = [];const model = createCodexSubscriptionModel(diff --git a/packages/eve/src/public/models/openai/chatgpt/model.ts b/packages/eve/src/public/models/openai/chatgpt/model.tsindex 8987a86d0..36c73fac5 100644--- a/packages/eve/src/public/models/openai/chatgpt/model.ts+++ b/packages/eve/src/public/models/openai/chatgpt/model.ts@@ -3,6 +3,7 @@ import type {LanguageModelV4,LanguageModelV4CallOptions,} from "#compiled/@ai-sdk/provider/index.js";+import { parseChatGptFastModelId } from "#shared/chatgpt-model.js";import { createCodexFetch, type CodexTransportOptions } from "./transport.js";const CODEX_LOCAL_AUTH_API_KEY = "codex-local-auth";@@ -22,31 +23,33 @@ export function createCodexSubscriptionModel(if (model.length === 0) {throw new Error('Expected "model" to name a Codex model.');}+ const { slug, fast } = parseChatGptFastModelId(model);const openaiModel = createOpenAI({apiKey: CODEX_LOCAL_AUTH_API_KEY,fetch: createCodexFetch(options),name: "codex",- }).responses(model);+ }).responses(slug);// Keep item IDs until the provider has grouped streamed reasoning summaries.// The transport removes them from the stateless request sent to Codex.return {specificationVersion: openaiModel.specificationVersion,provider: openaiModel.provider,- modelId: openaiModel.modelId,+ modelId: model,get supportedUrls() {return openaiModel.supportedUrls;},doGenerate: (callOptions: LanguageModelV4CallOptions) =>- openaiModel.doGenerate(normalizeCodexCallOptions(callOptions)),+ openaiModel.doGenerate(normalizeCodexCallOptions(callOptions, fast)),doStream: (callOptions: LanguageModelV4CallOptions) =>- openaiModel.doStream(normalizeCodexCallOptions(callOptions)),+ openaiModel.doStream(normalizeCodexCallOptions(callOptions, fast)),};}function normalizeCodexCallOptions(options: LanguageModelV4CallOptions,+ fast: boolean,): LanguageModelV4CallOptions {const providerOptions = options.providerOptions;const openaiOptions = providerOptions?.openai ?? {};@@ -70,7 +73,8 @@ function normalizeCodexCallOptions(...openaiOptions,// OpenAI documents `fast` as an alias of `priority`, but the Codex// backend rejects `fast`. Codex itself sends `priority` for Fast mode.- ...(openaiOptions.serviceTier === "fast" && { serviceTier: "priority" }),+ ...((openaiOptions.serviceTier === "fast" ||+ (fast && openaiOptions.serviceTier === undefined)) && { serviceTier: "priority" }),...(instructions !== undefined && { instructions }),store: false,},diff --git a/packages/eve/src/setup/flows/model-login.test.ts b/packages/eve/src/setup/flows/model-login.test.tsindex dbaeec738..05f3b2cd0 100644--- a/packages/eve/src/setup/flows/model-login.test.ts+++ b/packages/eve/src/setup/flows/model-login.test.ts@@ -97,7 +97,8 @@ beforeEach(() => {mocks.readSecret.mockResolvedValue("stored-key");mocks.models.mockResolvedValue({data: [{ id: "gpt-5.6-luna-fast" }, { id: "gpt-6-luna-fast" }, { id: "claude-sonnet-5" }],- models: [{ slug: "gpt-5.6-luna-fast" }, { slug: "gpt-6-luna-fast" }],+ // The Codex catalog lists base slugs only; Fast mode is a service tier.+ models: [{ slug: "gpt-5.6-luna" }, { slug: "gpt-6-luna" }],});mocks.gateway.mockResolvedValue({ kind: "valid" });mocks.chatgptState.mockResolvedValue({ kind: "ready", reload: true });diff --git a/packages/eve/src/setup/flows/model-login.ts b/packages/eve/src/setup/flows/model-login.tsindex 3b8501d6e..cd34443f4 100644--- a/packages/eve/src/setup/flows/model-login.ts+++ b/packages/eve/src/setup/flows/model-login.ts@@ -2,6 +2,7 @@ import { resolveModelEndpointStatus } from "#internal/resolve-model-endpoint-staimport { classifyModelRouting } from "#internal/classify-model-routing.js";import type { ConnectedModel } from "#shared/model-connection.js";import { DEFAULT_AGENT_MODEL_ID } from "#shared/default-agent-model.js";+import { parseChatGptFastModelId } from "#shared/chatgpt-model.js";import { measureLoginStage, withLoginProgress } from "./model-login-progress.js";import { availableHelperModels } from "#internal/model-auth/available-models.js";import { fetchGatewayCatalog } from "../boxes/select-model.js";@@ -115,7 +116,8 @@ async function applyConnection(): []);let id = defaultId;- if (!available.includes(id)) {+ const catalogId = helper === "chatgpt" ? parseChatGptFastModelId(id).slug : id;+ if (!available.includes(catalogId)) {if (available.length === 0)throw new Error("No models are available for this connection. Choose another connection with /login.",diff --git a/packages/eve/src/shared/chatgpt-model.ts b/packages/eve/src/shared/chatgpt-model.tsindex ea0915052..8f5d85480 100644--- a/packages/eve/src/shared/chatgpt-model.ts+++ b/packages/eve/src/shared/chatgpt-model.ts@@ -22,6 +22,15 @@ export function normalizeChatGptModelId(model: string): string | undefined {return isBareChatGptModelId(modelId) ? modelId : undefined;}+/**+ * Codex has no `-fast` model slugs: it serves Fast mode as the `priority`+ * service tier on the base model and rejects `gpt-6-luna-fast` outright.+ */+export function parseChatGptFastModelId(modelId: string): { slug: string; fast: boolean } {+ const slug = modelId.replace(/-fast$/u, "");+ return { slug, fast: slug !== modelId };+}+function isBareChatGptModelId(modelId: string): boolean {return modelId.length > 0 && modelId === modelId.trim() && !modelId.includes("/");}