How TeamClaude decides which account serves a request, and what it does when that account runs out.
- Claude Code connects to the local proxy instead of
api.anthropic.com. - The proxy selects the active account and forwards requests with that account's credentials.
- OAuth tokens expiring within 5 minutes are automatically refreshed and persisted to config.
- Rate limit headers from the API (
anthropic-ratelimit-unified-*) track session (5h) and weekly (7d) quota utilization. - When usage reaches the threshold, the proxy switches to the best available account (see Choosing an account).
- On retryable 429 responses, the proxy uses the quota or throttle rules below. An upstream 429 with
x-should-retry: falseand no spent quota window goes straight to the client. - Transient network errors (connection reset, timeout) drop the connection so the client can retry.
- If all accounts are exhausted, returns 429 with the soonest reset time — or, with
holdSecondsset, holds the connection open and retries silently until an account recovers. - Client token refresh requests (
/v1/oauth/token) are relayed to upstream untouched — the proxy and client manage their own token lifecycles independently.
TeamClaude prefers to keep you on one account. It stays on the current one and only rotates when that account nears switchThreshold (default 0.98).
An account you have cordoned is never picked for new work, whatever its priority; a conversation already on it stays there.
When it does have to pick, ranking is: lowest priority number first, then, among accounts of equal priority, the one whose governing weekly bucket resets soonest. Spending the account closest to its refresh preserves the ones whose window resets further out. A model with its own weekly bucket (Fable, Sonnet) is ranked by that bucket rather than the shared one. To make the soonest reset a standing preference rather than a tiebreak, set "preferSoonestWeeklyReset": true. Then, on every request, traffic moves to the available account in the top priority tier with the soonest deadline (its governing weekly reset, or its end date when that comes first) — at least a minute sooner than the current one's — and rotation ranks that deadline ahead of expiry pressure. This is earliest-deadline-first: weekly quota that would expire unspent is spent first, then the next-soonest, and an account sidelined by its 5-hour window is reclaimed as soon as that window frees up. An account whose deadline is unknown (no weekly reading, and no end date within the week) never preempts. Hot-applies on config reload. Set an explicit order with teamclaude priority <name> <n>, or --first / --last. teamclaude login --api adds a key at priority 100 — a metered key is a last resort behind the subscriptions unless you say otherwise (API key).
Separately, and on by default, an account whose 5-hour window resets takes the traffic straight away when its deadline (its weekly reset, or its end date when that comes first) is sooner than the current account's, even though the current account is healthy (the log says session quota reset and weekly expires sooner — switching to it, or session quota reset and weekly expires sooner — its provider's traffic switches to it when the account belongs to another provider than the current account). In a fleet with Claude and Codex accounts, a poll (the TUI, GET /teamclaude/quota; only with expiry routing off, the default) weighs each reset against the account its own provider's traffic is on, and moves only that provider's traffic; a provider whose traffic is on no account it can be sent to is left to its next request's own pick. A request weighs a reset against the account the request starts from: for a provider with no account of its own yet, or one riding a shared API key, that is the current account, whichever provider it belongs to, and an API key's reset that a request brings along can move that request, and the current account, onto the key. While a manual switch holds, no reset of the chosen account's provider moves traffic, and another provider's reset is weighed as a poll weighs it; a request that brings one for a provider with no account of its own spends it without acting on it. Each such move costs the conversations on the old account their prompt cache, and with keep-warm running every idle account's window resets every five hours. Set "switchOnSessionReset": false to keep traffic on a working account. That does not hold back preferSoonestWeeklyReset above, a separate rule: with it on, the account with the soonest deadline takes traffic as soon as it can serve again, including when its 5-hour window resets. The reset account still rejoins rotation and wins it on its sooner deadline when rotation next has to pick.
Some accounts stop being usable at a time no usage response reports: a subscription you cancelled that runs to the end of its paid month, a trial. Whatever weekly quota such an account holds at that moment is lost, the same way quota is lost at a weekly reset. Tell the proxy when:
teamclaude ends me@example.com 2026-12-01 # start of that day, local time
teamclaude ends me@example.com 2026-12-01T09:00:00Z # an exact instant
teamclaude ends me@example.com --clearThis writes "endsAt" on the account's entry (an ISO 8601 string or epoch milliseconds; ends also takes epoch milliseconds) and reloads a running server. From then on the account's deadline is the earlier of its governing weekly reset and its end time, and everything that ranks accounts by how soon their quota expires reads the deadline in place of the weekly reset:
- the equal-priority tiebreak above (soonest first),
preferSoonestWeeklyReset, which moves traffic to the account with the soonest deadline,- the session-reset switch, which moves to an account whose 5-hour window came back when its deadline is sooner than the current account's (the log says
it ends soonerin place ofweekly expires soonerwhen the end time decided it), - expiry pressure and the adaptive
"scoring": "pressure"placement, where the time left to spend the headroom is the time to the deadline, so the account's pressure rises as its end approaches.
An account with no weekly reading yet has its end time as its deadline, and a fresh window on it is priced over the time left rather than a full week.
It only ranks. priority still comes first, so an ending account in a lower tier is not pulled ahead of a preferred one: give it the same or a lower priority number if you want it drained. Thresholds, caps, cordons, pins and routes are untouched, and no account becomes available or unavailable because of an end time. Once the time has passed it has no effect at all: the account is not disabled, and what the ended subscription does is reported by upstream and handled as it is for any account (billing refusals, a plan that left the OAuth profile). teamclaude status shows the date on the account (Ends 2026-12-01 (in 6 days)), the TUI row carries an ends 6d tag, and each account in status --json and GET /teamclaude/status carries endsAt as epoch milliseconds (null when unset).
Without preferSoonestWeeklyReset or expiryRouting the deadline is consulted only when selection has to pick, as the weekly reset is: an account being spent is left until it reaches switchThreshold.
Reacting the wrong way to either one makes things worse, so they are handled separately.
-
An upstream
429withx-should-retry: falseis an explicit refusal of this request. TeamClaude returns its original status, body, and allowed response headers, even ifretry-afteris present. A 429 that also marks a quota window spent (5h,7dor7d_oistatusrejected, or a spent Codex window) is still a quota rejection and switches accounts as below. It does not retry, switch accounts, or pause the account: unrelated requests can still use it. The client decides what to do with the refusal. -
A quota rejection (a spent 5h or weekly bucket,
unified-…-status: rejected) switches accounts immediately. -
A rate-limit 429 (the per-minute throttle) does not switch. It pauses the account so concurrent requests wait instead of flooding, retries the same account (absorbing short
retry-afters inline, default ≤ 60s viaTEAMCLAUDE_RATE_LIMIT_ABSORB_MAX_SECONDS), and only surfaces a 429 to the client for longer waits. -
A request-scoped 429 — no
retry-afterand noanthropic-ratelimit-*headers at all, which is how upstream refuses a model id it will not serve — is about the request, not the account. Nothing is paused. The request gets one hop to an idle sibling and, once in total, one retry after 2s (TEAMCLAUDE_HEADERLESS_429_RETRY_DELAY_MS) — after the hop it stays on the account the hop landed on, because a limit that followed the request across two accounts is scoped to neither, so a third would prove nothing and pay a cold prompt cache. If that account is removed during the wait, there is no retry, and its 429 goes back to the client. With no sibling to hop to, the same single retry is all it gets. Setting the delay to0turns the retry off. If the answer is still the same, the 429 goes back to the client without a fabricatedretry-after, and the client's own backoff applies.Not every headerless 429 is a refusal, which is why the retry is there at all. Observed on one fleet over 32 minutes: Fable requests drew one about every 8 minutes — none on any other model, Codex included — consecutive refusals arrived 0.6-0.8s apart, they started from four different accounts, and the client's own retry usually succeeded. Those are transients the retry now absorbs. Left to the client, they surfaced as
Waiting for API response · will retry in 2m 38swith nothing written to the session transcript to explain the pause. The 2s is chosen against those numbers rather than measured from them — above the gap the hop already failed across, far below the client's own backoff — which is why it is tunable. -
A failure reported inside a 200 is the Responses API's spelling of the same thing: the stream opens with a 200, and the refusal (
server_is_overloaded— "Selected model is at capacity") arrives as anerrororresponse.failedevent in the body before any output. On a Codex pool this is how every refusal arrives, so a status-keyed failover never saw one. TeamClaude reads the head of every streaming reply before its headers go out: while only lifecycle events (response.created,response.queued,response.in_progress) have been seen it keeps reading, and the first other event decides. Aresponse.failedorerrorwhose code names the provider rather than the request —server_is_overloaded,server_error,rate_limit_exceeded, or Anthropic'soverloaded_error— takes one hop to a sibling, on the same budget and for the same reason as the 5xx hop below. Anything else (a delta,invalid_prompt, Anthropic'smessage_start) releases the stream untouched, with the bytes already read replayed ahead of the rest so the client sees an unbroken body. The hold is bounded by 256 KiB (TEAMCLAUDE_STREAM_PEEK_BUDGET_BYTES; the lifecycle envelopes echo the whole request back) and by 10s (TEAMCLAUDE_STREAM_PEEK_HOLD_MS); on either bound the stream is released as-is, so a slow first token is never held hostage. A failure that follows real output is a stream that broke after committing, and committed output has no retry behind it.
Rotating on a rate-limit 429 would just move the burst to the next account and throw away the first account's prompt cache.
An HTTP 400 with Anthropic's invalid_request_error message beginning
Your credit balance is too low to access the Anthropic API., or an HTTP
400 or 402 with a structured billing_error, excludes that account from
automatic rotation for five minutes. The request fails over immediately,
including to subscription usage credits when the existing fallback policy
allows them. Other validation errors pass through unchanged. A request
pinned to one account is not moved; one pinned to a
list of API-key accounts moves to the next one
listed.
Status reports the billing refusal separately from quota exhaustion and
recommends checking billing or purchasing credits. If every eligible account
is in this cooldown, the proxy returns 402 billing_error. The next request
after the cooldown retries the account. Re-enabling the account or replacing
its API key also clears the cooldown.
A 403 whose structured error code is error.details.error_code: oauth_not_allowed_for_organization means the selected account's organization does not permit OAuth authentication. TeamClaude fails the current request over to another account and keeps the denied account out of automatic rotation for a cooldown shared by later requests. The cooldown expires on its own, so an organization policy change can recover without restarting the proxy, and it lengthens while the denials keep coming with no served request in between: 5 min, 15 min, then 1 h for every one after that. A 403 to a request sent before the last denial was recorded was already in flight then and does not count as another. None of this is persisted. Other 403 responses still fail over for that request but do not quarantine the account.
The denial stays on the account past its cooldown, until it delivers a whole completion (/v1/messages) for a request sent after the last denial. A redirect, a side endpoint such as count_tokens, a body that breaks off, or an answer to a request sent before the denial does not clear it. Until then teamclaude status shows a Denied line with upstream's message, how many came in a row and when the first one did, the TUI status column reads denied where it would read active, the dashboard card carries an OAuth denied badge and the message, and the status JSON has entitlementDenial (detail, since, count).
If every configured account returns that exact denial, TeamClaude's terminal 502 says that no account served the request, names the denied accounts and error code, and recommends waiting for automatic re-admission or pinning a different eligible account. It does not recommend teamclaude login, which remains the diagnostic for a generic credential refusal.
An explicit TC_ACCT pin continues to target exactly the requested account and never fails over, even while that account is excluded from automatic rotation.
Each ChatGPT plan serves its own set of Codex models. A free plan, or a paid plan that lapsed to free, refuses the larger ones with a JSON 400: "The '' model is not supported when using Codex with a ChatGPT account." TeamClaude reads this from error.message or detail, and acts only when the message is that whole sentence and names the request's own model, exactly as sent. On a Codex account, this 400 keeps the account out of rotation for that model only, and the request fails over at once. The account continues to serve the models its plan has. The cooldown is 5 min, then 15 min, then 1 h for each later denial. A 400 to a request that was sent before the last denial does not count again. None of this is persisted.
TeamClaude does not decide from the plan name which models an account serves. OpenAI changes that list, and the list also depends on the client version. The 400 is the only reliable signal.
A completed response for the model, to a request sent after the last denial, clears that model's entry. A change in the account's reported plan type (for example free to prolite) clears all of the account's entries, so a renewed plan serves at once. Until then, teamclaude status shows a Models line, and the status JSON has modelDenials (model, until, detail, since, count).
If no account that can take the request serves the model, the client gets upstream's 400, not a 429 or a hold, because a quota reset does not change a plan. A TC_ACCT pin to such an account gets the same 400. If one account refuses the model and another is only out of quota, the request waits for quota as usual.
A Claude plan that does not include a model family refuses it with a JSON 429 (also accepted as 400, 402 or 403) and error.details.error_code: credits_required. To count as a model refusal, the body must carry that code and a message saying the credits are "required for this model". Nothing else counts: not the same code on a refusal for a request option such as fast mode or long context, not a model named in error.details.model on its own, and not the sentence without the code. Such a refusal goes back to the client that sent the request and holds nothing; a 403 of that kind takes the ordinary 403 path. TeamClaude keeps the account out of rotation for that family only, including when the model is an advisor. If no model is named, the hold applies to the request model. For a model outside the known families, it applies to the exact model ID. The request goes to another account at once, unless the 429 also reports a rejected 5-hour or weekly window (the shared weekly or the family's own), which takes the quota path instead, whichever kind of credits refusal its body carries.
The hold is 24 h when the plan does not include the family (exhausted_included_allowance: false), and 1 h when the included allowance is spent (exhausted_included_allowance: true). After the hold, the next request for the family re-checks the account; if it is refused again, that request fails over too. A completion clears the entry only if it comes from a request sent after the hold was armed. A change of plan or tier metadata, or the return of a lost subscription, also clears it. The entry is kept in the state file, so it survives a restart. Until it clears, teamclaude status shows a Credits line (for example "Fable not in plan (usage credits required; re-check in 23h)"), the Models line marks the family ⊘ needs credits, the TUI marks the family bar ⊘F (or adds a ⊘ Fable tag), and the status JSON has familyRefusals (family, model, reason, detail, until, since, count).
If all candidates are held and this request got a refusal, the client gets that refusal (status, headers and body). If all candidates are already held, TeamClaude sends the request once, to the account with the oldest hold that can otherwise serve it. The client gets the new answer, not a prior refusal. A TC_ACCT pin can still reach its chosen account despite a credits hold.
Some refusals are about the account rather than the request: error.details.error_code is verification_required (the owner has to verify their identity), account_on_hold, organization_on_hold, organization_disabled, restricted_regime_endpoint or ip_not_in_allowed_range. Older answers say the same with a 400 and no code: "This organization has been disabled." or "Identity verification is required…". On an OAuth account, any of these in a JSON 400 or a 403 puts the account in error with upstream's message (see Why an account is in error), and the request fails over. Every other 400 goes to the client unchanged, except a Codex model that the plan does not serve. If every account was refused, the terminal 502 quotes upstream's message for each; later requests name the account as refused by upstream and point to teamclaude status.
A 403 with error.details.error_code: oauth_scope_insufficient is about the token, not the account. A claude setup-token token carries user:inference only and cannot reach endpoints that require user:profile. An account signed in with teamclaude login --long-lived holds such a token. Known client control-plane calls bypass rotation from the start, unless proxy.controlPlane is "pool". For other endpoints, and for those calls in that mode, an unpinned GET that draws a scope denial goes out once more on the client's own bearer, over the same upstream proxy, sx route and admission queue as any forwarded request, and rotation stays where it was. Any other method, which includes every completion, a pinned request, and a client with no bearer of its own get the normal handling.
A quota rejection (a 429 carrying ...unified-*-status: rejected) is durable
exhaustion and rotates, as it always has. A plain rate-limit 429 does not
rotate as a policy — moving a shared burst to the next account just throttles
that one too and discards the first account's prompt cache.
That reasoning holds under load. It does not hold when a sibling is sitting idle, which is the common shape for a small fleet of personal subscriptions: one account throttled, another at 9% weekly, and the whole proxy stalling for 60s at a time.
So a rate-limit 429 takes one failover hop, onto an account that is not
already tried and not inside its own 429 pause. The same single hop applies to
an upstream 5xx (529 Overloaded above all), which is the provider
declining to serve rather than anything about the account.
One hop, not a walk of the fleet, and the reason is worth knowing: if the
second account is rate-limited too, the limit is almost certainly scoped to the
egress IP rather than to either account — every account leaves from the same
address. Continuing to rotate would prove nothing and pay a cold cache for each
attempt. After the hop the existing behaviour takes over: the sx.org fresh-IP
retry if sx.mode is 429, otherwise the inline wait, otherwise a 429 to the
client with its retry-after. An IP-scoped limit is logged as such, since that
is what an operator chasing a fleet-wide throttle is looking for.
Since Claude Sonnet 5.5, a thinking block is bound to the organization whose account produced it (preserved thinking, "Thinking blocks stay with the account that produced them"). When a later request in the same conversation goes out on an account of a different organization, the API drops those earlier Sonnet 5.5 thinking blocks before the model sees them. The request succeeds and the answer comes back; the model simply answers that turn without the reasoning it had built up, and rebuilds it from the visible history. With the thinking-binding-controls-2026-08-01 beta header the response lists each dropped block in input_transformations with the reason organization_binding_mismatch. Blocks from other models are not organization-bound (a model switch has its own, separate rules on that page).
What that means for a pool:
- Accounts of one organization (seats on a Team or Enterprise plan) are unaffected: the blocks stay readable on every account the conversation lands on.
- Accounts of different organizations — the usual shape for a pool of personal Max subscriptions, where each login is its own org — pay the drop once per switch of a Sonnet 5.5 conversation: the threshold rotation, the failover hop, a re-routed pin, or a
TC_ACCTchange. It is the same shape as the cold prompt cache a switch already costs, and it costs nothing on the turns that stay put.
TeamClaude does not strip or rewrite thinking blocks, so nothing is lost for good: the blocks stay in the client's history, and a conversation that moves back to its original organization reads them again. Which organization each account belongs to is on its row in teamclaude status and in the dashboard. Nothing here needs configuring; the levers that keep a conversation on one account — switchThreshold, distributeSessions, a route or a pin — are the ones that keep its reasoning too.
When you run many agents at once and the active account runs out, every in-flight request fails over to the next account at the same instant — a thundering herd that can spend a big chunk of the fresh account's quota (large contexts) and instantly throttle it, cascading down the fleet (#84).
To prevent this, requests onto a just-switched-to account are paced: concurrency starts at 1 and the cap ramps up step by step, then lifts once the ramp window (windowMs, 30 seconds by default) has passed. The first request or two reveal whether the new account is also near-exhausted before the whole herd commits to it, so a cascade is broken up hop by hop. The gate is fail-open: a request waits at most the ramp window, except on an account in a rate-limit pause, where it first waits out the pause and the window starts when the pause ends. A client that disconnects while waiting just drops out, and the slot is held only until response headers arrive, so streaming replies don't tie up concurrency. A 429 that pauses the account (see the two kinds of 429) does so for at most TEAMCLAUDE_RATE_LIMIT_ABSORB_MAX_SECONDS (60 by default), and a further one extends the pause and restarts the ramp.
On by default. Tune or disable via stormRamp in the config:
"stormRamp": { "enabled": true, "startConc": 1, "stepConc": 1, "stepMs": 250, "windowMs": 30000 }startConc— concurrent requests allowed the instant a switch happens (default 1).stepConc/stepMs— the cap grows bystepConceverystepMs(default +1 every 250ms ≈ 4 req/s).windowMs— after this long, pacing stops entirely (default 30s).enabled: false— turn storm control off (send the full burst immediately, pre-#84 behavior).
Each number has to be a finite number above 0, written without quotes, and pollMs (how often a waiting query re-checks the cap, default 50) a whole number of milliseconds from 5 to 536870911. A value that is not — "1", 0, a negative number, a field name the ramp does not know — is ignored with one line in the log, and that field keeps its default. enabled takes true or false; any other value is read for its truth, so 0, null and "" turn storm control off, and is named in the log. The block is read at startup; a reload does not apply a change to it.
The same gate handles rate-limit 429s: TeamClaude pauses the account for the retry-after window, at most TEAMCLAUDE_RATE_LIMIT_ABSORB_MAX_SECONDS (60 by default), so new queries wait instead of piling on, then releases the held queries through a fresh ramp (staggered, not all at once).
The per-model weekly cap (e.g. Fable) is tracked separately, so an account whose Fable quota is spent is skipped only for Fable requests and still serves Opus/Sonnet. Eligibility for a family model takes the higher of that family's bucket and the shared weekly one, because family spend meters twice, once in the family bucket and once in the shared one. An account already past its shared weekly cap is therefore unavailable for family traffic too, rather than continuing to serve it and pushing the shared bucket further past the cap. The reverse still holds: a spent family bucket bars only that family. One consequence worth knowing: on the weekly buckets the family gate is the stricter of the two, so an account whose weekly quota lets it serve Fable can also serve Opus. That is a statement about quota only, since a routes pin or a blocklist can still make an account ineligible for one model and not the other. Requests are routed by their model, read exactly from the request body in both base-URL and MITM modes. teamclaude status shows this per account (a Models line) and any families it detects appear as auto routes.
How large the second charge is has been measured once, on one pool of Claude subscriptions over eight days (#662). Per cache token, a response served from the Fable bucket moved the shared weekly 2.9 to 12.7 times as far as one served from the shared bucket (median 5.0 across the accounts), and it moved the Fable window further still. Traffic on the shared bucket did not move the Fable window. So a Fable window that shows room can still drain the shared weekly several times faster than Opus does. That is one pool, with cache tokens only (input and output are not counted per bucket), so read it as an order of magnitude and not as a rate. The pressure score for a Fable request is still taken from the Fable bucket alone; the shared weekly bounds it as a ceiling, as above.
Advisor requests (Claude Code's /advisor) carry a second model nested in the tools array. Routing sees it too, so the request lands on an account eligible for both the main model and the advisor, falling back to main-model-only routing when no account can serve both.
Claude Code declares the advisor tool on every request once an advisor model is configured, whether or not the advisor is ever called. So when only some accounts can serve the advisor's model — a route lists one account for claude-fable-*, or the others have spent their Fable bucket — all of that client's traffic is confined to them and the rest of the fleet idles. TeamClaude says so, at most once a minute:
[TeamClaude] Advisor model "claude-fable-5-1" narrows selection to 1 of 4 accounts — set advisorEligibility to "prefer" to route by request model instead
The counts are the accounts that can serve the request right now, and how many of those can also serve its advisor. GET /teamclaude/status carries the same reading as advisorNarrowing ({ model, eligible, of, at }, or null when the last advisor request was not narrowed), beside the mode in advisorEligibility.
advisorEligibility chooses what happens then:
"strict"(the default) keeps the request on the accounts that can serve both models. The advisor always has somewhere to run; the cost is the narrowing above."prefer"routes a narrowed request by its main model only, as though it declared no advisor: every account that can serve the main model is a candidate, under the ordinary rotation, session distribution included. The advisor call is then made by whichever account serves the request, which may be one your routes do not list for the advisor's model, or one whose bucket for it is spent — upstream fails that advisor call and Claude Code may stop using the advisor for the session. A route pin on the advisor's model is set aside with it. Where every candidate can serve the advisor, nothing changes, and the advisor model still takes part in selection.
In both modes, no account able to serve the advisor at all means main-model-only routing, as before.
An account's maxUsage cap on the advisor's family is read in both modes: while another account can serve the request, selection and a failover hop stay off an account whose cap bars that family, since the advisor call would cross it. When no other account can serve the request, the mode decides. Under "strict" the cap is a cap: the request is not sent to that account, a TC_ACCT or session pin to it gets the exhausted answer, and a fleet with nowhere else to send the request answers that no account can serve it. Under "prefer" the request is routed by its main model as usual and a pin stays where it is pinned, so a cap on the advisor's family never refuses a request by itself, and the advisor call can cross it.
Unwanted models can be rejected outright with blockedModels instead of being forwarded — a model no account can serve otherwise gets rate-limited upstream and hangs the pipeline.
Per-model quota is respected automatically, so most setups need nothing here. To go further you can pin model patterns to an exclusive set of accounts with a routes table. Each route matches the request's model id against shell-style globs (* is the only wildcard) and, on the first matching route, restricts the request to the listed accounts:
"routes": [
{ "name": "fable", "match": ["*fable*"], "accounts": ["personal-max"], "color": "magenta" },
{ "name": "bulk", "match": ["*opus*", "*sonnet*"], "accounts": ["corp-1", "corp-2"], "color": "blue" }
]match— one or more model globs; the first route whose globs match wins.accounts— account names (or indices) that may serve matching models. Exclusive: only these are used (and they 429/rotate among themselves when spent). Omit to route to all accounts — e.g. to only set abucketoverride.bucket— optional: force which quota bucket governs eligibility (unified7dFable,unified7dSonnet,unified7d), for the rare case the family can't be inferred from the model id.color— optional:red/green/yellow/blue/magenta/cyan, tinting this route's inline marker in the TUI. Display only.
Manage routes from the shell (changes apply to a running server immediately):
teamclaude route list
teamclaude route add fable --match '*fable*' --accounts personal-max --color magenta
teamclaude route add bulk --match '*opus*,*sonnet*' --accounts corp-1,corp-2
teamclaude route rm fable…or interactively in the TUI: open settings (g) → Manage routing, then a add / e edit / d delete (the editor prompts for a marker color too).
Inline markers (TUI). Instead of a separate list, each route surfaces on the account rows as a colored ►: next to the F7/S7 bar for a Fable/Sonnet route, or at the start of the row for a general route (one fixed column per route so its position is stable). The marker is bold on the account a route is pinned to, dim when that account is currently ineligible. teamclaude status still prints the routes as a list, colored and annotated with any pin.
Manual per-route switching (TUI). Press s to switch accounts, then ←/→ (or Tab) to choose what you're switching: the global default account, or a specific route. Pick an account with ↑/↓ and Enter to pin that route to it; Enter again on the current pin clears it. Pins are a runtime preference — not saved to config — and routing falls back to normal best-available selection whenever the pinned account is throttled or over quota, so a pin never stalls requests.
TeamClaude always tracks running Claude Code traffic by the x-claude-code-session-id header, narrowed to the conversation within it (see below) — the TUI header and teamclaude status show how many are active (a request in flight right now, or seen in the last ~2 min) and known (seen in the last hour; a conversation is forgotten after an hour idle, the maximum prompt-cache extension window). A long streaming request keeps its conversation active and non-expirable for its whole duration, so a multi-minute completion still counts as load. A client session that fans out to subagents is several conversations and counts as several, which is what its load on the fleet actually is. This is passive: it observes, it doesn't change routing.
Default rotation is purely quota-driven, so many parallel conversations all pile onto the current account while equal-priority siblings sit idle — one account queues behind its upstream concurrency ceiling while others do nothing (#109). Enable distributeSessions to fix that:
"distributeSessions": trueWhen on, TeamClaude routes each new conversation to the least-loaded eligible account (fewest active conversations, then fewest in-flight) and pins it there for the model family's weekly quota bucket, so it keeps hitting the same account for that family and preserves its prompt cache — while other conversations spread across accounts instead of funnelling onto one. Account priority still wins (a higher-priority account is never skipped to balance load), and a conversation whose account becomes exhausted re-routes automatically. Off by default; single-session use is unaffected either way.
What is pinned is a conversation, and one client session may hold many. Claude Code sends the same session id for its own turns and for every subagent it launches, so a fan-out arrives as N concurrent requests wearing one tag; pinning on that tag alone held all N on one account, queueing behind its concurrency ceiling while equal-priority siblings sat idle — #109 again, re-entered through the tag rather than through rotation. Nothing was gained for it, because a subagent given a context of its own shares no prompt cache with its siblings or with its parent. So a request is filed under its session id narrowed by a digest of the conversation's opening — the identity of the cached prefix — and the agents of one session are placed like any other conversations. Both edges of that key are safe by construction: a conversation cannot be separated from its own cache, because a first message that changed is a cached prefix that changed with it; and two conversations that open identically simply share an account, each keeping its own cache.
The exception proves the rule rather than breaking it. A subagent forked from its parent's context is sent with the parent's messages ahead of its own task, so its opening is the parent's opening: it keys the same and stays on the account already holding the cache it inherited. That is the right answer for those agents — they genuinely share a prefix, so co-locating them is what preserves it — but it does mean a fan-out of forks concentrates where a fan-out of fresh subagents spreads.
A message-thread continue is filed under the conversation it continues. Once Claude Code runs a message thread, every turn after the first sends only its delta, so the body's first message is no longer the conversation's opening. The proxy remembers which conversation produced each threaded reply, and a continue naming that reply is placed with it: on the same pin, and so on the account that holds the thread, which is the only one that can continue it (any other answers 404 thread_not_found, and the client then resends the whole conversation). A continue the proxy cannot trace, because persistence was off at restart or the conversation was forgotten, names no conversation and pins by session alone.
What changes for a fleet upgrading to this. Three things are counted or named differently than they were when the unit was the client session:
- Load is per conversation. Every session-aware count — the active and known totals, the per-account
active N sessfigure, the load the even and adaptive pickers compare — is a count of conversations. One client session running a parent and four subagents counts as five, once per conversation. A one-shot helper request (a title or a summary the client asks for on its own) opens with its own first message, so each one is a conversation too and stays in the active count for the two-minute active window after it completes. Expect the numbers to read higher than the number of terminals you have open. - A learned concurrency cap re-learns. The adaptive concurrency learner persists its cap in the state file, and a cap written by an older version was measured in sessions. Read against conversation counts it is too low, so an account looks more congested than it is until the learner has seen live traffic in the new unit and crept back up. Nothing needs resetting by hand.
sessions.items[].idis the composite key. In/teamclaude/status(withproxy.sessionDetailon) a row'sidis nowsession/digest— the session id, a/, and the conversation digest — and no longer the bare session id. The two halves are also given as separate fields,sessionandconversation, so a consumer that grouped rows byidshould group bysessioninstead. A request whose body names no conversation (a Codex Responses request, for one) keeps the bare session id as itsidand hasconversation: null.
More precisely, a conversation holds one pin per weekly quota bucket, not one overall, because eligibility is decided per bucket: an account whose Fable weekly is spent still serves Opus. So a Fable request that has to divert elsewhere leaves the conversation's Opus pin where it is, and each family with its own bucket keeps its own cache affinity. The consequence is that a conversation using two families commonly sits on two accounts, and the per-account counts in teamclaude status can therefore add up to more than the number of active conversations.
Families that share a bucket share a pin, including when only one of them is separately metered. Upstream can report a learned weekly bucket scoped to a family the static table has no entry for; routing then meters that family on its own window (see Expiry-pressure routing) while affinity still keys on the shared bucket the family falls under. Such a family has its own quota clock and not its own pin, so anything that moves the pin moves both — a known limitation of pinning by bucket rather than by governing window, and the reason the cost bound below is stated per pin rather than per family.
To retain automatic affinity for your own pooled accounts across proxy restarts:
"distributeSessions": "adaptive",
"persistSessionAffinity": truepersistSessionAffinity is off by default; only literal true enables it.
The setting is read once at startup, so changing it requires a restart.
Reload does not import an older snapshot. When off, startup ignores saved
affinity and the next ordinary state save removes that section.
The existing atomic, owner-only (0600) state file holds a versioned affinity
section: opaque conversation keys, optional client-session/conversation
ownership, last-use times, bucket pins naming stable account entry IDs and
providers, and up to the newest 32 threaded-message IDs per conversation. At
most 10,000 conversations survive. Beside them it holds the last ten minutes of
routed requests as a count per account entry and minute. No prompts,
credentials, client/project labels, usage, open requests or other counters enter
this section. Operator switch --session pins remain runtime-only.
With expiryRouting.preempt on, each pin also keeps the reading taken on its
own account (the reset of every weekly window that account presented), so a
window that rolled while the conversation was quiet still moves it once the
restarted daemon knows the new reset, as an uninterrupted daemon does. A
restored reading moves a pin only on a roll an uninterrupted daemon also
detects. With distributeSessions: "load", the recent request counts that break
ties in the re-rank after that roll are saved by the minute and restored, so a
restarted daemon decides that move as an uninterrupted daemon would, except
where two accounts' recent counts differ by no more than the restored requests
of the oldest saved minute: there the up-to-a-minute overcount can move a
restored conversation that an uninterrupted daemon keeps. A
restored request is counted as if sent at the end of its minute, for ten
minutes from there, so up to a minute longer than the uninterrupted daemon
counts it. A saved minute later than the clock at startup, as when the clock
was stepped back, is counted from the startup time, for ten minutes. An
uninterrupted daemon counts those requests longer, by up to the step plus a
minute, and in that interval a restarted daemon can decide a request
differently, including moving a conversation that an uninterrupted daemon
keeps. Above MAX_ROUTED (50,000) requests in ten minutes, the restored
ring can evict in a different order than the live one, by up to one minute's
requests per account. A start with preemption
off drops the readings. A roll held for an account a preemption pushed the
conversation off is not kept, so after a restart such a conversation can stay
on its pin where an uninterrupted daemon moves it, and, more rarely, move once
where an uninterrupted daemon would have kept it. Nor is a reading on an
account the conversation has not yet followed kept: a return there after a
restart reads that account afresh.
The same one-hour sliding idle lifetime applies across restarts. Restoring never refreshes it: a conversation active for days can survive, while one idle for more than an hour is forgotten. A saved time later than the clock at startup (the clock was stepped back, or the file is damaged) is read as the startup time, so such a record still expires an hour later.
A pin names its account by config entry ID and provider, so reordering or renaming accounts between starts changes a decision only where two accounts tie exactly on every ranking key and config order breaks the tie. A pin whose account was removed, or whose entry now belongs to another provider, is dropped. A pin on a disabled account is saved and restored like any other and stays unused until the account is enabled; it is replaced if its conversation is routed elsewhere in the meantime. If two running accounts ever carry the same entry ID, neither is saved or restored as a pin target. Config loading already gives the later of two rows sharing an ID a new one, so a row copied by hand above its original keeps the ID and inherits the original's saved pins; the cost is one cache miss per affected conversation. Saved request counts name accounts the same way, so they return to the account that carried them, and a removed account's are dropped. Current model, provider, route, quota and hard-pin checks still govern every request. Thread ownership can survive a dropped pin, but does not make another account capable of continuing the upstream thread.
A conversation with a request in flight at save time is saved as seen at that moment. Its in-flight count is not stored and the stream is not resumed.
State is saved on the existing minute tick and on graceful shutdown, including once more after an enabled drain completes. Abrupt termination can lose routing updates since the last completed save. A pin then restores with the reading taken at that save, so if its account rolled and the conversation moved off it and back inside that interval, the restarted daemon can move it again where the uninterrupted one kept it. Requests routed after that save are not counted. Missing, corrupt or unrecognized affinity snapshots start empty. A snapshot an older TeamClaude wrote restores its pins without readings and with no request counts, a malformed reading is dropped and its pin kept, and a malformed request count is dropped alone. This retains routing knowledge; it cannot restore an expired upstream cache or resume an interrupted stream.
Even distribution treats every account as interchangeable, which is wrong once a fleet is mixed. It sends a Pro account the same share as a Max 20x, so the small one hits its weekly wall days before the big one is half spent — and spreading evenly fragments the weekly windows: five accounts each left at 60% at reset is five windows' worth of credit thrown away, where four spent accounts and one untouched is the same work with the headroom kept where it can still be used.
"distributeSessions": "adaptive"Adaptive mode does the opposite of even: it concentrates new conversations on the account with the least remaining weekly credit, to finish that window off — while tapering its share away as it nears the switch threshold, so the account is spent down to the wall and never into it, and backing off when it is congested, so concentrating never costs response time. A conversation's pin, priority ordering, and the drain-on-disable behaviour are all unchanged.
Plan size comes from authoritative account metadata; only dynamic behavior is learned from traffic:
| Input | Source | Used for |
|---|---|---|
| Plan tier | OAuth profile organization and seat tier, using the same persisted 1x/5x/20x mapping as quota summary. | Making “least remaining” comparable across differently sized subscriptions without estimating the subscription from traffic. |
| Tolerated concurrency | AIMD: retreat below the load that upstream throttled, creep back up while running at the cap without trouble. Load is measured as active conversations plus requests in flight, the same figure the score compares against the cap. | The response-speed term: an account's share of new conversations decays as its load approaches the learned cap, so concentrating for quota reasons stops before the next one would just queue. It shapes placement only — it does not bound admission, and a request already on an account is never held back by it. |
The taper's width is adaptive too, rather than a fixed percentage: it is how much of the window the account would spend in the next 30 minutes at its own observed burn rate, so a fast-burning account is given a wide margin and an idle one may run much closer to the threshold.
The threshold it tapers toward is your switchThreshold, including the per-bucket form — set { "default": 0.98, "unified7d": 0.85 } and the weekly taper reaches zero at 85%, not 98%. An account's own accounts[].switchThreshold (per-account thresholds) overrides that wall for just that account, so two accounts on the same fleet setting can still taper toward different walls.
Quota response headers supply utilization and reset time. Burn rate is learned from fresh readings of each individual quota window; a response that refreshes only shared weekly quota does not rebaseline a cached family window. The burn-rate and concurrency learners run, and persist to the state file, in every mode — they have no effect on routing unless distributeSessions is "adaptive", but what they have already observed is in hand the moment it is.
Reading the result. In this mode teamclaude status adds an Adaptive line per account, and the header reads adapting:
> account-a (Max 20x) (oauth, prio 0) active 3 sess
Weekly [███████████░░░░░░░] 62% reset 3d8h
Adaptive next · weight 36% of opus+ · 3 sess / 3 inflight · head 36.0% of 98% · plan 20x · conc 6.0
The sess in both lines is the display's short label and counts conversations, not client sessions: active 3 sess is three active conversations pinned to that account, which may all belong to one Claude Code session and its subagents. The TUI's session figures count the same thing.
next names the account the deterministic picker would choose for the next new conversation. weight is that account's score normalized across the competing tier; it explains how strongly the inputs favor an account, but is not a routing probability. plan is the subscription multiplier read from the OAuth profile, not inferred from traffic. An unknown future tier is shown as plan unknown, and its competing tier falls back to plain utilization fractions rather than guessing. weight n/a (all reserved) means every account in the tier is inside its reserve, so the even fallback decides the next target. Under "scoring": "pressure" the head, plan and conc fields give way to P 3.85e-6, the pressure per second the score was taken from, and weight n/a (all zero) means every account scored 0.
A Codex account is scored only against other Codex accounts, on its own quota window, so its row names that window in place of the Claude bucket: weight 95% of codex weekly, not of opus+. Its plan is the ChatGPT plan upstream reported (plan pro), with no numeric weight; plan unknown appears only until a plan has been reported. The displayed weight and routing are the same as before this label; only the words changed.
Turning it off drains, it doesn't cut. The setting is applied live on config reload, and switching it off would otherwise move every distributed conversation to the current account on its next request — each one throwing away the prompt cache it built on its old account, and all of them arriving at one account at once. Instead, the conversations running at that moment keep their accounts, and only new ones go back to plain quota-driven rotation. Affinity therefore winds down as those conversations finish rather than snapping, and a draining conversation whose account becomes ineligible simply rejoins normal rotation. While this is happening teamclaude status reads draining N (the TUI header shows drain N) instead of single-account, and it clears itself once the last of them is done or idles out.
With expiryRouting.preempt on, a governing-window rollover also ends the drain for the conversation whose account rolled, and it rejoins normal rotation there and then. The drain trades expiring quota for a warm prompt cache, and that trade is priced on the window the account had when the drain started; once that window has gained a full week the account is the one the fleet should be spending last. Nothing else bounds it — a conversation making requests never idles out — so without this a long-lived one rides a rolled-over account for as long as it keeps talking.
"distributeSessions": "adaptive",
"adaptiveDistribution": { "scoring": "pressure" },
"expiryRouting": { "enabled": true, "tolerance": 3, "preempt": false }The default score ("scoring": "burndown", everything above) ranks accounts by the weekly room they have left. With expiryRouting on, the reset time then only decides who is in the top pressure band, so spreading across expiring windows is all-or-nothing and tolerance is the only dial. "scoring": "pressure" ranks inside the band by the pressure the band already computes:
score = P ÷ (1 + load)
P is the same figure the band uses: the room under the account's maxUsage caps (the whole window with none) per second until the governing weekly window resets. load is active conversations plus requests in flight, as above. New conversations then land in proportion to how soon each account's quota expires, instead of all on the most urgent account or by room left. The burn boost, taper and concurrency cap are not part of this score.
Every candidate needs a score, so the states the band leaves open are priced: a reset that has already passed, or no reading, counts as a fresh window (the cap, or 1, over one week); a reading with no reset time uses the band's own lower bound; and an account with nothing left under its caps scores 0. When every candidate scores 0 the even walk places the conversation, as it does when every account is reserved. Nothing else changes: availability, priority, the band, pins and the decision whether a pinned conversation moves (the preempt rollover above) are untouched. When that decision has moved a conversation, "pressure" picks the destination among the other accounts. With expiryRouting off the band lets every account through and only the score changes. The setting applies to "adaptive" only and is read at startup.
With "pressureFiveHour": true in adaptiveDistribution (off by default, read at startup, and only under "scoring": "pressure"), the score also counts the 5-hour window, so an account close to that wall takes fewer new conversations:
score = P × h5 ÷ (1 + load), h5 = (T5 − 5h use) ÷ T5
T5 is the lower of the account's own 5-hour cap and switch threshold. h5 runs from 1 for an untouched window to 0 at T5, and a window with no reading, no reset time or a reset already passed counts as 1. It places new conversations only: it can slow how quickly one busy pinned conversation reaches the wall, not stop it, and the decision whether a pinned conversation moves does not read it. teamclaude status shows the factor as 5h room.
With "fiveHourSoftMargin": 0.15 in adaptiveDistribution (0, off, by default; read at startup, and only under "scoring": "pressure"), a new conversation stops going to an account once its live 5-hour use reaches its own 5-hour cap, or a full window with no cap, less the margin: at 0.15, a 0.7 cap stops at 0.55 and an uncapped account at 0.85. Otherwise placement ignores that window until the account leaves rotation, and every conversation pinned there then moves at once and loses its cache. It is only a preference: it applies while another account of the same priority can take the conversation, so it never refuses a request or reaches for a lower priority such as a metered key. Conversations already pinned to the account stay, and it shows in status as not competing.
"distributeSessions": "load"The even mode counts conversations, and conversations are not interchangeable: an agent lane in a build-and-test loop sends a request every few seconds, an interactive session sends one a minute. On a pool of 14 Codex accounts with 24 even-placed sessions, one account was measured serving 31% of the requests and six were serving none. The load mode places each new conversation on the eligible account that served the fewest requests in the last ten minutes (LOAD_WINDOW_MS), then falls through to the even keys (fewest active conversations, fewest in-flight, expiry pressure, soonest reset) as tie-breaks. The conversation is then pinned exactly as in the other modes, so prompt caching is unaffected; only placement changes.
The count is of requests the proxy forwarded, kept in a bounded ring per account and pruned on read, so it needs no probe; with persistSessionAffinity on, the window is saved and restored across a restart, with expiry routing off too. Switching into load from another mode starts from the traffic of the last ten minutes. teamclaude status reports it per account as recentRequests. Like the even mode, load only moves traffic by placing new conversations: an existing skew drains as long-lived conversations end and are replaced.
The config key
expiryRoutingis provisional. #176 proposes aroutingStrategyenum for the adjacent drain-concentration problem, and a strategy value such as"expiry"is a plausible home for this behaviour. The mechanism below is settled; only its spelling on disk is open, and it will follow whatever shape that discussion settles on.
The soonest-reset preference in Choosing an account only applies at the moments selection has to pick — daemon start and threshold rotation. On a fleet whose weekly utilization never reaches the threshold, those moments never come: routing can sit on the account whose window just reset a full week out while another account's ample weekly quota quietly expires unspent. Enable expiryRouting to make the horizon a standing preference instead:
"expiryRouting": { "enabled": true, "tolerance": 1.5, "preempt": true }Each account gets a pressure score for the request's model: headroom in the governing weekly bucket over the seconds until it resets. High pressure means ample quota about to expire, so spend it first. Headroom is the numerator, so a soon reset alone does not favour a nearly-drained account. Both halves come from the same bucket, so an account reporting Fable use but no Fable window is not given the shared window's horizon and ranked on quota it does not have. Fable and Sonnet requests score on their own weekly bucket, so one account can rank differently per model. A family with no bucket of its own scores on whichever binds it, the shared weekly or a scoped weekly upstream reports for it, the same tighter-of-the-two the availability gate uses. So a learned bucket the family table never heard of cannot be spent past while the shared window looks roomy. Codex is outside that: upstream files its per-model weeklies under codexModelBuckets, which no governing-window reader consults, so its pressure comes from the shared weekly alone. The 5h bucket stays an availability gate: its much shorter horizon would swamp the weekly comparison. teamclaude status --json reports each account's pressure against the shared weekly, the ordering the router works from.
Beside codexModelBuckets, each Codex account's status carries codexModelLimits: each model the account has served, mapped to the limit upstream metered it on, as the response's x-codex-active-limit names it. The value is kept as upstream sends it. For a model-scoped limit that is the key the usage probe files its codexModelBuckets entry under (base_model_inference for gpt-reserve on a Pro Lite plan); premium on a Pro plan names the account-wide limit. It is reported for consumers only; routing does not read it either.
An account whose governing bucket is not fully reported is handled in two separate steps, and they do not answer the same way.
Admission is unconditional. Such an account stays in the band rather than being filtered out of it, whichever half of the reading is missing: being used is how that quota becomes known, so banding it out would make the unknown permanent. This mirrors the existing unknown-reset probe bias.
Ranking depends on what is actually known. A bucket reporting no utilization at all is a genuine unknown and ranks at the top of the band, for the reason just given. A bucket whose utilization is reported but whose window is not is a different case: the headroom is known and only the clock is missing, so it is ranked by a lower bound on its pressure — the score it would have if that window were resetting as late as a weekly window can, a full seven days out. A real window resets no later than that, so the bound can only understate, and such an account is never preferred over a measured one on the strength of a number nobody reported. Ranking it as a genuine unknown instead would put an account 95% through its Fable quota ahead of one holding 95% of that quota with an hour left to spend it.
Selection then draws from the top pressure band: accounts within tolerance (a ratio, ≥ 1) of the best pressure in the top priority tier. Inside the band the usual rules apply unchanged — distributeSessions still spreads new conversations by load, priority still wins, and the storm ramp still paces failover. tolerance is the dial between load spreading and expiry pressure: large values approach pure load-balancing, 1.0 is strict highest-pressure-first (and effectively disables spreading).
With preempt on, a pinned conversation (and the sticky current account) is re-routed when its account's governing weekly window rolls over — the account just became both the freshest and the furthest-dated choice, so staying would burn the window that gained a full week while sooner-expiring quota goes unspent. That rollover is the only thing this feature does to a pin by default. Pressure on its own never moves one, and neither does the pinned account's quota draining — that is the policy working, and re-routing on it would thrash the prompt cache for nothing. The one exception is opt-in: inside a reclaim window you set, a pin outside the band moves to the account whose quota is about to expire. Neither applies to a conversation the extra-usage preference keeps on a subscription past its switch threshold: both pick the destination among accounts that can serve normally, so the move would put it on API capacity the preference ranks after that subscription. Everything that moved a pin before still does, unchanged. A pin stops being honoured when the account cannot serve the request (every reason teamclaude status names on its Blocked line, from spent quota through a rate-limit hold to an upstream refusal), when a higher-priority account is available, or when that account was already tried and failed earlier in the same request. A pin is bypassed outright by a manual route pin and by a /tc-acct/ (TC_ACCT) override, both of which resolve before session affinity is consulted at all. And a pin can simply cease to exist: removing an account deletes the pins that named it, teamclaude release deletes the pins on one account on your say-so, and a conversation idle past the known window is forgotten along with all of them. (That enumeration is the four writers of a conversation's pin map — touch, remapAccounts, releaseAccount, and record expiry — plus the two paths that resolve ahead of affinity; it is the search, not a recollection.) Cost of the rollover itself: one cache-miss turn per PIN per rollover of the window that pin is measured on, roughly once per account per week, and a second one where the conversation is sent back to the rolled account before a request confirmed its stay at the destination, as the next paragraphs define it (the destination ran out, say): the roll was never settled, so the pin moves off again as soon as somewhere better is available. A roll is handed back once, so two is the most.
A rollover is measured against what the last request read where it came to rest. The whole state is one reading per pin and one for the sticky current account, taken when a request arrives to find it already placed. A selection that only sends a request may never arrive, so it writes only where no roll can be lost: a choice that never named an account, or one whose recorded windows have not rolled. The roll a preemption pushes traffic off is held until an attempt selecting under this move's stamp is served at the destination — upstream's response headers gave a status below 400 — and the reading is still the one that move left there: once it has moved away and come back its stamp is a later one, and the roll stays held. A body that fails afterwards does not un-serve the attempt. A second preemption before the first is settled holds both: each escaped account keeps its own reading until traffic returns to it or a stay is served under the stamp of the move that escaped that roll. The account a hand-back leaves keeps its own roll the same way, under no move's stamp: the move that leaves it is a move back, so a stay served where it returns to is no evidence about the account it left. A reading no walk established names no fleet of its own, so the roll it loses is held for the fleet of the roll being handed back, since a hold naming nobody can be settled by nobody. A roll is handed back once. A reading restored from a hold is held again only for a window that has rolled since the hand-back, so two accounts that have each rolled cannot trade their rolls for ever. A stay served on the account a roll is held against releases it whatever move stamped it, and only for the fleet the hold names, because the reading has come back to the account that owes it. The sticky current account's reading is one slot every provider shares, so the hold names the fleet that last established the reading it preserves, and only where the destination is that fleet's own subscription, which no other fleet is ever served at, does a success of its own release the roll; anywhere else the destination holds one reading for whoever it serves, and a success by whichever fleet is served there releases it. A request whose provider does not own the cursor borrows it, and gives it back but not the reading. With no roll standing on the account it names, a borrowed walk leaves it naming the borrower's, so the owner's next request re-reads that account and the test compares the reading against itself. A roll on the account the cursor names is missed whenever the reading names somewhere else by the owner's next request, whether the borrow that moved it fell before that roll or after. Only a borrower resting on a cursor of its own moves a reading whose account has already rolled, so a fleet without one yet leaves a standing roll for the owner to preempt on. That rest also puts the displaced roll into the hold, so only the later order leaves anything to recover. A fail-back is handed the roll where the borrow followed it, and nothing where it came first.
Arriving is not being served, so the hold survives a retry that never leaves the destination, whether a 401 re-entering selection on the same account or a short-wait 429 with no idle sibling. However many requests start there, none has been answered.
A retry of the same request can confirm the move, because the stamp is re-read before every attempt selects. But only after something has come to rest at the destination: the move writes nothing there, so the first attempt to arrive takes the reading, having selected before it was stamped. The attempt that made the move selected earlier still.
A rollover that happens before anything has read that account is not detected. That window is one request wide, and every first placement has it: a conversation's opening account, a rotation's destination, an operator's switch. In practice it costs the account's next roll rather than this one. Traffic that returns before the destination has served anything is preempted off the rolled account again as soon as anywhere better is available, because the stay was never confirmed. Traffic that returns after a serve finds the roll released and reads the origin whole, keeping the week that account gained until the window rolls again. A request still in flight when a later one confirms the stay pays that price: the confirmation speaks only for its own attempt. Where a learned scoped window shares a pin with the bucket it falls under (see above), every family on the pin pays that turn. A rollover that moves nothing logs why: no eligible account could take the traffic, or the re-rank ran and the account it was on still ranked best. Without that line a stuck preemption looks like no rollover, or the ordering agreeing that staying is right.
Pressure places new conversations on the account whose week is about to expire, and leaves a pinned one where it is. On a pool where one long conversation carries most of the traffic, that conversation can stay elsewhere while most of the expiring week is lost: in the measurement behind #643, an account with 80% of its week unspent and a reset 3 h 20 m away received 30% of the requests, because one conversation was pinned to another account. reclaimHours lets the router move such a conversation by itself:
"expiryRouting": { "enabled": true, "tolerance": 3, "reclaimHours": 24 }Off by default (0, and anything that is not a positive number of hours). With it off, a pin is treated exactly as described above. With it on, a conversation pinned to an account P moves to an account A on its next request when all of these hold:
- P is outside the top pressure band for this request's model, and A is in it on a measured pressure. A conversation whose account is in the band stays, which is also what keeps a moved conversation on A.
- A's deadline is ahead and no more than
reclaimHoursaway. The deadline is the one its pressure is priced on: the governing weekly reset for the request's model, or the account'sendsAtwhen that comes first. - A's deadline is sooner than P's. A move is always toward the earlier deadline, so two accounts that are both inside the window cannot pass a conversation back and forth as each is drained.
- A can serve the request by the ordinary checks: enabled, not cordoned, under its own 5-hour and weekly switch thresholds and
maxUsagecaps, allowed by the routes for this model, and of the request's provider. WherefiveHourSoftMarginkeeps new conversations off A, it keeps a reclaim off it too. - A and P have the same
priority. A better priority already outranks a pin, and that rule is unchanged. - A and P are known to belong to the same organization. An account whose organization is not known counts as a different one.
"reclaimAcrossOrganizations": truedrops this condition.
If several accounts qualify, the conversation goes to the one a new conversation would be placed on among them. The move applies to the next request's selection: a request in flight finishes where it is. It is logged as Session pin on "P" released — reclaim: ..., and the destination is paced by the storm ramp as after any other move.
What stays put. A session pin, a TC_ACCT or /tc-acct/ pin (keep-warm uses one) and a manual route pin resolve before session affinity is read, so none of them is ever moved by this. A conversation kept on a cordoned account stays there as well. With distributeSessions off there are no pins to move: every conversation follows the current account, and expiry routing changes that account only at a rollover or a rotation. To have the current account follow the soonest deadline in that mode, use preferSoonestWeeklyReset or teamclaude switch.
After the move the conversation is pinned to A like any other. When A reaches its 5-hour or weekly switch threshold the conversation is placed again by the normal ranking, and when A's next 5-hour window opens it moves back to A if the conditions above still hold. Draining a nearly whole week therefore costs two moves per 5-hour window for each long conversation. Once A's weekly window rolls over, or its quota is spent, A leaves the band or the window and nothing more moves.
What it costs. Each move is a switch of account, with the cost described under Prompt caching across rotation. Within one organization that cost was measured as small in #643: 9 of 10 first responses after a move to an account that had not served the conversation were cache hits, on one pool over 16 hours. That is a small sample from one operator. Across organizations the prompt cache does not carry and neither do Sonnet 5.5 thinking blocks, so every move is a cache miss and a dropped block. That is why the default requires one known organization, and why reclaimAcrossOrganizations is a separate setting: turn it on when the quota that would expire is worth more to you than those turns.
Sizing reclaimHours. Weekly quota can only be spent through 5-hour windows, one after another, so the window has to open early enough for the remaining share to fit. Take the share of the week one full 5-hour window consumes on that plan (in #643 it was about 0.17, measured on one account by comparing how far the 5-hour and weekly readings moved together), divide the weekly share you expect to have left by it, round up, and multiply by 5 hours. With 0.80 of the week left: 0.80 / 0.17 rounds up to 5 windows, so "reclaimHours": 25. A value of 5 or less can reclaim at most one 5-hour window. A larger value moves conversations earlier and so more often; a value of 168 or more means any account in the band with a sooner deadline qualifies.
teamclaude release <account> remains the manual tool for the same job: it releases every pin on one account once, whatever the organizations and the window.
With "preempt": false the band only refines the moments selection was already going to pick — a rotation, or placing a new conversation — so the "standing preference" above is really a property of preempt: true. Without it, the sticky current account (distribution off) or an existing conversation's pin stays where it is across a rollover, and long-lived conversations can still ride an account whose window just reset a week out.
Off by default. With the knob off, every routing decision is byte-identical to the one the router makes without this feature, and with reclaimHours unset or 0 every decision is the one the router makes without the reclaim window. The one addition either way is the status payload: teamclaude status --json gains an expiryRouting echo of the resolved settings and a per-account pressure figure whether the knob is on or off, since pressure is a measurement of the fleet rather than a report of the feature's state. Changes apply to a running server via POST /teamclaude/reload (or any CLI command that notifies the server). Off means there is no state at all, and that is what makes the byte-identity promise checkable rather than a rule every reader has to remember: no reading is taken while preemption is off, and every reading is dropped the moment it is turned off. Switching it back on takes a fresh reading for the current account and for every live conversation's pin — including any that a reload turning distributeSessions off in the same pass has just put into the drain, whose only bound is the rollover above — so the fleet is measured from the reload rather than from its next roll. The cost of that lifetime is stated rather than hidden: a rollover that happens while the feature is off is not carried across. It was not being watched for, and the alternative is mechanism state that outlives the knob.
A status read, a TUI paint, the quota poll behind the status line and the opening placement at launch all meet an expired 5-hour window before any request. The status read clears the window and never switches, knob off or on. The other three call the combined clear-and-switch. With the knob off they take it themselves, with no request in hand and so on the model-less ranking. Launch then places the cursor outright, so its switch settles nothing either way. With the knob on none of them switches, because a reset is spent by a request and none of these is one.
The event stays recorded on the account. The first request that can be sent both there and to the cursor's account acts on it, ranked on the window governing that request. Acting on it can mean staying. The band that refuses the move covers the fleet the cursor serves and not this attempt's reach, so it holds the accounts the request's provider partition leaves that are available for its models, the ones already tried included, since that cursor also serves the requests behind this one. A request that also names an advisor model is admitted on both models, by the same test that selection applies. So it spends the event only onto an account it could itself be sent to. Where no account the request can be sent to serves the advisor model, selection routes on the main model alone. The switch follows it there, so advisor traffic can still spend a reset. The flag is not in the quota state the proxy saves, and the poll that raised it already cleared the window, so a restart drops the event. Startup then places traffic by the ranking any start uses, owed nothing, the cursor included.
With sessionAdvice on, the proxy answers, for one Claude Code session, whether moving it to another account is worth it. It only advises: moving is the operator's teamclaude switch <account> --session.
"sessionAdvice": { "enabled": true, "maxContextTokens": 150000, "cooldownMinutes": 60, "ask": false }curl -s 'http://127.0.0.1:3456/teamclaude/session-advice?session=<x-claude-code-session-id>'{ "session": "…", "account": "a", "via": "affinity", "context": 42300,
"advice": { "enabled": true, "ask": false },
"recommendation": { "to": "b", "reread": 42300 }, "reason": "out-of-band" }account is the session's manual pin (via: "manual") or else the account its conversations are pinned to (via: "affinity"). Among the session's conversations seen within two minutes of its last request, the one with the largest context prices the move. context is that conversation's last prompt size (cache read, cache write and uncached input), and reread is the same figure: an estimate of what the destination re-reads without the prompt cache. A later side conversation on a smaller model does not change the account shown. A conversation brought back by affinity across restarts keeps its pin but no token figures, so until its next response context and reread are null and the ceiling below is not applied.
A move made this way is not compacted first. compactBeforeSwitch asks a conversation only ahead of a rotation and never asks a request that a session pin holds, so the destination re-reads the conversation at the size reread gives. Compacting the session first (/compact in Claude Code) is what makes it smaller.
reason is the first of these that applies:
reason |
Recommendation | When |
|---|---|---|
disabled |
none | sessionAdvice.enabled is not true |
unknown-session |
none | the proxy has no pin and no live conversation for that id |
pinned-unavailable |
when an account can take it | the session is manually pinned to an account its requests are not forwarded to: one over a maxUsage or spend cap, one whose plan is refusing the model, a subscription of another provider, an account that no longer exists, or one upstream has stopped serving (rate limited until its window resets, exhausted, or in error). A manual pin never fails over, so every request fails and this is advised past every check below, expiry routing off and the cooldown of the move that made the pin included. A pinned account that is disabled, over its switch threshold, cordoned or excluded by a route is still sent the session's requests, so it is judged by the rules below like any other. The check is made for the conversation's own model only: a family cap on an advisor model the session's requests declare can still bar them while the advice reads the pin as serving |
expiry-routing-off |
none | expiryRouting is off, so there is no pressure band to leave |
cooldown |
none | the session was moved or the advice declined less than cooldownMinutes ago |
context-over-ceiling |
none | context is over maxContextTokens: the re-read costs more than the move gains |
current-unavailable |
none | the account cannot serve, and the router decides where the session's next request goes: another account, or, under an extra-usage preference, the same account spending credits. A cordoned account counts as serving here, since it keeps the conversations already on it; the band leaves it out, so its sessions read out-of-band |
router-moves |
none | the router itself moves the session on its next request, judged in the router's order. A manual route pin for the session's model to an available account decides alone: router-moves exactly when it names another account. Without one, an available account of the session's provider with a higher priority (a lower priority number) preempts it in every distribution mode (with distribution off, not while the account is the operator's teamclaude switch choice). With distribution off a session has no affinity, so it is also router-moves whenever the fleet's current account for its model is another one: the next request goes there anyway. With distributeSessions on, no route pin at all and an account that is not cordoned, so does the reclaim window. A cordoned account keeps the session unless a route pin names a healthy account that cannot serve, in which case the fleet walk leaves it. A session pin would only hold the session where it is, since a pin never fails over and neither preemption nor reclaim moves one. Not anticipated: a governing-window rollover under expiryRouting.preempt (the session can read out-of-band for the one request before the router moves it); the advisor model's family cap and route pin, since the check uses the conversation's own model only, so the advice can say router-moves while the router keeps the session; and the routes of a restored conversation, which has no model on record until its next request |
in-band |
none | the account is in the top pressure band |
out-of-band |
yes | the account left the band; to is the account session placement would give a new conversation of that model, among the accounts of the session's provider, in the configured distributeSessions mode (the even walk when it is off). On a route-pinned session the move is still made: a session pin resolves before selection, where route pins are read, so it overrides the route pin for that session |
no-destination |
none | out of the band, but no other account can take the session |
An accepted move is a session pin: the session then stays on that account and does not fail over, until teamclaude switch --session --clear drops the pin and gives it back to rotation. A successful POST /teamclaude/session-pin starts the cooldown while the feature is on. POST /teamclaude/session-advice/decline with {"sessionId": "<id>"} starts it without moving and answers {"ok": true, "recorded": true}, or "recorded": false with the feature off. Cooldowns live in the server's memory and are gone on a restart. ask is echoed under advice for clients that want to ask before moving.
The destination is judged on the model of the conversation that prices the move. On a fleet whose routes restrict accounts by model, it may not serve the session's other model families. A restored conversation has no model on record until its next request; it is placed in the bucket of its newest pin, and no destination is named unless that is the shared weekly bucket on a fleet with no routes and no models claims.
Both endpoints are refused with 403 for a caller holding a client key: the answer names a session's account and context size. The shared proxy.apiKey and key-exempt loopback callers are allowed.
TC_ACCT forces every request onto one account, bypassing rotation (and never failing over to another, except along a list of API-key accounts when billing refuses one, or a list of subscriptions when one's quota is spent). It works in both modes — MITM (the default) and --no-mitm:
# By email — what you'll normally use
TC_ACCT=me@example.com teamclaude run
# By accountUuid — stable across renames; `teamclaude accounts` prints it
TC_ACCT=a1b2c3d4-… teamclaude runTC_ACCT is read by teamclaude run and removed from the environment before claude is launched — it never reaches the client or anything it spawns. Under --no-mitm TeamClaude builds the pinned base URL itself; under MITM it travels as the proxy credential on each CONNECT, which is the only pin channel an HTTPS_PROXY URL can carry. Either way you don't hand-write a URL.
teamclaude env honours it identically, so a tool that spawns claude itself gets the same pin:
TC_ACCT=me@example.com eval "$(teamclaude env)"The value matches an accountUuid, an orgUuid, or a display name/email, first match wins. No escaping needed; spaces, @ and parens are handled for you. An unknown value is refused by the proxy with a 404 rather than quietly served by whichever account rotation picked. That refusal happens on the first request, not at launch, so a typo shows up as a failing claude rather than a wrong account.
Prefer the accountUuid (printed by teamclaude accounts) for anything scripted: display names are rewritten in place, since an account is named by its email and gains an (Org) suffix the moment that email holds a second org.
The rotation index is not accepted — it is array position, so deleting an account would silently repoint every later pin at a different account.
If you hold the same account in two orgs, a bare uuid or email matches the first one.
TC_ACCT=<accountUuid>/<orgUuid>picks a specific one — rarely needed.
TC_ACCT may name several API-key accounts, separated by commas, in the order they are to be spent:
TC_ACCT=credit-one,credit-two,credit-three teamclaude runThe session is pinned to the first. When upstream billing refuses the account a request is on (no API credit left, see Billing refusals), that request goes to the next account in the list, and later requests pass over a listed account for as long as its billing cooldown lasts. The refusal arrives before the model runs and before anything reaches the client, so the request runs once, on the account that takes it. A listed account serves while it is disabled, as a pinned one does, so accounts kept out of rotation can be spent this way and no other.
That is the only move. A rate limit, a 5xx, a credential refusal or any other answer is handled as for a pin to one account; a response that has started reaching the client is never moved; and the list never moves a request to or from a subscription, whatever it names (a list headed by a subscription is a list of subscriptions). A listed account at its usage cap, or of another provider, is passed over. When no listed account is left, the request ends as a pin to the last one tried does.
Every name has to match an account, or the pin is refused as an unknown one is. A value that matches as a whole is still that one account, so a display name with a comma in its org keeps working. Under MITM the list travels as the proxy URL's username (http://credit-one,credit-two:<key>@127.0.0.1:3456), under --no-mitm in the /tc-acct/ prefix. The session pin names one account.
Each account is usually its own organization, and organizations share no prompt cache, so the first request of each conversation after a move writes its cached prefix again on the next account.
A list headed by a subscription names the subscriptions a session may use, in the order it should use them:
TC_ACCT=work-1,work-2,work-3 teamclaude runEach request goes to the first listed subscription that can serve it under its switch threshold. When none can, it goes to the first one held back by the threshold alone, since a pin may spend past the threshold up to maxUsage, as a pin to one account does. A request stays on the account chosen for it; a quota rejection (a 429 with a spent window) there, or a token that could not be renewed, has it chosen again by the same rule among the listed accounts it has not tried, and the rejection's hold keeps later requests off that account until it lifts. Requests return to an earlier account in the list as soon as it can serve again.
So a session can be kept to the accounts that have something the others lack (one organization's access to a model or a feature, its data terms), and a per-account switchThreshold below 1 on those accounts leaves the rest of their quota to the sessions that name them: rotation stops at the threshold (bar the one revalidating request an exhausted fleet sends), the list spends on past it. Give it for every weekly bucket the session's models use (unified7d, unified7dSonnet, unified7dFable), since a family model is held to its own bucket's threshold.
The list moves nowhere else. It never reaches an account it does not name, nor an API key it names. Only subscriptions of the first one's provider are used. A transient rate limit, a 5xx or a response that has started reaching the client is handled as for a pin to one account. A listed subscription serves while disabled or cordoned and whatever routes say, as a pinned one does. One at its usage cap, with a spent window, held by a rate limit or refused upstream is passed over while another listed one can serve; when none can, the request goes to the first one it has not tried, as a pin to that account would. When every listed account has been tried, the request ends as a pin to the last one does.
Before this, a list headed by a subscription pinned the session to that subscription alone. A one-name pin is unchanged, and so is a list headed by an API key.
TC_ACCT is chosen at launch. To move a session that is already running, without moving the rest of the fleet the way teamclaude switch <account> does, pin it by its session id:
# From inside the session (a `!` command): Claude Code exports $CLAUDE_CODE_SESSION_ID
teamclaude switch api-1 --session
# From anywhere else, naming the session
teamclaude switch api-1 --session 3f2a1b9c-…
# Back to following the fleet
teamclaude switch --session --clearThe pin behaves like TC_ACCT: the session's requests go to that account only and never fail over, and an account that has since been removed is refused with a 404 rather than quietly replaced. A launch-time TC_ACCT pin wins over it. The account is accepted in every form TC_ACCT accepts and stored by name, so it follows a rename.
It is runtime state, like switch: kept in the server's memory, gone on a restart, and forgotten once the session has been idle for an hour. teamclaude status lists the pinned sessions on its Pinned line, the dashboard in its summary, and the activity view marks their requests [pin]. The command warns when the proxy has not seen a request from that session id in the last hour, since a pin on an id no request carries pins nothing. A caller holding a client key is refused, as for the other control-plane writes. The command wraps POST /teamclaude/session-pin with {"sessionId": "<id>", "account": "<name>"}, where "account": null clears the pin.
Pinning without teamclaude run (/tc-acct/, deprecated)
Deprecated — use TC_ACCT instead. The path-prefix form cannot work in MITM mode (inside a CONNECT tunnel the path is the real upstream one), so it only covers half the product. It still works for keep-warm's internal use and for calling the proxy directly:
curl -s http://127.0.0.1:3456/tc-acct/1/v1/messages \
-H 'content-type: application/json' \
-H 'x-api-key: <your teamclaude proxy key>' \
-d '{"model":"claude-sonnet-4-6","max_tokens":16,"messages":[{"role":"user","content":"hi"}]}'URL-encode spaces and parens in a name here. The fully-qualified accountUuid/orgUuid form is not expressible in a path (the / is the delimiter) — use TC_ACCT for that. An unknown pin returns 404. The prefix is stripped before the request is forwarded upstream.
Rotation is transparent to your Claude Code session, but it's worth knowing how it interacts with Anthropic's prompt cache.
- Your context is never lost. Claude Code resends the full transcript every turn, and TeamClaude rewrites the request's
account_uuidto match the injected token, so whichever account serves a turn sees the complete history — a mid-session switch is invisible to the client. - The cache doesn't carry across organizations. The prompt cache is scoped to the organization that created it and expires after a few minutes. Each personal subscription is usually its own organization, so on such a pool the first turn after a switch is a cache miss — that turn is processed without the cache discount, after which the new account warms its own cache. No proxy can share a cache across organizations.
- Within one organization a switch often does not miss. One operator measured this over 16 hours on a pool whose accounts all share an organization (#643), counting a response as a hit when at least 90% of its prompt came from the cache. The first response after a move hit 73% of the time (85 of 117), against 93% for staying on the same account, and 9 of 10 hit on an account that had not served the conversation in the last hour. That is one pool and a small sample, and the gap is unexplained, so plan for a switch to cost some cache hits rather than none. Where this page says a move costs a cold cache, read that as the cross-organization case.
In practice this rarely bites, because TeamClaude prefers to keep you on one account (see Choosing an account) — a single account tends to serve a whole session and switches are infrequent.
Keep-warm is unrelated to this — it starts an idle account's 5h session timer, not its prompt cache. An account in another organization still takes a one-turn cache miss after a rotation, regardless.
compactBeforeSwitch (off by default) has Claude Code compact a long conversation on the account that still holds its cache, shortly before that account reaches a switch threshold. The switch that follows then carries a summary to the next account instead of the whole transcript, which that account would otherwise write to its cache at the cache-write price.
"compactBeforeSwitch": trueor, with the defaults written out:
"compactBeforeSwitch": { "margin": 0.04, "minBodyBytes": 400000, "cooldownSeconds": 1800 }What it does. Only the client can compact its own conversation, and nothing lets a proxy start a compaction. What the proxy can do is answer one request with the Anthropic API's error for a prompt over the context limit:
{"type":"error","error":{"type":"invalid_request_error","message":"prompt is too long: 107926 tokens > 107000 maximum"}}with status 400. Claude Code reacts to that error by compacting the conversation and retrying the turn. The request that was answered this way is not forwarded, so the provider never sees it and no quota is spent on it. The compaction request that follows is the same conversation, so it goes to the same account, where the transcript is expected to be a cache read.
Read this before turning it on:
- The client is shown the provider's error wording for a request the provider never saw. The proxy writes that answer itself. The first number is the request body size in bytes divided by 4, rounded up. The second is the largest multiple of 1000 below it. It is not a model's context limit: the conversation is usually well under the real one. The answer carries no
request-idheader, since upstream issued none. - It relies on how Claude Code behaves, not on a documented contract. The reporter of #709 observed Claude Code 2.1.325 compact and retry on this error, in
claude -p --continueand in the stream-json mode the IDE extensions use, against a mock upstream. Other versions and other clients were not checked, and neither was what the client does if its compaction request itself fails. A client that does not compact on this error shows it to you as a failed turn. - A compaction discards conversation detail. The model continues from a summary. With this on, long conversations are compacted earlier than Claude Code would have compacted them by itself.
- The saving was inferred, not measured. In #709 the compaction request shared its prefix with the earlier turns, block for block, so it should be served almost entirely from the cache on the account that served those turns. That was worked out from the structure of the requests against a mock upstream, not observed on a real account. On a pool whose accounts share one organization a switch often does not miss the cache in the first place (see above), and there is less to save.
- While an account sits inside the margin, every long conversation on it is asked once. An account that approaches its weekly threshold slowly stays inside the margin for a long time, so more conversations are compacted than the one switch at the end would have cost.
marginbounds that.
When a request is asked. All of these hold:
- it is a
POST /v1/messagescompletion that carries a Claude Code session id.count_tokensand every other endpoint are forwarded; - its body is at least
minBodyBytes(default400000, about 100k tokens). Body size stands in for the token count because it is known before anything is sent; in #709 bytes divided by 4 matched the client's own count within 1%; - the account that served this conversation's last request is a Claude subscription account, and it is the account this request would go to now. A conversation with no earlier request on record is not asked, and neither is one whose account the fleet has already left. Codex accounts, API-key accounts and third-party backends are never asked;
- that account is within
margin(default0.04) of its switch threshold on the 5-hour window or on the weekly window that gates the request's model, and is not yet at either. The thresholds are the ones rotation uses, per-bucket tables and per-account thresholds included. An account already at a threshold is not asked, because its compaction request would be sent to the next account, where nothing is cached; - nothing pins the request to an account:
TC_ACCT, the/tc-acct/prefix, an operator session pin and keep-warm requests are never asked, since a pinned request does not rotate.
How often. A conversation is asked once per cooldownSeconds (default 1800), which is what lets its compaction request through. A client session is asked at most once in two minutes. After those two minutes and until the cooldown ends, a request of that session is asked only if its body is at least as large as the one that was asked: a compacted conversation that its system prompt and tools keep above minBodyBytes is left alone until it has grown back. The record is kept in memory, one per server (the MITM tunnels share it), and a restart forgets it.
Session distribution. With distributeSessions off, one account serves the fleet, so the account in question is the current one, and each long conversation on it is asked as it comes in. With it on, each conversation is held to the account it is pinned to, so only conversations on the account near its threshold are asked.
Invalid values are not an error: anything other than true or an object is off, and a field that is not a usable number takes its default (margin above 0 and below 1, the other two above 0). The setting is read for each request, so POST /teamclaude/reload applies an edit to the next one. Each request answered this way writes one log line naming the session, the account and the window, and shows in the activity log with status 400 and (compact before switch: <account>) in place of the account. GET /teamclaude/status reports the setting as resolved and the count since start under compactBeforeSwitch. An error inside the decision forwards the request.