Skip to content

fix(routing): preserve dispatch order and route feedback - #653

Open
guyu233 wants to merge 2 commits into
caigee-cmd:mainfrom
guyu233:fix/routing-dispatch-integrity
Open

guyu233 wants to merge 2 commits into
caigee-cmd:mainfrom
guyu233:fix/routing-dispatch-integrity

Conversation

@guyu233

@guyu233 guyu233 commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Problem

Routing had several integrity gaps that only showed up under failover or heavy concurrency:

  • An account was reserved and rotation was updated as separate steps, so a full account could consume an upstream attempt and a failover could escape the provider/region the request and API key allow.
  • Dispatch, cooldowns, and stream feedback occasionally used the requested model instead of the resolved one, and the API-key concurrency check ran after an aggregation classifier could already send an upstream request.
  • Priority aggregations rotated only within one tier, max_attempts counted per tier instead of across tiers, and named dispatch groups could reorder members for dual-protocol Responses requests.
  • Nested group listings/previews drifted from configured members, quota checks used the unresolved model, and late successes could revive explicitly rejected models.
  • The public model list could disagree with API-key grants and routing for namespaced models and group names shadowing account aliases; canceled streams could cool healthy accounts and stale session affinity could block a healthy fallback.

Change (high level)

  • One reservation step that commits account selection and rotation together; full accounts do not consume an attempt, and failover cannot leave the allowed provider/region.
  • Dispatch, cooldown, and stream feedback use the resolved account/model; API-key concurrency is acquired before a classifier can send upstream.
  • Priority aggregation rotation spans the best available tier; max_attempts caps dispatches of the requested model across all tiers.
  • Named groups keep member order for dual-protocol Responses and honor explicit no-failover errors; early heartbeats no longer announce a provisional account.
  • Group listings/previews follow the current member configuration; quota checks use the resolved model; late successes do not restore rejected models.
  • Public model list matches API-key grants and routing; canceled streams no longer cool accounts; stale affinity cannot block a fallback.

The commit is the fork’s reviewed routing change, cherry-picked onto current main with the console assets rebuilt (npm run sync).

Validation

  • go build ./...
  • go vet ./...
  • go test ./internal/executor ./internal/gateway ./internal/control ./internal/app ./internal/console ./internal/accounts -count=1
  • cd frontend && npm run lint (0 errors)
  • cd frontend && npm run sync

Reserve account slots atomically and preserve dispatch group order, grants and failover budgets across protocols. Keep catalog and stream feedback aligned with the concrete target.

(cherry picked from commit 427c066)
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.

1 participant