Skip to content

fix(proxy): prefer budget-safe routing and support image-generation compatibility#1

Merged
RazvanBugoi merged 4 commits intomainfrom
fix/pr-421-budget-safe-routing-image-generation
Apr 21, 2026
Merged

fix(proxy): prefer budget-safe routing and support image-generation compatibility#1
RazvanBugoi merged 4 commits intomainfrom
fix/pr-421-budget-safe-routing-image-generation

Conversation

@RazvanBugoi
Copy link
Copy Markdown
Owner

Summary

Upstream reference

Validation

  • uv run pytest tests/unit/test_openai_requests.py tests/unit/test_proxy_load_balancer_refresh.py tests/unit/test_proxy_utils.py tests/unit/test_select_with_stickiness.py tests/unit/test_settings_multi_replica.py tests/integration/test_openai_compat_features.py tests/integration/test_proxy_compact.py tests/integration/test_proxy_sticky_sessions.py -> 361 passed, 3 skipped
  • openspec validate --specs not run: openspec CLI not installed in local environment

Copy link
Copy Markdown

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

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

ℹ️ 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 on lines 717 to 720
pool_also_exhausted = pool_best.account is not None and (
pool_best.account.account_id == pinned.account_id
or (
pool_best.account.used_percent is not None
and pool_best.account.used_percent > budget_threshold_pct
)
or _state_above_budget_threshold(pool_best.account, budget_threshold_pct)
)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve codex-session mapping when no safer account exists

Handle the pool_best.account is None case as “no better candidate” instead of forcing reallocation. With the new CODEX_SESSION budget-pressure path, if the pinned account is above threshold but temporarily unavailable (for example in cooldown) and all other accounts are unavailable, _select_account_preferring_budget_safe(...) can return no account; this expression then makes pool_also_exhausted false and the code deletes stickiness anyway. That drops durable session affinity despite there being no eligible below-threshold replacement, which can cause avoidable session rebinding/loss and No available accounts behavior on follow-up requests.

Useful? React with 👍 / 👎.

@RazvanBugoi RazvanBugoi merged commit c2c3e84 into main Apr 21, 2026
@RazvanBugoi RazvanBugoi deleted the fix/pr-421-budget-safe-routing-image-generation branch April 21, 2026 06:35
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.

2 participants