fix(proxy): retry accepted capacity bridge failures - #1384
Conversation
251c570 to
4d3a04d
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: aabc8da834
ℹ️ 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".
b119d6c to
8062265
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8062265485
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Already looking forward to the next diff. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
8043fdc to
7563c32
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. Delightful! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
abcd853 to
fc86a9d
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 0148a2f96a
ℹ️ 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".
a8fca26 to
c896bb9
Compare
|
@codex review |
f246d1f to
efe2eb6
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f526e281d2
ℹ️ 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".
| client_ip=client_ip, | ||
| ) | ||
| return | ||
| if last_exhausted_transient_exc is not None: |
There was a problem hiding this comment.
Preserve the later security-work failure
When account A exhausts transient overload retries and account B subsequently returns security_work_authorization_required, the security path records last_security_work_retry_error and excludes B. If no authorized account is then selectable, this newly inserted branch runs before the security-work branch and returns account A's stale overload instead, hiding the actionable trusted-access failure after already telling the client that an authorized account is being selected. Preserve the existing security-work precedence or clear the stale transient once another account is attempted.
AGENTS.md reference: AGENTS.md:L105-L110
Useful? React with 👍 / 👎.
| error_code=message.error_code, | ||
| error_message=message.error, | ||
| ) | ||
| capacity_retry_attempted = capacity_retry_code is not None and archive_request_state is not None |
There was a problem hiding this comment.
Keep blocked untyped closes account-neutral
When an untyped bridge close is not eligible for replay because output was already observed, another request is pending, or replay_count is exhausted, this expression leaves capacity_retry_attempted false and the later reader-failure call computes penalize_account=True from message.error_code is None. That records a health failure against an otherwise healthy account, contrary to the account-neutral guarantee in openspec/specs/responses-api-compat/spec.md:244; carry the untyped-close classification separately from retry eligibility and disable the penalty when replay is blocked.
AGENTS.md reference: AGENTS.md:L105-L110
Useful? React with 👍 / 👎.
Summary
retry-server-is-overloadedRoot cause
The bridge handled failures before
response.created, but later accepted responses could still fail with overload/capacity or an abrupt close before any model output became visible. Those failures were surfaced as terminal even though the narrow output-free request was safe to replay. The direct non-streaming and initial-stream-EOF paths similarly returned before entering their bounded transient retry path.The retry path now preserves downstream continuity and refuses replay after downstream detach, deadline expiry, visible output, or an unsafe continuation. Local transport and reader closes remain account-neutral; real upstream account errors retain their existing health penalties.
Validation
4ee8538421eaa6a46cfa199055b435dd019deb45uv run pytest tests/unit/test_proxy_http_bridge.py tests/unit/test_proxy_utils.py -q-> 1239 passeduv run pytest tests/integration/test_http_responses_bridge.py tests/integration/test_proxy_api_extended.py tests/integration/test_proxy_transient_retry.py -q-> 183 passeduv run ruff check app/modules/proxy tests/unit/test_proxy_http_bridge.py tests/unit/test_proxy_utils.py tests/integration/test_http_responses_bridge.py tests/integration/test_proxy_api_extended.py tests/integration/test_proxy_transient_retry.py-> passeduv run ty check app/modules/proxy-> passedopenspec validate retry-server-is-overloaded --strict-> passedgit diff --check origin/main...HEAD-> passed