Skip to content

fix(codex): make manual account selection immediate - #506

Merged
Ingwannu merged 1 commit into
devfrom
agent/fix-issue-504-immediate-account
Jul 26, 2026
Merged

Ingwannu merged 1 commit into
devfrom
agent/fix-issue-504-immediate-account

Conversation

@Ingwannu

Copy link
Copy Markdown
Owner

Summary

  • clear existing thread affinity and selected-account transient state on manual selection while preserving hard 429 cooldown and reauth state
  • keep an explicitly active account while quota is unknown
  • apply transient soft-avoid and affinity clearing only at the configured failover threshold
  • return appliesImmediately: true and align GUI, CLI, and localized docs with next-request semantics

Validation

  • backend/CLI focused tests: 199 passed
  • GUI focused tests: 13 passed
  • TypeScript typecheck, GUI ESLint, GUI production build
  • docs site: 131 pages built

Closes #504

@Ingwannu
Ingwannu requested a review from lidge-jun as a code owner July 26, 2026 14:47
@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@Ingwannu, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 16 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 730a437a-5170-4654-a6b9-ebde9622d73c

📥 Commits

Reviewing files that changed from the base of the PR and between c426a90 and ea2766a.

📒 Files selected for processing (27)
  • docs-site/src/content/docs/guides/web-dashboard.md
  • docs-site/src/content/docs/ja/guides/web-dashboard.md
  • docs-site/src/content/docs/ja/reference/cli.md
  • docs-site/src/content/docs/ja/reference/configuration.md
  • docs-site/src/content/docs/ko/guides/web-dashboard.md
  • docs-site/src/content/docs/ko/reference/cli.md
  • docs-site/src/content/docs/ko/reference/configuration.md
  • docs-site/src/content/docs/reference/cli.md
  • docs-site/src/content/docs/reference/configuration.md
  • docs-site/src/content/docs/ru/guides/web-dashboard.md
  • docs-site/src/content/docs/ru/reference/cli.md
  • docs-site/src/content/docs/ru/reference/configuration.md
  • docs-site/src/content/docs/zh-cn/guides/web-dashboard.md
  • docs-site/src/content/docs/zh-cn/reference/cli.md
  • docs-site/src/content/docs/zh-cn/reference/configuration.md
  • gui/src/i18n/de.ts
  • gui/src/i18n/en.ts
  • gui/src/i18n/ja.ts
  • gui/src/i18n/ko.ts
  • gui/src/i18n/ru.ts
  • gui/src/i18n/zh.ts
  • src/cli/account.ts
  • src/codex/auth-api.ts
  • src/codex/routing.ts
  • tests/cli-account.test.ts
  • tests/codex-auth-api.test.ts
  • tests/codex-routing.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/fix-issue-504-immediate-account

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added the bug Something isn't working label Jul 26, 2026
@Ingwannu
Ingwannu merged commit 2d5d491 into dev Jul 26, 2026
10 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ea2766a739

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Comment thread src/codex/auth-api.ts
resetCodexRoutingForManualSelection(body.accountId ?? MAIN_CODEX_ACCOUNT_ID);
saveRuntimeConfig(config, runtimeConfig);
return jsonResponse({ ok: true, activeCodexAccountId: body.accountId });
return jsonResponse({ ok: true, activeCodexAccountId: body.accountId, appliesImmediately: true });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid promising immediate use for ineligible selections

When this PUT selects an account that is under a preserved hard 429 cooldown, or whose known usage exceeds the enabled auto-switch threshold while a lower-usage account exists, the next resolver call chooses a fallback and may overwrite the active ID before the selected account handles any request. Returning appliesImmediately: true—alongside the new GUI copy promising that the next request will use the account—is therefore incorrect for these reachable cases; either give a manual selection a one-request override or report and document that application is conditional.

Useful? React with 👍 / 👎.

| `POST /api/oauth/login` · `GET /api/oauth/status` | Start a provider OAuth flow and poll for completion. |
| `GET /api/codex-auth/accounts?refresh=1` | List main and pool accounts, force quota refresh, and report main-account `hasCredential` / terminal `needsReauth` state. |
| `PUT /api/codex-auth/active` · `PUT /api/codex-auth/auto-switch` · `PUT /api/codex-auth/failover` | Select the next-session account and configure pool routing. |
| `PUT /api/codex-auth/active` · `PUT /api/codex-auth/auto-switch` · `PUT /api/codex-auth/failover` | Select the account for the next request and configure pool routing. |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Update the stale manual-switch overview

This new next-request description contradicts the same guide's lines 82–83, which still say that manual selection affects only a new session and that an already-bound thread keeps its account; resetCodexRoutingForManualSelection() now clears all thread affinity, so that overview and its translated equivalents describe the opposite behavior. Update those bullets together with this endpoint row.

AGENTS.md reference: AGENTS.md:L78-L79

Useful? React with 👍 / 👎.

Comment thread src/codex/routing.ts
const activeUsage = computeCodexUsageScore(quota, getPoolAccountPlan(config, active));
// Unknown usage is not evidence that a user's explicit selection crossed the
// threshold. Wait for quota priming instead of rotating among guesses.
if (isUnknownUsage(activeUsage)) return active;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep a real 100% quota distinct from unknown usage

CODEX_UNKNOWN_USAGE_SCORE is exactly 100, while parsed quota percentages are clamped to the inclusive range 0–100, so this new early return also classifies a real, known 100% usage value as unknown. With auto-switch enabled and another account at lower usage, an exhausted active account now remains selected instead of switching at the configured threshold; the same guard also blocks preview and bound-thread reevaluation. Distinguish missing quota from a known 100% value and add a routing regression for this boundary.

AGENTS.md reference: AGENTS.md:L75-L77

Useful? React with 👍 / 👎.

@lidge-jun
lidge-jun deleted the agent/fix-issue-504-immediate-account branch July 29, 2026 04:29
agentHits pushed a commit to agentHits/opencodex that referenced this pull request Sep 17, 2026
…mmediate-account

fix(codex): make manual account selection immediate
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant