fix(codex): timeouts for websockets (#4979)
This commit is contained in:
@@ -340,11 +340,18 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
|
||||
throw new Error(auth.error);
|
||||
}
|
||||
const providerRetrySettings = settingsManager.getProviderRetrySettings();
|
||||
const timeoutMs =
|
||||
options?.timeoutMs ??
|
||||
providerRetrySettings.timeoutMs ??
|
||||
(model.api === "openai-codex-responses" ? settingsManager.getHttpIdleTimeoutMs() : undefined);
|
||||
const websocketConnectTimeoutMs =
|
||||
options?.websocketConnectTimeoutMs ?? settingsManager.getWebSocketConnectTimeoutMs();
|
||||
const attributionHeaders = getAttributionHeaders(model, settingsManager, options?.sessionId);
|
||||
return streamSimple(model, context, {
|
||||
...options,
|
||||
apiKey: auth.apiKey,
|
||||
timeoutMs: options?.timeoutMs ?? providerRetrySettings.timeoutMs,
|
||||
timeoutMs,
|
||||
websocketConnectTimeoutMs,
|
||||
maxRetries: options?.maxRetries ?? providerRetrySettings.maxRetries,
|
||||
maxRetryDelayMs: options?.maxRetryDelayMs ?? providerRetrySettings.maxRetryDelayMs,
|
||||
headers:
|
||||
|
||||
@@ -112,6 +112,7 @@ export interface Settings {
|
||||
warnings?: WarningSettings;
|
||||
sessionDir?: string; // Custom session storage directory (same format as --session-dir CLI flag)
|
||||
httpIdleTimeoutMs?: number; // HTTP header/body idle timeout in milliseconds; 0 disables it
|
||||
websocketConnectTimeoutMs?: number; // WebSocket connect/open handshake timeout in milliseconds; 0 disables it
|
||||
}
|
||||
|
||||
/** Deep merge settings: project/overrides take precedence, nested objects merge recursively */
|
||||
@@ -145,6 +146,17 @@ function deepMergeSettings(base: Settings, overrides: Settings): Settings {
|
||||
return result;
|
||||
}
|
||||
|
||||
function parseTimeoutSetting(value: unknown, settingName: string): number | undefined {
|
||||
const timeoutMs = parseHttpIdleTimeoutMs(value);
|
||||
if (timeoutMs !== undefined) {
|
||||
return timeoutMs;
|
||||
}
|
||||
if (value !== undefined) {
|
||||
throw new Error(`Invalid ${settingName} setting: ${String(value)}`);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
export type SettingsScope = "global" | "project";
|
||||
|
||||
export interface SettingsStorage {
|
||||
@@ -722,15 +734,7 @@ export class SettingsManager {
|
||||
}
|
||||
|
||||
getHttpIdleTimeoutMs(): number {
|
||||
const value = this.settings.httpIdleTimeoutMs;
|
||||
const timeoutMs = parseHttpIdleTimeoutMs(value);
|
||||
if (timeoutMs !== undefined) {
|
||||
return timeoutMs;
|
||||
}
|
||||
if (value !== undefined) {
|
||||
throw new Error(`Invalid httpIdleTimeoutMs setting: ${String(value)}`);
|
||||
}
|
||||
return DEFAULT_HTTP_IDLE_TIMEOUT_MS;
|
||||
return parseTimeoutSetting(this.settings.httpIdleTimeoutMs, "httpIdleTimeoutMs") ?? DEFAULT_HTTP_IDLE_TIMEOUT_MS;
|
||||
}
|
||||
|
||||
setHttpIdleTimeoutMs(timeoutMs: number): void {
|
||||
@@ -750,6 +754,10 @@ export class SettingsManager {
|
||||
};
|
||||
}
|
||||
|
||||
getWebSocketConnectTimeoutMs(): number | undefined {
|
||||
return parseTimeoutSetting(this.settings.websocketConnectTimeoutMs, "websocketConnectTimeoutMs");
|
||||
}
|
||||
|
||||
getHideThinkingBlock(): boolean {
|
||||
return this.settings.hideThinkingBlock ?? false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user