Repository navigation
Replies: 8 comments 2 replies
|
I think this would be a wonderful idea. Especially for the fact that we keep hitting token limits at the most in-opportune time. I would also be more than willing to help architect / design this. This would add a lot of value for long term work flows (especially seeing that GPT 6 is soon to hit the public). |
|
I'd like to help move this forward with a narrower, configurable version. What's changed since this was opened:Usage ‚-> Limits now collects session/weekly windows ( Proposal: opt-in "Auto-select account" for new threads only An off-by-default setting in Settings ‚-> Providers. When it's on, the new-thread composer resolves the account (provider instance) from the latest Limits snapshot before the first message is sent. The choice shows as a chip, e.g. "Auto ¬∑ Claude (work) ¬∑ 23% of 5h used, resets in 2h", and you can override it for that thread from the model picker as you would today. The user can configure:
Rules:
Out of scope (each one is a separate problem):
Questions for maintainers
If the direction is approved, I'm happy to implement it as one focused PR with tests. |
|
I built a version of this to find the smallest shape that works, and opened it as a draft so the trade-offs are concrete: #16076. It has no maintainer approval, so treat it as a proposal for this discussion; I will close it if the direction is not wanted. What it does. One opt-in environment setting, Rotate accounts for new threads, off by default, plus an Account rotation switch on each account in Settings → Providers, also off by default. While a thread is still a draft, the client picks its account among the selected provider's marked accounts that are signed in and offer the selected model: most usage left first, then the account whose last thread was started longest ago. Model and options stay as selected. An account picked in the model picker stands, a project's own default model stands, and a started thread never moves. Two things I did not expect.
Guards. Only the accounts the user marks take part, and a draft on an unmarked account is left alone, so nothing moves to an API-key or proxy instance unless the user marks it. Reset times are compared against the environment's latest provider report, not the client clock. A draft that is sending or being promoted is left alone. Left out on purpose: continuing a thread that stopped on a limit, rotating between turns, changing model or provider, and threads the server starts itself (scheduled tasks, agent-created threads). Open questions I would like a maintainer's call on: whether the client-side draft is an acceptable home for this (the alternative is server-side with a client change to adopt the result), and whether the setting belongs next to the usage-limit rows. Edited 2026-10-05: eligibility is now per account. The first version took in every subscription account, guessed from what each one reports about its usage. Built and tested with Claude Code (Claude Opus 5.5) on my own accounts. |
|
A different cut of the same wish, running in my fork: don't rotate, switch only when the account is actually used up. With two subscriptions per provider, rotation is not what I want. I want to use one account's weekly allowance to the end and then move on, without thinking about it. And with Codex there is a trap: at 0% the turn does not fail, it quietly continues on ChatGPT credits. Nothing tells you. What the fork does:
Why I like this shape:
Evidence: a real run in a dev build (thread on an account at 100% of its weekly window, message sent, the turn ran and finished on the other account, handed over by summary), plus seven mid-thread account switches in my daily database. Honest limits: readings are periodic and can be stale, ChatGPT-connected accounts report no limits, and "every account is empty" does not yet say so. @mneves75 your #16076 and this would fit together: rotation for new threads, exhaustion for running ones. Would one setting with two modes make sense to people here? Code: Posted by Claude (Opus 5.5, Claude Code via T3 Code) on behalf of @AdEx-Partners-DE. |
|
+1 to the original idea. One rule on the server (pick the account with the most headroom for the model) is the right size. I want to suggest a narrower first scope that I think avoids what made #16076 hard: apply it to delegated tasks ( I run 5 Claude and 2 Codex subscriptions. Most of my uneven usage comes from orchestrating threads that send subagents to whichever account the parent is on. Right now, one account's 5-hour window runs out while the others sit near 100%. For new threads, #16076 had to show the chosen account in the draft, keep it from changing while you type, and handle the clients resending the draft's account on the next turn. Delegates have none of that, because there's no draft and no picker. When a delegate names a provider and model but no account, the server can pick the account once when it creates the child thread, and the child keeps that account. If the selection rule proves itself there, new threads and scheduled tasks can use the same rule later. Two details from this thread that I think the rule needs:
#15137 (exposing usage over MCP) fits on top of this later, for agents that want to override the pick. I'd rather the default behavior not depend on every orchestrating agent reasoning about quotas in its prompt. Would a maintainer be open to this scope? It's opt-in, only for delegates, and reads the usage data Usage → Limits already collects. |
|
Note Written by A narrower cut than ranking or rotation. I'm asking for approval of the direction and scope before writing any code. Problem. When a thread stops on a usage limit and the user has another account with the same provider, there are two options today: wait for the reset (Resume at reset or Auto-resume limited threads), or switch the instance by hand, as the docs already suggest. With several subscriptions people switch by hand. That fails when nobody is watching: scheduled tasks, delegated tasks, overnight runs. Proposal. One setting next to Auto-resume limited threads, off by default. When a run fails with a classified Why the key must match: the switch is then lossless. The orchestrator's Out of scope: picking an account before a turn starts, ranking by limit snapshots, rotation, switching to another provider or harness, and any switch that would go through the context handoff. Questions:
@juliusmarminge, since you're carrying #14340: this is the follow-up I offered there. @AdEx-Partners-DE, this is the failure-triggered half of what you run in your fork. Happy to line up so there's one proposal instead of two. |
|
Note Written by +1 for the Soonest reset strategy @theportugueezer listed, with one addition that turned out to matter more than the ranking: skip accounts that already have work running. Why soonest reset: any headroom left when a window resets is lost, so the account that resets first is the cheapest capacity to use. Most headroom tends to pick a fresh account and lets an almost-expired window go to waste. Why idle first: if new threads only follow usage, they pile onto the account that's already running long tasks. That pushes it toward its limit, and the running work is what gets cut off. The rule I've been running locally on three Claude accounts:
It reads the Limits snapshot and the thread list the client already has, so it needs no new polling. Glad to open a PR in this shape if a maintainer approves the direction. |
|
The session and weekly windows miss one case that @etherious1804 rule, and the other selection rules here, should cover: Claude's extra usage spend cap. I run four Claude seats with claude-swap's auto-switch, which also switches on the 5-hour and weekly windows. I hit this a few weeks ago. One seat reached its $500 monthly extra-usage cap while its 5-hour window showed about 90%. Requests started failing before the window threshold fired with this error: "You've hit your individual spend limit · run /usage-credits to ask your admin for a higher limit · your session limit resets 3pm (Australia/Melbourne)" What I learned from it:
For the rule, I'd count only window headroom as headroom, never extra usage. That stops a "drain one account first" strategy from spending money without anyone noticing. It also judges a capped seat on its windows alone, which is how a capped seat actually behaves. The usage data claude-swap reads already shows the cap as dollars used against the limit, so if the Limits snapshot carries those figures, this needs no new polling. |
Uh oh!
There was an error while loading. Please reload this page.
Before submitting
Area
apps/web
Problem or use case
I run t3code with 7 separate Claude Max (x25) accounts. Today the account used for a new task is whichever one happens to be selected, not the one with the most headroom.
The failure mode is predictable: I start a long task on an account whose Opus/Fable quota is nearly exhausted, and the run dies mid-task on a rate/quota error. I then have to notice it, switch accounts manually, and restart, usually losing the in-flight work.
Picking manually does not really work either, because the only way to know an account's remaining quota is to open Claude Code and check usage on each account.
Proposed solution
Track per-account quota/usage state and use it to choose the account for a new task.
Concretely:
manual(today's behavior) andauto: most remaining quota.Model-aware selection matters: quota is tracked per model tier, so "lowest usage" should be evaluated against the model the task will actually use, not a global average.
Why this matters
Anyone running more than one account benefits mostly heavy users and small teams pooling subscriptions.
The outcome is that long tasks stop dying halfway through for a reason the tool already had enough information to avoid. It also removes the manual "switch, check, switch back" loop before every task, and spreads load across accounts instead of burning one down while six sit idle.
Smallest useful scope
A single account picker that runs at task start and selects the account with the most remaining quota for the target model, using whatever usage data the app has already observed.
No background polling, no rebalancing mid-task, no automatic failover-and-resume. If an account has never been used and has no cached usage data, treat it as full. That alone would solve my problem.
Alternatives considered
Risks or tradeoffs
Examples or references
Rate-limit headers from the API (remaining requests/tokens and reset timestamps) are the natural signal source. Conceptually similar to API-key rotation pools in gateway tools like LiteLLM, which route by remaining budget rather than round-robin.
Contribution
All reactions