feat(auth): account pool round-robin and fill-first strategies - #593
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Seed RR on manual select, gate affinity re-eval to quota, validate before mutate, keep automatic picks in-memory, and advance fill-first/RR on 429.
Mock shared /active defaults and pool-strategy so CodexPoolStrategySetting no longer races the auto-switch harness.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ 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". |
Return 400 for null/array/scalar JSON instead of throwing 500, and use POOL_KEY_ANTHROPIC in the sticky-release test.
|
Addressed remaining CodeRabbit nits in e6467e3:
|
🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
commit="a96d705d"
echo '=== Commit metadata and changed files ==='
git show --no-ext-diff --format=fuller --stat "$commit"
git diff-tree --no-commit-id --name-only -r "$commit" | sort
echo '=== Source/test outlines for changed TypeScript files ==='
git diff-tree --no-commit-id --name-only -r "$commit" |
while IFS= read -r file; do
case "$file" in
*.ts|*.tsx)
echo "--- $file"
ast-grep outline "$file" --items all 2>/dev/null || true
;;
esac
done
echo '=== Exact implementation/test patch ==='
git show --no-ext-diff --format= --find-renames "$commit" -- \
src/codex/routing.ts \
src/codex/auth-context.ts \
src/server/responses/core.ts \
src/oauth/anthropic-routing.ts \
src/codex/pool-rotation.ts \
tests/codex-pool-rotation.test.ts \
tests/anthropic-account-pool.test.ts \
tests/server-auth.test.ts
echo '=== Relevant code at the reviewed commit ==='
git show "$commit:src/codex/routing.ts" | nl -ba | sed -n '1,180p;500,720p;900,1060p'
git show "$commit:src/oauth/anthropic-routing.ts" | nl -ba | sed -n '140,260p;340,540p'
git show "$commit:src/server/responses/core.ts" | nl -ba | sed -n '260,360p'
git show "$commit:src/codex/pool-rotation.ts" | nl -ba | sed -n '80,190p'
echo '=== Focused regression-test sections at the reviewed commit ==='
git show "$commit:tests/codex-pool-rotation.test.ts" | nl -ba | sed -n '220,290p;360,500p'
git show "$commit:tests/anthropic-account-pool.test.ts" | nl -ba | sed -n '170,420p'
git show "$commit:tests/server-auth.test.ts" | nl -ba | sed -n '1650,1730p'Length of output: 45280 🏁 Script executed: #!/bin/bash
set -euo pipefail
commit="a96d705d"
show_range() {
local file="$1"
local range="$2"
echo "=== ${file}:${range} @ ${commit} ==="
git show "${commit}:${file}" | cat -n | sed -n "${range}p"
}
echo '=== Complete commit patch (including auth API) ==='
git show --no-ext-diff --format= --find-renames "$commit"
show_range src/codex/routing.ts '470,750'
show_range src/codex/routing.ts '740,1035'
show_range src/oauth/anthropic-routing.ts '130,340'
show_range src/oauth/anthropic-routing.ts '330,525'
show_range src/codex/auth-api.ts '500,760'
echo '=== Exact relevant call sites at the reviewed commit ==='
git grep -n -E \
'getEffectiveActiveCodexAccountId\(|promoteActiveCodexAccount\(|rememberActiveCodexAccount\(|setActiveCodexAccount\(|resolveAnthropicAccountForSession\(|getAnthropicPoolAccessToken\(|rotateAnthropicAccountOn429\(' \
"$commit" -- src tests || true
echo '=== Full modified test files at the reviewed commit ==='
git show "$commit:tests/codex-pool-rotation.test.ts" | cat -n | sed -n '1,500p'
git show "$commit:tests/anthropic-account-pool.test.ts" | cat -n | sed -n '1,430p'Length of output: 139947
The documented preview-reserve limitation remains properly constrained to the subagent fallback path and does not invalidate the routing changes in this commit. ✅ Action performedReview finished.
|
Summary
quota(default, unchanged),round-robin, andfill-firstaccountPoolStrategy/ stickyLimit; Anthropic nested fields)Fixes #592
Improvements (measured)
Fixture: 3 Codex pool accounts, equal quota, unbound new sessions.
vs 9Router / OmniRoute: session-granular RR (not request-granular), three composable strategies instead of a large menu, keeps existing generation/cooldown integrity.
Test plan
bun run typecheckbun run privacy:scanbun run lint:guicodex-pool-rotation,anthropic-account-pool,account-pool-management-api, GUI strategy testsSummary by CodeRabbit
accountPoolStrategy(quota, round-robin, fill-first) andaccountPoolStickyLimitfor new sessions.