Merge pull request #533 from AutoMaker-Org/feature/v0.12.0rc-1768605477061-fhv5

fix: Codex freezes
This commit is contained in:
Shirone
2026-01-16 23:59:16 +00:00
committed by GitHub
5 changed files with 217 additions and 5 deletions

View File

@@ -21,6 +21,13 @@ export type {
ReasoningEffort,
} from './provider.js';
// Provider constants and utilities
export {
DEFAULT_TIMEOUT_MS,
REASONING_TIMEOUT_MULTIPLIERS,
calculateReasoningTimeout,
} from './provider.js';
// Codex CLI types
export type {
CodexSandboxMode,

View File

@@ -18,6 +18,61 @@ import type { CodexSandboxMode, CodexApprovalPolicy } from './codex.js';
*/
export type ReasoningEffort = 'none' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
/**
* Default timeout in milliseconds for provider operations.
* Used as the baseline timeout for API calls and CLI operations.
*/
export const DEFAULT_TIMEOUT_MS = 30000;
/**
* Timeout multipliers for reasoning effort levels.
* Higher reasoning effort requires more time for the model to generate reasoning tokens.
* These multipliers are applied to DEFAULT_TIMEOUT_MS.
*/
export const REASONING_TIMEOUT_MULTIPLIERS: Record<ReasoningEffort, number> = {
none: 1.0, // No reasoning, baseline timeout
minimal: 1.2, // Very quick reasoning, slight increase
low: 1.5, // Quick reasoning, moderate increase
medium: 2.0, // Balanced reasoning, double baseline
high: 3.0, // Extended reasoning, triple baseline
xhigh: 4.0, // Maximum reasoning, quadruple baseline
};
/**
* Calculate timeout for provider operations based on reasoning effort.
* Higher reasoning effort requires more time for the model to generate reasoning tokens.
*
* This function addresses GitHub issue #530 where Codex CLI with GPT-5.2 "xtra thinking"
* (xhigh reasoning effort) mode would get stuck because the 30-second "no output" timeout
* would trigger during extended reasoning phases.
*
* @param reasoningEffort - The reasoning effort level, defaults to 'none' if undefined.
* If an invalid value is provided, falls back to multiplier 1.0.
* @param baseTimeoutMs - Optional custom base timeout, defaults to DEFAULT_TIMEOUT_MS (30000ms)
* @returns The calculated timeout in milliseconds, rounded to the nearest integer
*
* @example
* // Using default base timeout (30000ms)
* calculateReasoningTimeout('high') // Returns 90000 (30000 * 3.0)
*
* @example
* // Using custom base timeout
* calculateReasoningTimeout('medium', 60000) // Returns 120000 (60000 * 2.0)
*
* @example
* // No reasoning effort (default)
* calculateReasoningTimeout() // Returns 30000 (default timeout)
* calculateReasoningTimeout(undefined) // Returns 30000
*/
export function calculateReasoningTimeout(
reasoningEffort?: ReasoningEffort,
baseTimeoutMs: number = DEFAULT_TIMEOUT_MS
): number {
const effort = reasoningEffort ?? 'none';
const multiplier = REASONING_TIMEOUT_MULTIPLIERS[effort] ?? 1.0;
return Math.round(baseTimeoutMs * multiplier);
}
/**
* Configuration for a provider instance
*/