Skip to content

feat(balancer): bypass QUOTA_EXCEEDED filter for gated models with additional quota - #855

Closed
zwd0313 wants to merge 9 commits into
Soju06:mainfrom
zwd0313:feat/allow-gated-model-quota-exceeded-bypass
Closed

zwd0313 wants to merge 9 commits into
Soju06:mainfrom
zwd0313:feat/allow-gated-model-quota-exceeded-bypass

Conversation

@zwd0313

@zwd0313 zwd0313 commented May 30, 2026

Copy link
Copy Markdown

Problem

When a model is routed through an additional (gated) quota (e.g. `GPT-5.3-Codex-Spark`), `select_account()` unconditionally filters out all accounts with `QUOTA_EXCEEDED` status — even when the additional (independent) quota is available and the account is otherwise healthy. This causes legitimate gated-model requests to fail with "No available accounts".

The root cause: the `QUOTA_EXCEEDED` branch in `select_account()` does `continue` without checking whether an additional quota gate has already determined the account is eligible.

Change

Add a `bypass_quota_exceeded=False` keyword parameter to `select_account()` that, when `True`, skips the `QUOTA_EXCEEDED continue` branch while still respecting all other status checks (PAUSED, DEACTIVATED, RATE_LIMITED, cooldown, error backoff).

At the `LoadBalancer.select_account()` entry point, automatically compute:

```python
_effective_bypass_quota_exceeded = additional_limit_name is not None
```

so bypass is enabled for any gated-model request. The parameter flows through the full call chain:

  • `LoadBalancer.select_account()` → `_select_account_preferring_budget_safe()` → `select_account()`
  • `LoadBalancer.select_account()` → `_select_with_stickiness()` → `select_account()`

Impact scope: Only affects requests routed through an additional quota gate. Standard (non-gated) requests are unaffected (`additional_limit_name=None` → bypass stays `False`).

Testing

84/84 pass (82 existing + 2 new):

  • `test_bypass_quota_exceeded_keeps_account_in_pool`: confirms QUOTA_EXCEEDED account stays in pool when bypass=True
  • `test_bypass_quota_exceeded_does_not_affect_other_statuses`: confirms PAUSED/DEACTIVATED still filtered when bypass=True

Files changed (3 files, +65/-1)

File Change
`app/core/balancer/logic.py` New `bypass_quota_exceeded` param + skip logic
`app/modules/proxy/load_balancer.py` Param forwarding + entry-point computation
`tests/unit/test_load_balancer.py` 2 regression tests

@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: 551facccdc

ℹ️ 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/load_balancer.py Resolved
@Soju06 Soju06 added 🤖 codex: needs work [@codex review] raised an issue and removed 🤖 codex: needs work [@codex review] raised an issue labels May 31, 2026
@Komzpa

Komzpa commented May 31, 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: 934ca0635e

ℹ️ 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/core/balancer/logic.py Resolved
Comment thread app/modules/proxy/load_balancer.py Resolved
@Komzpa Komzpa added the 🤖 codex: needs work [@codex review] raised an issue label May 31, 2026
@Komzpa
Komzpa force-pushed the feat/allow-gated-model-quota-exceeded-bypass branch from 934ca06 to 295705f Compare May 31, 2026 20:14
@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label May 31, 2026
@Komzpa

Komzpa commented May 31, 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: 295705f392

ℹ️ 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/load_balancer.py Resolved
@Komzpa Komzpa added the 🤖 codex: needs work [@codex review] raised an issue label May 31, 2026
@Komzpa
Komzpa force-pushed the feat/allow-gated-model-quota-exceeded-bypass branch from 295705f to 24971c2 Compare May 31, 2026 20:32
@Komzpa

Komzpa commented May 31, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Keep them coming!

ℹ️ 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 🤖 codex: ok [@codex review] says no issues found. and removed 🤖 codex: needs work [@codex review] raised an issue 🤖 codex: ok [@codex review] says no issues found. labels May 31, 2026
@Komzpa
Komzpa force-pushed the feat/allow-gated-model-quota-exceeded-bypass branch 4 times, most recently from 3f99a17 to c51efb7 Compare May 31, 2026 22:03
@Soju06

Soju06 commented May 31, 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: c51efb7fed

ℹ️ 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/core/balancer/logic.py Resolved
@Soju06 Soju06 added the 🤖 codex: needs work [@codex review] raised an issue label May 31, 2026
@Komzpa
Komzpa force-pushed the feat/allow-gated-model-quota-exceeded-bypass branch from c51efb7 to 7266350 Compare May 31, 2026 22:46
@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label May 31, 2026
@Komzpa

Komzpa commented May 31, 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: 72663507ba

ℹ️ 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/usage/repository.py Resolved
@Komzpa Komzpa added the 🤖 codex: needs work [@codex review] raised an issue label May 31, 2026
@Komzpa
Komzpa force-pushed the feat/allow-gated-model-quota-exceeded-bypass branch from 7266350 to 9752e3e Compare May 31, 2026 23:07
@Soju06 Soju06 removed the 🤖 codex: needs work [@codex review] raised an issue label Jun 1, 2026
@Soju06

Soju06 commented Jun 1, 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: ae519914e0

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

Komzpa commented Jun 1, 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: 58a8cbe4c2

ℹ️ 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/load_balancer.py Resolved
@Komzpa Komzpa added the 🤖 codex: needs work [@codex review] raised an issue label Jun 1, 2026
@Komzpa
Komzpa force-pushed the feat/allow-gated-model-quota-exceeded-bypass branch from b13a5e2 to ca9e470 Compare June 1, 2026 07:04
@Komzpa

Komzpa commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@Komzpa Komzpa removed 🤖 codex: needs work [@codex review] raised an issue hermes: needs-followup Hermes left a blocker/comment that needs follow-up observation labels Jun 1, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Chef's kiss.

ℹ️ 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 🤖 codex: ok [@codex review] says no issues found. and removed 🤖 codex: ok [@codex review] says no issues found. labels Jun 1, 2026
# Conflicts:
#	app/core/balancer/logic.py
#	app/modules/proxy/load_balancer.py
@Komzpa

Komzpa commented Jun 1, 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: 5fa4382078

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

Komzpa commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

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

ℹ️ 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 added a commit to Komzpa/codex-lb that referenced this pull request Jun 1, 2026
# Conflicts:
#	app/core/balancer/logic.py
#	app/modules/proxy/account_cache.py
#	app/modules/proxy/load_balancer.py
#	tests/unit/test_proxy_load_balancer_refresh.py
@Komzpa

Komzpa commented Jun 2, 2026

Copy link
Copy Markdown
Collaborator

Folded into #716.

#716 is the surviving main-based routing/quota branch for this bucket. It includes the routing/quota changes from this PR, has current-head CI green, and has a clean current-head Codex review, so this separate PR can be closed to keep the queue reviewable.

@Komzpa Komzpa closed this Jun 2, 2026
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.

3 participants