From 1b40e19baf0b10ae6c38438db2c32796b5f921bc Mon Sep 17 00:00:00 2001 From: Thibault Sottiaux Date: Wed, 16 Apr 2025 10:32:45 -0700 Subject: [PATCH] w (#8) --- codex-cli/src/utils/config.ts | 11 +++++------ codex-cli/src/utils/model-utils.ts | 7 +++---- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/codex-cli/src/utils/config.ts b/codex-cli/src/utils/config.ts index 07f9b40a..a98473b2 100644 --- a/codex-cli/src/utils/config.ts +++ b/codex-cli/src/utils/config.ts @@ -63,7 +63,7 @@ export type MemoryConfig = { enabled: boolean; }; -// Represents full runtime config, including loaded instructions +// Represents full runtime config, including loaded instructions. export type AppConfig = { apiKey?: string; model: string; @@ -91,7 +91,7 @@ export function discoverProjectDocPath(startDir: string): string | null { } } - // 2) Fallback: walk up to the Git root and look there + // 2) Fallback: walk up to the Git root and look there. let dir = cwd; // eslint-disable-next-line no-constant-condition while (true) { @@ -104,13 +104,13 @@ export function discoverProjectDocPath(startDir: string): string | null { return candidate; } } - // If Git root but no doc, stop looking + // If Git root but no doc, stop looking. return null; } const parent = dirname(dir); if (parent === dir) { - // Reached filesystem root without finding Git + // Reached filesystem root without finding Git. return null; } dir = parent; @@ -157,7 +157,6 @@ export function loadProjectDoc(cwd: string, explicitPath?: string): string { } } -// (Receives params for testing) export type LoadConfigOptions = { /** Working directory used for project doc discovery */ cwd?: string; @@ -210,7 +209,7 @@ export const loadConfig = ( ? readFileSync(instructionsFilePathResolved, "utf-8") : DEFAULT_INSTRUCTIONS; - // Project doc ----------------------------------------------------------- + // Project doc support. const shouldLoadProjectDoc = !options.disableProjectDoc && process.env["CODEX_DISABLE_PROJECT_DOC"] !== "1"; diff --git a/codex-cli/src/utils/model-utils.ts b/codex-cli/src/utils/model-utils.ts index 7dabd4fd..07d924c0 100644 --- a/codex-cli/src/utils/model-utils.ts +++ b/codex-cli/src/utils/model-utils.ts @@ -1,6 +1,7 @@ import { OPENAI_API_KEY } from "./config"; import OpenAI from "openai"; +const MODEL_LIST_TIMEOUT_MS = 2_000; // 2 seconds export const RECOMMENDED_MODELS: Array = ["o4-mini", "o3"]; /** @@ -14,9 +15,9 @@ export const RECOMMENDED_MODELS: Array = ["o4-mini", "o3"]; let modelsPromise: Promise> | null = null; async function fetchModels(): Promise> { - // If the user has not configured an API key we cannot hit the network + // If the user has not configured an API key we cannot hit the network. if (!OPENAI_API_KEY) { - return ["o4-mini"]; + return RECOMMENDED_MODELS; } try { @@ -67,8 +68,6 @@ export async function isModelSupportedForResponses( return true; } - const MODEL_LIST_TIMEOUT_MS = 2_000; - try { const models = await Promise.race>([ getAvailableModels(),