fix(codex): improve oauth error guidance and correct comment on default reasoning effort

This commit is contained in:
Hannes Rudolph 2025-09-25 18:45:28 -06:00
parent dc4ec3c077
commit 3922396bc4

View file

@ -112,24 +112,26 @@ export class OpenAiNativeCodexHandler extends BaseProvider {
try { try {
raw = await fs.readFile(explicitPath, "utf8") raw = await fs.readFile(explicitPath, "utf8")
} catch (e: any) { } catch (e: any) {
throw new Error( const base = t("common:errors.openaiNativeCodex.oauthReadFailed", {
t("common:errors.openaiNativeCodex.oauthReadFailed", { path: explicitPath,
path: explicitPath, error: e?.message || String(e),
error: e?.message || String(e), })
}), const tip =
) " Tip: Authenticate with the Codex CLI to generate auth.json (defaults to ~/.codex/auth.json), then retry."
throw new Error(base + tip)
} }
let j: any let j: any
try { try {
j = JSON.parse(raw) j = JSON.parse(raw)
} catch (e: any) { } catch (e: any) {
throw new Error( const base = t("common:errors.openaiNativeCodex.oauthParseFailed", {
t("common:errors.openaiNativeCodex.oauthParseFailed", { path: explicitPath,
path: explicitPath, error: e?.message || String(e),
error: e?.message || String(e), })
}), const tip =
) " Tip: Ensure the file is valid JSON or re-authenticate via the Codex CLI to regenerate auth.json."
throw new Error(base + tip)
} }
const tokens = (j?.tokens as any) || {} const tokens = (j?.tokens as any) || {}
@ -277,8 +279,8 @@ export class OpenAiNativeCodexHandler extends BaseProvider {
metadata?: ApiHandlerCreateMessageMetadata, metadata?: ApiHandlerCreateMessageMetadata,
) { ) {
// For Codex provider: // For Codex provider:
// - Regular "gpt-5" should default to minimal reasoning unless explicitly overridden in settings. // - Use the model's default reasoning effort (currently "medium") unless explicitly overridden in settings.
// - The "gpt-5-codex" variant should NOT force minimal; use provided/default effort. // - Both "gpt-5" and "gpt-5-codex" follow the provided/default effort without forcing "minimal".
let effectiveEffort: ReasoningEffortWithMinimal | undefined = reasoningEffort let effectiveEffort: ReasoningEffortWithMinimal | undefined = reasoningEffort
const body: any = { const body: any = {