Skip to content

fix(proxy): classify upstream overloaded_error as retryable transient - #601

Merged
Soju06 merged 1 commit into
Soju06:mainfrom
ozpool:fix/transient-overloaded-error-565
May 15, 2026
Merged

Soju06 merged 1 commit into
Soju06:mainfrom
ozpool:fix/transient-overloaded-error-565

Conversation

@ozpool

@ozpool ozpool commented May 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes Agent stops after transient upstream overload error instead of retrying #565. Long-running agent sessions stop mid-task when the upstream returns Our servers are currently overloaded. Please try again later. OpenAI delivers that as error.code = \"overloaded_error\", which is missing from _TRANSIENT_CODES in app/modules/proxy/helpers.py.
  • The envelope often arrives without a 5xx HTTP status — streamed Responses traffic returns 200 before the error frame hits the wire, and some upstream variants downgrade the JSON 503 to 200 to keep the SSE channel open. With both code-set membership and the http_status >= 500 fallback failing, the classifier returns non_retryable. failover_decision only retries / fails over for rate_limit, quota, or retryable_transient (app/core/balancer/logic.py:361), so the agent is failed back to the client without any account failover and stops.
  • Add \"overloaded_error\" to _TRANSIENT_CODES, exercise the regression in tests/unit/test_failover_foundation.py using the http_status=None shape, and document the requirement under the responses-api-compat capability.
  • No public surface change. Clients still see the upstream error envelope verbatim; only codex-lb's internal failover decision is widened by one code that is, by definition, transient.

Validation

  • uv run pytest tests/unit/test_failover_foundation.py — 44 passed
  • uvx ruff check app/modules/proxy/helpers.py tests/unit/test_failover_foundation.py — clean
  • uv run ty check app/modules/proxy/helpers.py — clean
  • openspec validate treat-upstream-overloaded-as-retryable — valid

Notes

  • Same classifier feeds both /v1/responses and /v1/chat/completions failover, so the fix benefits both surfaces even though the documented requirement is parked under responses-api-compat (where the issue surfaced).
  • Intentionally minimal: this PR widens the transient set by one code. It does not change retry budget, backoff, or any client-facing payload. If you'd prefer broader message-pattern matching as a defence in depth for hosts that strip the structured code, happy to follow up in a separate change.

Fixes #565

Fixes Soju06#565. Long-running Codex agent sessions stop mid-task when the
upstream replies with "Our servers are currently overloaded. Please
try again later" because classify_upstream_failure returns
non_retryable for that envelope.

OpenAI surfaces the overload condition with error.code =
"overloaded_error". That code is missing from _TRANSIENT_CODES, and
the envelope can arrive without an accompanying 5xx HTTP status
(streamed Responses API traffic typically returns HTTP 200 before
the error envelope hits the wire). With both signals absent the
classifier falls through to non_retryable, and failover_decision
only retries / fails over for retryable_transient, rate_limit, and
quota. The request is failed back to the client and the agent stops
without exercising the multi-account failover path that already
exists in the load balancer.

Add "overloaded_error" to _TRANSIENT_CODES so the classifier returns
retryable_transient regardless of the HTTP status, and pin the
behavior with a unit regression that uses the no-status shape.

Document the requirement under the responses-api-compat capability
since /v1/responses is the surface where this overload shape is most
commonly observed.
@Soju06

Soju06 commented May 15, 2026

Copy link
Copy Markdown
Owner

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@Soju06
Soju06 merged commit 8ef0833 into Soju06:main May 15, 2026
18 checks passed
@Soju06

Soju06 commented May 15, 2026

Copy link
Copy Markdown
Owner

@all-contributors please add @ozpool for code, test

@Soju06

Soju06 commented May 15, 2026

Copy link
Copy Markdown
Owner

@all-contributors please add @ozpool for code

@allcontributors

Copy link
Copy Markdown
Contributor

@Soju06

I've updated the pull request to add @ozpool! 🎉

@allcontributors

Copy link
Copy Markdown
Contributor

@Soju06

@ozpool already contributed before to code

Soju06 added a commit that referenced this pull request May 17, 2026
Release 1.18.0 — v1.17.0 → main, 27 PR.

## Pre-merge verification (release-gate e2e)

- ✅ CI 18/18 (mergeStateStatus CLEAN)
- ✅ baseline release-gate-smoke: 10/10 (`v1.models`, chat non-stream/stream/tool_call, responses non-stream/stream, unknown-msg-key drop, transient codes, dashboard 72-byte, alembic index)
- ✅ per-PR e2e extra: 14/14 (#658 strict tool × chat valid/invalid/type-omitted + responses invalid, #650-652 trim replay markers, #516 prev-resp miss mask, #558 prolite plan, #600 token_expired, #635 device poll, #647 frontend 72B, #594 account selection, #640 alembic head, #653/#654 conv archive, #655/#656 weekly pace)
- ✅ pytest 562 passed / 3 PG-only skip (unit + integration suite)
- ✅ SDK e2e 20/20 (`tests/e2e/test_openai_sdk_compat.py` + `tests/e2e/test_v1_responses_openai_sdk.py`)
- ✅ `scripts/verify_v1_responses_openai_sdk.py` 5/5 against live container with real account
- ✅ ruff check + ruff format --check + uv run ty check — All clean
- ✅ prod parity probe: #637 (unknown-key drop) + #658 (strict tool 400) both confirmed fixed vs prod 1.17.0

## Behavior change to note in announcements

- **#658**: `strict: true` function tool schemas missing `additionalProperties: false` (or other strict-mode requirements) now return a local **400 `invalid_function_parameters`** with `param=tools[N].function.parameters` (chat) / `tools[N].parameters` (responses). Pre-1.18.0 these were silently forwarded upstream; 1.18.0 enforces OpenAI's documented strict-mode contract locally before forwarding.

OpenSpec changes shipped in this release (to be archived after tag publish):
- deactivate-on-token-expired (#600)
- drop-unknown-message-fields (#637)
- mask-single-http-previous-response-miss (#516)
- normalize-v1-responses-openai-sdk-stream (#639)
- start-device-oauth-polling (#635)
- support-prolite-plan-capacity (#558)
- treat-upstream-overloaded-as-retryable (#601)
- validate-password-length (#598)
- validate-strict-function-tool-schema (#658)
Soju06 added a commit that referenced this pull request May 17, 2026
Archive changes shipped in v1.18.0 and v1.18.1 per AGENTS.md
"release 이후 archive" workflow. All 12 changes verified shipped in
production at 10.0.0.113 (image 1.18.1, sha256:0431a474432d).

1.18.0 (9 changes):
- deactivate-on-token-expired (#600)
- drop-unknown-message-fields (#637)
- mask-single-http-previous-response-miss (#516)
- normalize-v1-responses-openai-sdk-stream (#639)
- start-device-oauth-polling (#635) [delta header fixed: MODIFIED -> ADDED]
- support-prolite-plan-capacity (#558) [delta header fixed: MODIFIED -> ADDED]
- treat-upstream-overloaded-as-retryable (#601)
- validate-password-length (#598)
- validate-strict-function-tool-schema (#658)

1.18.1 (3 changes):
- harden-long-codex-websocket-turns (#586)
- suppress-duplicate-side-effect-tool-calls (#586)
- hotfix-db-pool-pre-ping-and-firewall-cache-ttl (#679)

Specs updated: 9 capabilities (admin-auth, api-firewall, chat-completions-compat,
chat-completions-extensions, database-backends, frontend-architecture,
responses-api-compat, usage-refresh-policy).

openspec validate --specs: 19/19 passed.

Co-authored-by: Hermes Agent <[email protected]>
vitalNohj pushed a commit to vitalNohj/codex-lb that referenced this pull request Jul 17, 2026
…Soju06#601)

Fixes Soju06#565. Long-running Codex agent sessions stop mid-task when the
upstream replies with "Our servers are currently overloaded. Please
try again later" because classify_upstream_failure returns
non_retryable for that envelope.

OpenAI surfaces the overload condition with error.code =
"overloaded_error". That code is missing from _TRANSIENT_CODES, and
the envelope can arrive without an accompanying 5xx HTTP status
(streamed Responses API traffic typically returns HTTP 200 before
the error envelope hits the wire). With both signals absent the
classifier falls through to non_retryable, and failover_decision
only retries / fails over for retryable_transient, rate_limit, and
quota. The request is failed back to the client and the agent stops
without exercising the multi-account failover path that already
exists in the load balancer.

Add "overloaded_error" to _TRANSIENT_CODES so the classifier returns
retryable_transient regardless of the HTTP status, and pin the
behavior with a unit regression that uses the no-status shape.

Document the requirement under the responses-api-compat capability
since /v1/responses is the surface where this overload shape is most
commonly observed.
vitalNohj pushed a commit to vitalNohj/codex-lb that referenced this pull request Jul 17, 2026
Release 1.18.0 — v1.17.0 → main, 27 PR.

## Pre-merge verification (release-gate e2e)

- ✅ CI 18/18 (mergeStateStatus CLEAN)
- ✅ baseline release-gate-smoke: 10/10 (`v1.models`, chat non-stream/stream/tool_call, responses non-stream/stream, unknown-msg-key drop, transient codes, dashboard 72-byte, alembic index)
- ✅ per-PR e2e extra: 14/14 (Soju06#658 strict tool × chat valid/invalid/type-omitted + responses invalid, Soju06#650-652 trim replay markers, Soju06#516 prev-resp miss mask, Soju06#558 prolite plan, Soju06#600 token_expired, Soju06#635 device poll, Soju06#647 frontend 72B, Soju06#594 account selection, Soju06#640 alembic head, Soju06#653/Soju06#654 conv archive, Soju06#655/Soju06#656 weekly pace)
- ✅ pytest 562 passed / 3 PG-only skip (unit + integration suite)
- ✅ SDK e2e 20/20 (`tests/e2e/test_openai_sdk_compat.py` + `tests/e2e/test_v1_responses_openai_sdk.py`)
- ✅ `scripts/verify_v1_responses_openai_sdk.py` 5/5 against live container with real account
- ✅ ruff check + ruff format --check + uv run ty check — All clean
- ✅ prod parity probe: Soju06#637 (unknown-key drop) + Soju06#658 (strict tool 400) both confirmed fixed vs prod 1.17.0

## Behavior change to note in announcements

- **Soju06#658**: `strict: true` function tool schemas missing `additionalProperties: false` (or other strict-mode requirements) now return a local **400 `invalid_function_parameters`** with `param=tools[N].function.parameters` (chat) / `tools[N].parameters` (responses). Pre-1.18.0 these were silently forwarded upstream; 1.18.0 enforces OpenAI's documented strict-mode contract locally before forwarding.

OpenSpec changes shipped in this release (to be archived after tag publish):
- deactivate-on-token-expired (Soju06#600)
- drop-unknown-message-fields (Soju06#637)
- mask-single-http-previous-response-miss (Soju06#516)
- normalize-v1-responses-openai-sdk-stream (Soju06#639)
- start-device-oauth-polling (Soju06#635)
- support-prolite-plan-capacity (Soju06#558)
- treat-upstream-overloaded-as-retryable (Soju06#601)
- validate-password-length (Soju06#598)
- validate-strict-function-tool-schema (Soju06#658)
vitalNohj pushed a commit to vitalNohj/codex-lb that referenced this pull request Jul 17, 2026
…u06#682)

Archive changes shipped in v1.18.0 and v1.18.1 per AGENTS.md
"release 이후 archive" workflow. All 12 changes verified shipped in
production at 10.0.0.113 (image 1.18.1, sha256:0431a474432d).

1.18.0 (9 changes):
- deactivate-on-token-expired (Soju06#600)
- drop-unknown-message-fields (Soju06#637)
- mask-single-http-previous-response-miss (Soju06#516)
- normalize-v1-responses-openai-sdk-stream (Soju06#639)
- start-device-oauth-polling (Soju06#635) [delta header fixed: MODIFIED -> ADDED]
- support-prolite-plan-capacity (Soju06#558) [delta header fixed: MODIFIED -> ADDED]
- treat-upstream-overloaded-as-retryable (Soju06#601)
- validate-password-length (Soju06#598)
- validate-strict-function-tool-schema (Soju06#658)

1.18.1 (3 changes):
- harden-long-codex-websocket-turns (Soju06#586)
- suppress-duplicate-side-effect-tool-calls (Soju06#586)
- hotfix-db-pool-pre-ping-and-firewall-cache-ttl (Soju06#679)

Specs updated: 9 capabilities (admin-auth, api-firewall, chat-completions-compat,
chat-completions-extensions, database-backends, frontend-architecture,
responses-api-compat, usage-refresh-policy).

openspec validate --specs: 19/19 passed.

Co-authored-by: Hermes Agent <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Agent stops after transient upstream overload error instead of retrying

2 participants