Skip to content

fix(coding-agent): prefer subscription accounts with headroom - #5053

Open
code-yeongyu wants to merge 9 commits into
mainfrom
feat/9234-headroom-skip
Open

code-yeongyu wants to merge 9 commits into
mainfrom
feat/9234-headroom-skip

Conversation

@code-yeongyu

@code-yeongyu code-yeongyu commented Oct 30, 2026 •

Copy link
Copy Markdown
Owner

Summary

Prefer subscription accounts with reported headroom before starting a request.

Part of code-yeongyu/oh-my-openagent#9234. Account-list usage display is delivered separately.

Root cause

Both the generic credential pool and the Claude subscription selector ranked accounts without consulting the latest reported subscription windows. A session could therefore keep selecting an account already at its limit while another account still had allowance.

Fix

  • Share a pure headroom preference between both selection paths.
  • Prefer the next usable account when any live window reports at least 95% usage; ignore reset windows and missing data.
  • Keep pins authoritative and preserve the current choice when every usable account is near its limit.
  • Retain the replacement account for session cache locality, without changing failure classification or block lifetimes.
  • Preserve Claude's explicit disabled-account-fallback setting.

Evidence

  • RED against the original selectors: 6 failed, 14 passed.
  • GREEN regression: 24 passed, 0 failed.
  • Changed-file oxfmt --check and oxlint: passed.
  • Full bun run check was not run under the lane's host-load restriction. Broad static validation is delegated to the post-push lane receipt.
  • Tests use synthetic accounts, a fake clock, and fake limit snapshots; no network or live model calls.

Summary by cubic

Fixes account selection so both the credential pool and the Claude subscription selector prefer accounts with reported headroom over ones already at their limit.

  • Skips accounts whose live usage window reports at least 95%; reset and missing windows are ignored.
  • Preserves pinned accounts, the current choice when every account is near its limit, and Claude's disabled-account-fallback setting.
  • Remembers the replacement account for session cache locality only; failure classification and block lifetimes are unchanged.
  • Adds regression tests covering both selection paths, seeding headroom Claude accounts as CLI-store slots.

Written for commit 7d711fc. Summary will update on new commits.

View guided diff Turn on auto-fix

Still open: typed blocked-account surface

This PR does not deliver the typed RPC/desktop surface that says why an account is blocked, until when, and what to do. That is the one open item for account visibility. It is tracked on #4092 (blocked on #4992 and #4674) and starts as soon as those two merge.

code-yeongyu and others added 2 commits October 30, 2026 10:03
Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
Co-authored-by: sisyphus-dev-ai <sisyphus-dev-ai@users.noreply.github.com>
@code-yeongyu code-yeongyu added the run-full-ci Run the full macOS/Windows CI set on this PR label Oct 31, 2026
@gitguardian

gitguardian Bot commented Oct 31, 2026

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
39343090 Triggered Generic High Entropy Secret d0524b3 packages/ai/test/anthropic-claude-oauth-token-refused.test.ts View secret
39343091 Triggered Generic High Entropy Secret d0524b3 packages/ai/test/anthropic-claude-oauth-token-refused.test.ts View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secrets safely. Learn here the best practices.
  3. Revoke and rotate these secrets.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-full-ci Run the full macOS/Windows CI set on this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant