Skip to content

fix(accounts): credit a setup-token session's rate limits to its provider account - #3957

Merged
muqsitnawaz merged 1 commit into
mainfrom
fix/statusline-token-attribution
Nov 2, 2026
Merged

muqsitnawaz merged 1 commit into
mainfrom
fix/statusline-token-attribution

Conversation

@taylorg009

@taylorg009 taylorg009 commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator

A setup-token provider session can share a managed installation with a native login. Its statusline previously wrote the provider's rate limits under the home login's identity, making an exhausted native login eligible for balanced selection again.

Resolve statusline attribution from the selected run account: provider limits use the provider's own usage key, native logins retain their home identity, and unknown account IDs write nothing. Provider candidates carry their cached usage, and balanced execution propagates the selected provider account ID. The collector preserves main's parallel credential checks.

Verification on the final file tree:

  • Canonical CLI build passed.
  • Targeted canonical test run: 223 passed, 1 existing skip across seven files; all 19 statusline and all 10 collector tests ran. Tests use real isolated account metadata, encrypted file-backed secret bundles, and usage-cache writes.
  • Comment-line check passed at the existing 1311-line ceiling, without changing policy; diff whitespace check passed.
  • Final PR delta: seven files. Independent review found no security or correctness blockers; its verdict and exact revision are posted in the PR comments.

The existing skip requires a managed Claude installation absent from the isolated test home. The full monorepo suite and a production installation were not run. Required GitHub checks remain the merge gate. This PR does not publish a release.

@muqsitnawaz

Copy link
Copy Markdown
Contributor

Maintainer follow-up: I am taking the conflict and CI repair for this PR. Independent triage found no security hold; the recorded Tests failure is the comment-line ceiling. I will preserve the newer parallel credential checks on main, remove the unnecessary added comments rather than raise the ceiling, verify the updated behavior, and obtain a new independent review before merging. The other open Linear-workspace PR remains separately on hold.

…ider account, not the home login

A session launched with a provider (setup-token) account runs inside the version home of a
native login. The Claude status line resolved the account from that home, so it wrote the
token account's headroom over the native login's usage key. On mars the poll kept recording
taylor@turingsaas.com at session 100% / week 56% while the token session's status line
rewrote it to 31% / 3% every refresh; each rewrite made the limited login eligible again and
`agents run claude --strategy balanced` picked it, then died with "You've hit your session
limit".

- claude-statusline: resolve the account from AGENTS_RUN_ACCOUNT_ID. A provider account's
  limits land under `claude:name=<account>`, a native login keeps the home identity, an id
  that matches neither writes nothing.
- account-pool-collect: provider candidates carry that usage key and its cached snapshot, so
  rotation excludes a limited token account instead of treating it as a permanently blind pick.
- exec: a balanced provider pick sets the spawn account so the session gets
  AGENTS_RUN_ACCOUNT_ID; the pick banner names the provider account.

Verified on mars with the built dist: a status line call carrying the turing-token run id
wrote `claude:name=turing-token` (38% / 10%) and left `claude:org=8763a87b…` untouched;
the next balanced pick listed turing-token as a verified candidate with that usage.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@muqsitnawaz
muqsitnawaz force-pushed the fix/statusline-token-attribution branch from 69e3630 to 0ac5289 Compare November 2, 2026 09:56
@muqsitnawaz

Copy link
Copy Markdown
Contributor

Independent non-author review of final head 0ac5289f83248e5dad2327662d9ef543ec380756.

VERDICT: APPROVE. READY TO MERGE once required CI passes. No blocking security or correctness findings; requirement conformance: YES.

  • cli/src/lib/accounting/account-pool-collect.ts:13,63-66 retains concurrent credential-presence checks and parallel native/provider collection.
  • cli/src/commands/exec.ts:2507-2509 carries the selected provider account into execution with spawnAccount = picked.
  • cli/src/lib/claude-statusline.ts:103-108 attributes provider limits to the provider's own key and returns no usage key for an unknown account. Line 137 refuses usage writes without that key.
  • cli/src/lib/claude-statusline.test.ts:239-242,270-280 uses real isolated file-backed bundles/account metadata, verifies native attribution, and exercises unknown-ID refusal.

The independent reviewer inspected the full seven-file repaired diff, including the conflict resolution. After the history-only rebase, the reviewer independently verified that the final head and previously reviewed repair share tree a74022df252593b4d16dd2dec3daf6f3f2c691af; git diff --exit-code returned 0. No code changed during that rebase.

Validation: canonical build passed; targeted tests reported 223 passed and one existing skip; comment ceiling and whitespace checks passed. The reviewer inspected tests without rerunning them. Required GitHub CI must pass on this final head before merge.

Filtered: 2 candidates (native test state is isolated; concurrent credential checks remain intact).

@muqsitnawaz
muqsitnawaz merged commit fb5b3dc into main Nov 2, 2026
8 checks passed
@muqsitnawaz
muqsitnawaz deleted the fix/statusline-token-attribution branch November 2, 2026 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants