Skip to content

fix(proxy): keep streams alive while account capacity recovers#1000

Merged
Komzpa merged 18 commits into
Soju06:mainfrom
softkleenex:wait-for-account-capacity
Jun 14, 2026
Merged

fix(proxy): keep streams alive while account capacity recovers#1000
Komzpa merged 18 commits into
Soju06:mainfrom
softkleenex:wait-for-account-capacity

Conversation

@softkleenex

Copy link
Copy Markdown
Contributor

Summary

  • keep streaming clients alive when account selection fails only because all eligible accounts are temporarily rate/usage limited
  • emit no-token codex.keepalive / response.in_progress frames while waiting, then retry selection after the balancer's retry hint/default interval
  • preserve fail-fast behavior for permanent selection failures such as re-auth required, paused accounts, plan mismatch, missing additional quota data, and local stream/bridge capacity overload

Covered paths

  • direct HTTP/SSE streaming retry
  • HTTP responses bridge session creation and bridge idle watchdog
  • native responses websocket connection selection

Tests

  • uv run python -m py_compile app/modules/proxy/_service/support.py app/modules/proxy/_service/http_bridge/mixin.py app/modules/proxy/_service/http_bridge/streaming.py app/modules/proxy/_service/websocket/mixin.py app/modules/proxy/_service/streaming/retry.py tests/unit/test_proxy_utils.py tests/unit/test_proxy_http_bridge.py
  • uv run ruff check app/modules/proxy/_service/support.py app/modules/proxy/_service/http_bridge/mixin.py app/modules/proxy/_service/http_bridge/streaming.py app/modules/proxy/_service/websocket/mixin.py app/modules/proxy/_service/streaming/retry.py tests/unit/test_proxy_utils.py tests/unit/test_proxy_http_bridge.py
  • uv run pytest tests/unit/test_proxy_utils.py tests/unit/test_proxy_http_bridge.py
  • uv run pytest tests/unit/test_load_balancer.py -k 'Try or rate_limit or exceeded or reset'

Notes

This keeps live streams alive across long account-capacity recovery windows, but it does not add durable job persistence. A process restart, OS sleep, client disconnect, or network drop can still end the in-flight stream.

@Komzpa

Komzpa commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

@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: aeaf9dfc40

ℹ️ 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/retry.py Outdated
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label Jun 14, 2026
@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 14, 2026
@Soju06

Soju06 commented Jun 14, 2026

Copy link
Copy Markdown
Owner

@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: 68f3154fbe

ℹ️ 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/support.py
@Komzpa Komzpa added the 🤖 codex: needs work [@codex review] raised an issue label Jun 14, 2026
@Komzpa

Komzpa commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 14, 2026

@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: 2a2f54de55

ℹ️ 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/support.py
Comment thread app/modules/proxy/_service/websocket/mixin.py Outdated
Comment thread app/modules/proxy/_service/http_bridge/streaming.py
@Komzpa Komzpa added the 🤖 codex: needs work [@codex review] raised an issue label Jun 14, 2026
@Komzpa

Komzpa commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 14, 2026

@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: 8ae2a6b145

ℹ️ 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/streaming.py Outdated
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label Jun 14, 2026
@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 14, 2026
@Komzpa

Komzpa commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

@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: e6381c63ef

ℹ️ 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/retry.py Outdated
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label Jun 14, 2026
@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 14, 2026
@Komzpa Komzpa removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 14, 2026
@Soju06

Soju06 commented Jun 14, 2026

Copy link
Copy Markdown
Owner

@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: b0a2084612

ℹ️ 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/websocket/mixin.py Outdated
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label Jun 14, 2026
@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 14, 2026
@Soju06

Soju06 commented Jun 14, 2026

Copy link
Copy Markdown
Owner

@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: 9c1569d2c3

ℹ️ 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/mixin.py Outdated
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label Jun 14, 2026
@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 14, 2026
@Soju06

Soju06 commented Jun 14, 2026

Copy link
Copy Markdown
Owner

@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: e370baeac9

ℹ️ 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/mixin.py Outdated
Comment thread app/modules/proxy/_service/http_bridge/streaming.py
@Komzpa Komzpa added the 🤖 codex: needs work [@codex review] raised an issue label Jun 14, 2026
@Komzpa Komzpa removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 14, 2026
@Komzpa

Komzpa commented Jun 14, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label Jun 14, 2026
@Komzpa Komzpa removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 14, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 🚀

Reviewed commit: a2184a8c46

ℹ️ 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 added the 🤖 codex: needs work [@codex review] raised an issue label Jun 14, 2026
@Komzpa Komzpa added 🤖 codex: ok [@codex review] says no issues found. and removed 🤖 codex: needs work [@codex review] raised an issue labels Jun 14, 2026
@Komzpa
Komzpa merged commit 8d8061b into Soju06:main Jun 14, 2026
25 checks passed
vitalNohj pushed a commit to vitalNohj/codex-lb that referenced this pull request Jul 17, 2026
…6#1000)

* fix(proxy): keep streams alive while account capacity recovers

* docs: add @softkleenex as a contributor

* fix(proxy): fail fast on generic no-account selection

* fix(proxy): bound stream capacity waits

* docs(openspec): cover account capacity stream waits

* fix(proxy): bound account capacity recovery waits

* fix(proxy): use bridge budget for capacity waits

* fix(proxy): tolerate legacy bridge budget settings

* fix(proxy): wait on owner stream capacity hints

* fix(proxy): use bridge budget for reattach waits

* fix(proxy): stop bridge capacity retry after budget wait

* fix(proxy): reuse bridge capacity wait after resend fallback

* fix(proxy): retry workspace spend cap capacity waits

* fix(proxy): wait during bridge recovery capacity retries

* fix(proxy): wait after websocket failover capacity hints

* fix(proxy): preserve bridge budget across capacity retries

* fix(proxy): preserve bridge capacity wait state

---------

Co-authored-by: Darafei Praliaskouski <me@komzpa.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🤖 codex: ok [@codex review] says no issues found.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants