Skip to content

fix(proxy): retry accepted capacity bridge failures - #1384

Open
Komzpa wants to merge 25 commits into
Soju06:mainfrom
Komzpa:fix/selected-model-capacity-retry-20260716
Open

fix(proxy): retry accepted capacity bridge failures#1384
Komzpa wants to merge 25 commits into
Soju06:mainfrom
Komzpa:fix/selected-model-capacity-retry-20260716

Conversation

@Komzpa

@Komzpa Komzpa commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • retry accepted-but-output-free HTTP bridge overload, selected-model-capacity, and abrupt-close failures before model output is visible
  • retry direct non-streaming Responses API overload responses and initial upstream stream EOFs through the existing bounded retry path
  • preserve owner-pinned quota handling while keeping local bridge/websocket close failures account-neutral
  • bound accepted retries by downstream attachment, request deadline, and visible-output state; retain the pending close failure for the reader when replay cannot proceed
  • update OpenSpec coverage and CI label-helper tests for retry-server-is-overloaded

Root 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

  • Head: 4ee8538421eaa6a46cfa199055b435dd019deb45
  • uv run pytest tests/unit/test_proxy_http_bridge.py tests/unit/test_proxy_utils.py -q -> 1239 passed
  • uv 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 passed
  • uv 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 -> passed
  • uv run ty check app/modules/proxy -> passed
  • openspec validate retry-server-is-overloaded --strict -> passed
  • git diff --check origin/main...HEAD -> passed

@Komzpa
Komzpa force-pushed the fix/selected-model-capacity-retry-20260716 branch from 251c570 to 4d3a04d Compare July 16, 2026 21:11
@Komzpa

Komzpa commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread app/modules/proxy/_service/streaming/mixin.py Outdated
Comment thread app/modules/proxy/_service/http_bridge/upstream_events.py Outdated
@Komzpa Komzpa added 🤖 codex: ok [@codex review] says no issues found. simplicity-budget-approved Maintainer-approved exception to a simplicity budget (PRINCIPLES.md P3) labels Jul 16, 2026
@Komzpa
Komzpa force-pushed the fix/selected-model-capacity-retry-20260716 branch from b119d6c to 8062265 Compare July 16, 2026 23:22
@Komzpa

Komzpa commented Jul 16, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread .github/scripts/fetch_pr_labels.py
Comment thread .github/scripts/detect_changed_areas.py
Comment thread .github/scripts/check_all_contributors.py Outdated
@Komzpa Komzpa added 🤖 codex: needs work [@codex review] raised an issue and removed 🤖 codex: ok [@codex review] says no issues found. 🤖 codex: needs work [@codex review] raised an issue labels Jul 16, 2026
@Komzpa

Komzpa commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

Reviewed commit: 8043fdc51e

ℹ️ 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".

@Komzpa Komzpa added the 🤖 codex: ok [@codex review] says no issues found. label Jul 17, 2026
@Komzpa
Komzpa force-pushed the fix/selected-model-capacity-retry-20260716 branch from 8043fdc to 7563c32 Compare July 17, 2026 08:52
@Komzpa Komzpa removed the 🤖 codex: ok [@codex review] says no issues found. label Jul 17, 2026
@Komzpa

Komzpa commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Delightful!

Reviewed commit: 7563c322f7

ℹ️ 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".

@Komzpa Komzpa added the 🤖 codex: ok [@codex review] says no issues found. label Jul 17, 2026
@Komzpa
Komzpa force-pushed the fix/selected-model-capacity-retry-20260716 branch from abcd853 to fc86a9d Compare July 19, 2026 11:27
@Komzpa Komzpa removed the 🤖 codex: ok [@codex review] says no issues found. label Jul 19, 2026
@Komzpa

Komzpa commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread app/modules/proxy/_service/http_bridge/request_submit.py
@Komzpa Komzpa added the 🤖 codex: needs work [@codex review] raised an issue label Jul 22, 2026
@Komzpa
Komzpa force-pushed the fix/selected-model-capacity-retry-20260716 branch from a8fca26 to c896bb9 Compare July 22, 2026 08:42
Komzpa added a commit to Komzpa/codex-lb that referenced this pull request Jul 22, 2026
@Komzpa Komzpa removed the 🤖 codex: needs work [@codex review] raised an issue label Jul 22, 2026
@Komzpa

Komzpa commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@Komzpa
Komzpa force-pushed the fix/selected-model-capacity-retry-20260716 branch from f246d1f to efe2eb6 Compare August 6, 2026 23:13
@Komzpa Komzpa removed the needs rebase Needs rebase or conflict repair against current main label Aug 7, 2026
@Komzpa

Komzpa commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@Komzpa Komzpa added 🤖 codex: needs work [@codex review] raised an issue needs rebase Needs rebase or conflict repair against current main and removed 🤖 codex: needs work [@codex review] raised an issue labels Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Needs rebase or conflict repair against current main simplicity-budget-approved Maintainer-approved exception to a simplicity budget (PRINCIPLES.md P3)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants