fix(proxy): prefer budget-safe routing and support image-generation compatibility#1
Conversation
There was a problem hiding this comment.
💡 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".
| 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) | ||
| ) |
There was a problem hiding this comment.
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 👍 / 👎.
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 skippedopenspec validate --specsnot run:openspecCLI not installed in local environment