Spaces:
Paused

icebear icebear0828 Claude Opus 4.6 commited on
Commit
9d6278d
·
unverified ·
1 Parent(s): d40d20b

fix: detect empty Codex responses and auto-retry with account rotation (#18)

Browse files

* fix: detect empty Codex responses and auto-retry with account rotation

Codex API intermittently returns HTTP 200 with valid SSE events but zero
text deltas. Add EmptyResponseError detection in all three translation
layers (OpenAI, Anthropic, Gemini) and a retry loop in proxy-handler
that switches accounts on empty responses (up to 3 attempts).

- Non-streaming: catch EmptyResponseError → release account → acquire
new account → retry with fresh CodexApi (max 2 retries)
- Streaming: inject "[Error] Codex returned an empty response" text
chunk when response.completed fires with no content
- All retries exhausted → 502 with clear error message

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix: prevent double-release of account in empty-response retry loop

The outer catch block used the original entryId, which was already
released when EmptyResponseError switched to a new account. Introduce
activeEntryId to track the currently-active account across retries.
Also set EmptyResponseError.name for proper serialization.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: icebear0828 <icebear0828@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>

6 files changed +156 -27
Files changed (6)
CHANGELOG.md+1
src/routes/shared/proxy-handler.ts+77-24
src/translation/codex-event-extractor.ts+10
src/translation/codex-to-anthropic.ts+17-1
src/translation/codex-to-gemini.ts+26-1
src/translation/codex-to-openai.ts+25-1