fix(codex): harden streaming timeouts + Responses terminal events

Raise stall/connect timeouts to 60s (configurable per-provider), accept
codex response.done, and always emit a terminal response.failed + [DONE]
for Responses passthrough when a stream closes, stalls, or aborts before
a terminal event — preventing codex clients from hanging.

Co-authored-by: jonathanli12 <jonathanli12@users.noreply.github.com>
Co-authored-by: rifuki <rifuki@users.noreply.github.com>
Co-authored-by: nguyenha935 <nguyenha935@users.noreply.github.com>
Co-authored-by: trananhtung <trananhtung@users.noreply.github.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
decolua
2026-06-06 16:07:43 +07:00
parent f161b295a5
commit 9caea88528
15 changed files with 311 additions and 30 deletions

View File

@@ -71,8 +71,8 @@ export const PROVIDERS = {
baseUrl: "https://chatgpt.com/backend-api/codex/responses",
format: "openai-responses",
headers: {
"originator": "codex-cli",
"User-Agent": "codex-cli/1.0.18 (macOS; arm64)"
"originator": "codex_cli_rs",
"User-Agent": "codex_cli_rs/0.136.0"
},
clientId: "app_EMoamEEZ73f0CkXaXp7hrann",
tokenUrl: "https://auth.openai.com/oauth/token"

View File

@@ -32,10 +32,10 @@ export const MEMORY_CONFIG = {
};
// Stream stall timeout: abort if no chunk received within this duration
export const STREAM_STALL_TIMEOUT_MS = 30 * 1000;
export const STREAM_STALL_TIMEOUT_MS = 60 * 1000;
// Fetch connect timeout: abort if upstream doesn't return response headers within this duration
export const FETCH_CONNECT_TIMEOUT_MS = 20 * 1000;
export const FETCH_CONNECT_TIMEOUT_MS = 60 * 1000;
// Default token limits
export const DEFAULT_MAX_TOKENS = 64000;