Repository navigation
fix(accounts): honor autoSwitchThreshold=0 as disabled - #5091
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configurationConfiguration used: Repository: lidge-jun/opencodex/.coderabbit.yaml Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks 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
✅ 4/4 boxes ticked. Automatic draft conversion failed (token cannot change draft status). Please convert this pull request to a draft manually. The required |
리뷰 · 우선순위 56 / 80계정을 자동으로 바꾸지 말라고 0을 저장했는데, 그 0이 "다 썼으니 바꿔"로 읽히던 버그를 고친 PR이에요. 여러 계정을 모아 쓰는 generic OAuth 풀의 fill-first는 지금 계정을 쓰다가, 사용량이 기준을 넘으면 다음 계정으로 넘겨요. 기준 숫자 고친 곳은 한 줄이에요. 기준이 0 이하면 넘지 않았다고 보고 지금 계정을 유지해요. 429나 401이 나서 복구하는 길은 그대로예요. 상태 명령도 풀이 켜져 있어도 저장된 0을 꺼짐으로 보여 줘요. 테스트 두 개와 문서가 이 규칙을 적어요. 베이스는 structure/config.md - 설정 그룹 표 바로 밑에 CLI 상태 문단이 들어갔어요. 이번에 고친 규칙은 tests/cli/cli-account-pool-verbs.test.ts - JSON의 메인테이너의 판단이 필요한 지점 아직 draft예요. 너의 추천 가드 한 줄은 Codex, Anthropic과 같은 뜻이고, 사용량 100% 테스트가 예전 버그를 잡아요. 문서 문단만 정리하고 스폰서 라벨을 단 뒤 머지하면 돼요. 닫을 중복 PR은 없어요. 이 댓글은 grok-bot이 작성했습니다 |
리뷰 · 우선순위 62 / 80이 PR은 로그인 계정을 여러 개 묶어 쓸 때, "사용량이 이 퍼센트면 다음 계정으로 넘겨라"를 0으로 저장하면 그 기능이 꺼지게 고칩니다. 범용 풀(xAI, Antigravity 같은 OAuth 계정)이 fill-first이면, 지금 계정의 사용량이 저장해 둔 숫자를 넘을 때 다음 계정으로 바꿉니다. 끄는 값은 0입니다. CLI에서 끄면 0이 저장됩니다. Codex 풀과 Anthropic 풀은 이미 0이면 사용량 때문에 옮기지 않습니다. 범용 풀만 그 확인이 없었습니다. 남은 사용량을 숫자로 알고 있으면 예전 식은 고친 코드는 베이스는 structure/config.md - 새 문단이 설정 묶음 표 바로 아래, 환경 변수 문단 앞에 있습니다. 키 이름 메인테이너의 판단이 필요한 지점
너의 추천 코드는 이대로 둬도 됩니다. 0을 꺼짐으로 읽는 쪽이 Codex, Anthropic과 같고, 테스트가 그 경우를 고정합니다. 드래프트를 풀기 전에 이 댓글은 grok-bot이 작성했습니다 |
Also drop the config.md paragraph that duplicated the transports inventory rule without naming the oauthAccountFailover.autoSwitchThreshold key.
43dc193 to
d8351c7
Compare
|
Author note: the hygiene/enforce-target gates fail with unsponsored_surface — the change touches the account/failover surface, so it needs the maintainer-sponsored label before it can leave draft. The two review findings (stale doc paragraph, missing non-JSON output assertion) are addressed at head 43dc193. |
Motivation
A generic OAuth provider's
autoSwitchThresholduses0as the stored "off" value, butisOverAutoSwitchThresholdhad no non-positive guard, so100 - headroom >= 0was always true. With fill-first routing, a threshold explicitly stored as0(disabled) therefore read as exceeded on every request and proactively rotated requests — and billing — onto another pooled account.Description
isOverAutoSwitchThresholdsothreshold <= 0always returnsfalse, disabling proactive usage-based switching while leaving reactive recovery (429/401 driven) unchanged (src/oauth/generic-account-failover.ts).src/cli/account-extended.ts).autoSwitchThresholdis0and that the CLI status JSON reports a zero threshold as disabled (tests/oauth/generic-oauth-failover.test.ts,tests/cli/cli-account-pool-verbs.test.ts).structure/config.md,structure/providers/xai-grok.md,structure/transports/inventory.md).Tests
bun test tests/oauth/generic-oauth-failover.test.ts— 45 pass, 0 fail.bun test tests/cli/cli-account-pool-verbs.test.ts— 30 pass, 0 fail.bun run typecheck— clean.bun run structure:check— passed.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.