Repository navigation
[Feature]: Quota-aware model routing and handoff at the T3 layer #26844
Closed
nidheeshdas
started this conversation in
Ideas
Replies: 1 comment 1 reply
|
Closing as a duplicate of #26838, which tracks the same request. Please follow along there. |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Problem
T3 Code already has most of the pieces to make small subscriptions feel much bigger, but it does not connect them.
It can read Claude's 5-hour and weekly windows, Codex's 5-hour and weekly windows, and OpenCode Go's rolling, weekly, and monthly allowances. It can switch a thread to another provider and build a real context handoff. It can resume a usage-limited thread when the reported reset arrives.
What it cannot do is decide that the current subscription is about to run out and continue the work on another subscription the user already pays for.
Today the behaviour is:
UsageLimitRecoveryWorker.ts). It does not continue on another account or provider.provider.switch,ProviderSessionTransitionPolicy.ts).This is not a request for a LiteLLM/OpenRouter-style proxy. A proxy switches HTTP requests. It cannot see T3's turn boundaries, worktree, checkpoints, approvals, or native provider session. It would switch mid-tool-call and leave the next model with a half-applied edit. The routing and handoff belong in T3's orchestration layer, because that is the only layer that knows what "continue this work" means.
Who this hurts
People on small plans.
A $20 Claude plan and a $20 ChatGPT plan are already a real monthly cost in many countries. Add a $10 OpenCode Go plan and a small prepaid API credit, and you have a stack that should be able to keep working all day. Instead:
This is especially painful because T3's Claude sessions currently appear to drain the 5-hour window faster than the Claude Code CLI (about 1.7x in #24649; fix proposed in #25597). Even after that is fixed, the structural problem remains: one quota is not the same as all quotas.
For people who cannot buy Max, multiple Claude accounts, or a pile of API credit, this is the difference between T3 being usable for a day of work and T3 being a toy that stops at the worst moment.
What a T3-level solution looks like
The goal: when the current subscription is exhausted or about to be, continue the thread on the best available subscription automatically, with a T3 handoff, and show the user what happened.
Not a hidden router. Not an extra model call by default. Not credential pooling. A policy inside Orchestrator V2 that uses the usage data T3 already collects and the switch/handoff machinery T3 already has.
Track 1 — Quota-aware continuation (MVP)
On a
usage_limitfailure, before arming reset recovery:ModelSelections, not one model).provider.switchand a server continuation message ("Continue where you left off").ContextHandoffServiceV2; it already creates the handoff when the provider instance changes.This is the smallest useful change and it works for Codex and OpenCode immediately. For Claude there is an extra wrinkle below.
Track 2 — Predictive guard (the part that actually helps Claude)
T3's own docs note that Claude Code can hold a turn until the 5-hour window reopens. A post-failure worker may therefore fire too late.
Add two earlier triggers:
usedPercentover the last few turns — not just the absolute percentage. If the last three turns each added 7% and the window is at 84%, switch now.rate_limit_eventsays 100% and the reset is not imminent, interrupt the turn and let the continuation policy take over. If the reset is a few minutes away, waiting is cheaper than a handoff.Keep the post-failure path as the safety net.
Track 3 — Candidate intelligence
The chain should not be a blind round-robin. Ordering:
Guardrails:
credentialFingerprint;Track 4 — Quota-aware delegation
The same problem exists one level up. An orchestrator thread can spawn child threads with
delegate_task, but it cannot see which account has room. #24412 adds a read-onlyprovider_usageMCP tool; that is the right direction. A quota-aware launch admission should then:#22281 explored this and was closed for missing prior maintainer approval, not because the problem was solved. It is worth re-opening as an approved, smaller track.
Track 5 — Handoff quality
T3's portable handoff is a budgeted selection, not an agent-written summary (docs). It includes recent user/assistant messages, commands, file changes, checkpoints, and references for omitted history, and the incoming agent can read the thread for more. That is a good base.
Improvements that matter for quota failover:
T3CODE_CONTEXT_HANDOFF_TOKEN_CAPguidance for coding threads (16k default is small; 32k–64k is available);Acceptance criteria
Non-goals
Implementation notes
The pieces are close to each other:
packages/shared/src/usageLimits.ts— add a pureselectQuotaCandidatewith tests; it already hasexhaustedUsageWindowandresolveNewThreadModelSelection.apps/server/src/orchestration-v2/UsageLimitRecoveryWorker.ts— extend the sweep, or add a sibling worker registered inruntimeLayer.ts.apps/server/src/orchestration-v2/ProviderSwitchService.ts— reuse the existing switch/handoff path.packages/contracts/src/settings.ts— add an ordered chain and thresholds; keepfallbackModelSelectionfor new threads.apps/web/src/components/settings/SettingsPanels.tsx— expose the chain and the enable/disable switch; reuse the existing Usage limits section.packages/shared/src/usageLimits.test.ts, a worker test, and a ProviderSwitch integration replay.This can be split cleanly: Track 3's pure candidate selector is a small, testable PR on its own. Track 1 is the server worker. Track 2 touches adapter events. Track 4 is contracts/MCP. Track 5 is docs and handoff content.
A plea to people with tokens to spare
I know maintainer review capacity is the bottleneck, and I know this is a feature request, not a bug report. I am filing it here because the problem is real and because the Ideas discussion alone has not turned into a policy.
If you have spare implementation tokens, a free afternoon, or a provider plan you can test against, please pick up one track. Even the pure candidate selector plus tests would unblock the rest. If you are a maintainer and the direction is acceptable, please say so in an Ideas discussion so contributors can work without guessing.
I can test on macOS against Claude Pro, ChatGPT Plus, OpenCode Go, and a prepaid Fireworks credit, and I can provide logs, repros, and verification for the Claude 5-hour hold case. I am not asking for free quota or a bypass; I am asking T3 to use the subscriptions I already pay for before telling me to come back in five hours.
Small subscriptions are not a lesser way to use T3. For a lot of us they are the only way.
All reactions