Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions codex-cli/src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down
7 changes: 3 additions & 4 deletions codex-cli/src/utils/model-utils.ts
Original file line number Diff line number Diff line change
@@ -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<string> = ["o4-mini", "o3"];

/**
Expand All @@ -14,9 +15,9 @@ export const RECOMMENDED_MODELS: Array<string> = ["o4-mini", "o3"];
let modelsPromise: Promise<Array<string>> | null = null;

async function fetchModels(): Promise<Array<string>> {
// 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 {
Expand Down Expand Up @@ -67,8 +68,6 @@ export async function isModelSupportedForResponses(
return true;
}

const MODEL_LIST_TIMEOUT_MS = 2_000;

try {
const models = await Promise.race<Array<string>>([
getAvailableModels(),
Expand Down
Loading