feat(codex): opt in to priority failback for ongoing tasks - #3709
feat(codex): opt in to priority failback for ongoing tasks#3709sbrusse-git wants to merge 1 commit into
Conversation
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: trueThanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
⏳ DRAFT
What to do
Review readiness checklist
0/4 boxes ticked. This pull request was already a draft. Its draft status will be preserved after every issue above is resolved. |
|
@coderabbitai review Maintainer review requested: the intake gate flags Local validation for 8178755 passed: full suite 19,461 passed / 0 failed / 15 skipped, typecheck, focused regression tests, privacy scan, and documentation build. Keeping this PR in draft until review findings and the sponsorship gate are resolved. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '=== PR metadata and labels ==='
gh pr view 3709 --repo lidge-jun/opencodex --json number,title,state,isDraft,baseRefName,headRefName,labels,files \
--jq '{number,title,state,isDraft,baseRefName,headRefName,labels:[.labels[].name],files:[.files[].path]}'
echo '=== Changed-file summary ==='
git diff --stat HEAD~1..HEAD || true
git diff --name-status HEAD~1..HEAD || true
echo '=== Source and test outlines ==='
for path in \
src/codex/auth-api.ts \
src/codex/auth-context.ts \
tests/codex-integration/codex-routing.test.ts \
tests/codex-integration/codex-quota-prime.test.ts \
tests/codex-integration/codex-auth-context.test.ts
do
if [ -f "$path" ]; then
echo "--- outline: $path ---"
ast-grep outline "$path" --items all || true
fi
done
echo '=== Relevant changed diff ==='
git diff --unified=80 HEAD~1..HEAD -- \
src/codex/auth-api.ts \
src/codex/auth-context.ts \
tests/codex-integration/codex-routing.test.ts \
tests/codex-integration/codex-quota-prime.test.ts \
tests/codex-integration/codex-auth-context.test.ts \
|| true
echo '=== Routing and configuration symbols ==='
rg -n -C 5 --glob '*.ts' \
'codexAccountPriorityFailback|quota.*strategy|priority.*failback|prime.*quota|refresh.*quota|exact.*account|manual.*pin|cooldown|quotaScope' \
src tests/codex-integration || trueLength of output: 174523 🏁 Script executed: #!/bin/bash
set -euo pipefail
base="$(gh pr view 3709 --repo lidge-jun/opencodex --json baseRefOid --jq .baseRefOid)"
echo "=== PR identity ==="
gh pr view 3709 --repo lidge-jun/opencodex --json number,title,isDraft,labels,files \
--jq '{number,title,isDraft,labels:[.labels[].name],files:[.files[].path]}'
echo "base=$base head=$(git rev-parse HEAD)"
echo '=== Full PR changed files ==='
git diff --name-status "$base...HEAD"
echo '=== Full PR focused diff ==='
git diff --unified=35 "$base...HEAD" -- \
src/codex/auth-api.ts src/codex/auth-context.ts src/codex/routing.ts src/types/config.ts \
tests/codex-integration/codex-routing.test.ts tests/codex-integration/codex-quota-prime.test.ts \
tests/codex-integration/codex-auth-context.test.ts docs README.md
echo '=== auth-api relevant symbols ==='
rg -n -C 12 'primeCodexPoolQuotas|Quota.*Prime|quota.*prime|refresh.*quota|applyAccountQuotaFromUpstreamHeaders' src/codex/auth-api.ts
echo '=== auth-context relevant symbols ==='
rg -n -C 12 'primeCodexPoolQuotas|beginCodex|exactAccount|codexAccountMode|Direct|direct|quota.*prime|refresh.*quota' src/codex/auth-context.ts
echo '=== routing failback implementation ==='
sed -n '1575,1630p;1755,1860p;1980,2085p' src/codex/routing.ts
echo '=== focused test names and assertions ==='
for path in tests/codex-integration/codex-routing.test.ts tests/codex-integration/codex-quota-prime.test.ts tests/codex-integration/codex-auth-context.test.ts; do
echo "--- $path ---"
rg -n -C 4 'priority.*failback|failback|prime.*quota|quota.*prime|five.hour|300_000|300000|exact.*account|direct|manual.*pin|cooldown|independent' "$path" || true
done
echo '=== Sponsor label availability ==='
gh label list --repo lidge-jun/opencodex --limit 200 --json name --jq '.[] | select(.name == "maintainer-sponsored") | .name' || trueLength of output: 148388 🏁 Script executed: #!/bin/bash
set -euo pipefail
base="$(gh pr view 3709 --repo lidge-jun/opencodex --json baseRefOid --jq .baseRefOid)"
echo '=== Cache constants and all prime call sites ==='
rg -n -C 5 'POOL_CACHE_TTL|MAIN_CACHE_TTL|primeCodexPoolQuotas\s*\(' src tests/codex-integration
echo '=== Config validation and normalization ==='
rg -n -C 8 'accountPoolStrategy|codexAccountPriorityFailback|autoSwitchThreshold' src/config.ts src/types/config.ts
echo '=== Auth-context selection and trigger region ==='
sed -n '585,875p' src/codex/auth-context.ts
echo '=== Prime function and relevant token/dispatch path ==='
sed -n '1300,1685p' src/codex/auth-api.ts
echo '=== Documentation and structure diff ==='
git diff --unified=50 "$base...HEAD" -- \
docs-site/src/content/docs/guides/providers.md \
docs-site/src/content/docs/reference/configuration/providers.md \
structure/08_openai-provider-tiers.md \
src/config.ts
echo '=== Test setup and configuration helpers ==='
sed -n '1,230p' tests/codex-integration/codex-quota-prime.test.ts
rg -n -C 10 'function orderedConfig|const orderedConfig|function makeConfig|const makeConfig' \
tests/codex-integration/codex-routing.test.ts tests/codex-integration/codex-auth-context.test.tsLength of output: 140877 🏁 Script executed: #!/bin/bash
set -euo pipefail
gh pr edit 3709 --repo lidge-jun/opencodex --add-label "maintainer-sponsored"
gh pr view 3709 --repo lidge-jun/opencodex --json labels \
--jq '[.labels[].name] | sort'Length of output: 634
The implementation keeps the feature disabled by default. It uses the existing quota endpoint and credential paths. It does not add an authentication endpoint, credential format, or secret logging path. The reviewed paths retain the stated boundaries:
I attempted to apply You are interacting with an AI system. |
리뷰 · 우선순위 49 / 80이 PR은 Codex Pool 동작 요약입니다. 켜지면 bound 요청이 현재 계정 쿼터를 “알고 있어도” 현재 HEAD의 경로/심볼 - 메인테이너의 판단이 필요한 지점
너의 추천 이 댓글은 grok-bot이 작성했습니다 |
Summary
codexAccountPriorityFailbackfor the Codex Poolquotastrategy. A conversation that fell from a higher-priority account to a lower-priority one can return on its next request after observed quota confirms recovery, even while the current account remains below its switching threshold. Default behavior stays unchanged.ocx config set codexAccountPriorityFailback true. Add regression coverage for same-task five-hour recovery, disabled/default behavior, pins, unknown quota, model restrictions, cooldowns, rotation strategies, independent scopes, main-account refresh, and the refresh throttle.Verification
bun run typecheck— passed.bun run test— passed, exit 0; all suite shards passed.bun test tests/codex-integration/codex-routing.test.ts tests/codex-integration/codex-quota-prime.test.ts— final focused run: 204 passed, 0 failed.bun test tests/codex-integration/codex-auth-context.test.ts— 72 passed, 0 failed.bun run privacy:scan— passed.cd docs-site && bun install --frozen-lockfile && bun run build— passed, 425 pages built.Checklist
Contributor draft per repository policy. Maintainer security review/sponsorship is requested for the existing auth-context and quota-prime integration; no credential format, authentication endpoint, or secret logging is added. Automated review and maintainer review remain pending.
Review readiness checklist
This PR stays in draft until every box below is ticked. Tick all four boxes once the requirements are met:
All CI tests are green on my local testing.
I pushed my PR to the latest dev commit.
I resolved all correct Codex and CodeRabbit findings.
My PR is ready for review.