Repository navigation
feat(routing): preserve account headroom with quota-aware Claude routing - #1
Conversation
|
Caution Review failedThe pull request is closed. Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
No new issues
Adds quota-aware routing for Claude OAuth accounts, ranking accounts by spendable allowance and reset timing while enforcing per-email reserves ahead of affinity, pinned selection, retries, and built-in scheduler delegates. Introduces background usage probes with rate-limit backoff and stale-credential safeguards, validated reloadable configuration, documentation, CI, and focused tests, while retaining priority-based routing for other providers and synchronizing an existing cancellation test.
Still open from earlier reviews (2)
- Preserve Codex priority ordering before applying WebSocket preference ·
selector_quota.go:126 - Honor HTTP-date Retry-After values for usage probes ·
service_quota.go:89
Review details
- Reviewed
fa786b0with 5 passes: rules, bugs, history, comments, spec.
Reply with @pipkin-bot to ask about a finding, or comment @pipkin-bot review to run the review again.
Claude account selection currently follows static priorities, so it cannot spend allowance according to reset timing or preserve capacity for use outside the proxy. This adds
routing.strategy: quota-awarefor Claude OAuth accounts and configurable per-account reserves matched by email.New bindings use the highest spendable-quota-per-second score across available accounts, constrained by each account's tightest applicable quota window. Reserves override session affinity, pinned selection, retries, and built-in plugin scheduler delegates. Protected accounts with missing or stale measurements are excluded; other providers keep existing priority-based round-robin behavior.
Normal response headers update quota observations. Background usage probes cover idle accounts, respect rate-limit backoff, and reject stale results from replaced credentials. The policy supports configuration reloads and rejects invalid reserve settings. See
NORTHBROOK.mdfor configuration, scoring, freshness, and accounting limitations.Validation:
go test ./...passed.Live verification: installed the fork locally with a 20% Gmail Claude reserve, populated quota observations for all three Claude accounts, and verified real Codex HTTP, Codex WebSocket, and Claude responses.
Also synchronized an existing upstream cancellation test after Linux CI exposed its immediate-assertion race; no production cancellation behavior changed.