feat(proxy): add fill-first routing strategy#831
Conversation
e94fd6f to
119acee
Compare
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 119aceed59
ℹ️ 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".
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9231178ffb
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Add a new `fill_first` routing strategy that deterministically picks the eligible account with the lowest primary 5h `used_percent`, tiebreaking on `account_id` ascending. The 'fill' behavior emerges naturally from the existing `effective_pool` ladder: an account stays selected while it remains the lowest-usage candidate, and traffic only moves once the upstream marks that account rate-limited or quota-exceeded (or it transitions to draining). Touches: - balancer: extend `RoutingStrategy`, add `_select_fill_first`, dispatch - settings: widen Pydantic regex; `_routing_strategy()` propagates `fill_first` - frontend: schema, dropdown, status-bar label, mocks - tests: unit, integration, settings-API round-trip, frontend - openspec: change folder + proxy-admission-control delta No alembic migration: `dashboard_settings.routing_strategy` is a free-form String column with app-level Pydantic validation only. Default routing strategy unchanged (capacity_weighted).
3c122cf to
56e3555
Compare
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 56e3555970
ℹ️ 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".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 56e3555970
ℹ️ 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".
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 060783be27
ℹ️ 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".
060783b to
45a10fc
Compare
|
@codex review |
|
Codex Review: Didn't find any major issues. What shall we delve into next? ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
Summary
Add a new
fill_firstrouting strategy that deterministically picks the eligible account with the lowest primary 5hused_percent, tiebroken byaccount_idascending. Operators get a single-account-at-a-time mode for prompt-cache locality and predictable cost attribution, without changing the default routing strategy.Type of change
feat:— new user-facing feature or capabilityLinked issue:
OpenSpec
Change directory:
openspec/changes/add-fill-first-routing-strategy/The change adds:
proposal.md— problem, solution, scope, impacttasks.md— implementation breakdown (T1–T19)specs/proxy-admission-control/spec.md—## ADDED Requirementsdelta with normative scenarios for deterministic ranking, stable selection, transition-on-pool-exit, andaccount_idtiebreakChanges
app/core/balancer/logic.py: extendRoutingStrategyliteral to include"fill_first"; add_fill_first_sort_keyand_select_fill_firsthelpers; add new dispatch branch inselect_account()that applies_prefer_earlier_reset_candidatesthe same way ascapacity_weighted. Determinism is a hard property — no randomness, only(used_percent, account_id).app/modules/proxy/service.py: extend_routing_strategy()to propagate the new value toLoadBalancer.select_account(). Without this, the dashboard would acceptfill_firstbut the proxy would silently fall back tocapacity_weighted.app/modules/settings/schemas.py: widen Pydantic regex on both response and update models.frontend/src/features/settings/schemas.ts: extendRoutingStrategySchema; align the optional default with the backend (capacity_weighted).frontend/src/features/settings/components/routing-settings.tsx: add<SelectItem value="fill_first">Fill first</SelectItem>directly under "Capacity weighted"; widen theonValueChangeliteral cast.frontend/src/components/layout/status-bar.tsx: widengetRoutingLabel(...)to renderfill_firstwith sticky / prefer-earlier-reset compositions.frontend/src/utils/constants.ts: addfill_first: "fill first"toROUTING_LABELS.frontend/src/test/mocks/handlers.ts: widen the routing-strategy Zod enum.routing-settings.test.tsx,schemas.test.ts, andconstants.test.ts.No alembic migration:
dashboard_settings.routing_strategyis a free-formStringcolumn with app-level Pydantic validation only; the existing column accepts the new value as-is. Default routing strategy is unchanged (capacity_weighted).Test plan
Checklist
CHANGELOG.mdby hand.openspec validate --specswill run in CI; the local CLI was unavailable in the dev environment.