Skip to main content

Module account_episodes

Module account_episodes 

Source
Expand description

One notice per account episode, and the move to another account (docs/specs/SPEC_UNRESPONSIVE_AGENTS_2026_10_23.md §6).

An episode is every agent pane that is limited or signed_out on one account (agent_state::unavailable_of_block, which reads the account its run launched on through run_accounts_of_block), from the first until none is: the reset passed, the agents moved, or they recovered. srv keeps them in memory (machine::Episodes) and rebuilds them from block meta on start; a failure stored before the start is the episode rebuilt, not news.

What follows from an episode:

  • the accountavailability event when it opens, changes or closes (ok), and identity.account.availability for the open ones, which the Kanban and Swarm strips show with the move action;
  • one OS toast (NotifyKind::AccountUnavailable) for a sign-in problem or a weekly (or unknown) limit, never for a session limit, and no per-pane AgentCrashed or “finished” toast for a pane it covers (covers_block);
  • one [AgentMux] note to the agent that requested each task a newly blocked agent holds. A worker’s leader already hears from backend::worker_notes.

An agent that hits a usage limit moves by itself to an account with quota after its turn (failover); so do the agents of a login that expired, to a valid login of the same account first, and the one that was mid-turn carries on (login_expiry).

identity.account.move_agents (moves) links an episode’s idle agents to another signed-in account of the same provider and restarts their panes; any link change clears the failure its old account caused (failed_panes, after_rebind), and a sign-in that proves an account works clears its panes’ “signed out” (after_sign_in).

Modules§

accounts 🔒
identity.accounts: the signed-in accounts on this machine as an agent sees them, and how identity.switch names one (docs/specs/SPEC_AGENTS_OPERATE_OTHER_MACHINES_2026_10_30.md §4.3, §4.4).
failover
Automatic failover (docs/specs/SPEC_AGENTS_OPERATE_OTHER_MACHINES_2026_10_30.md §4.4, D4): an agent whose pane hit a usage limit moves itself to another signed-in account of its provider that has quota, once its turn is over, and says so in one note to the agent and one to its lead.
fresh 🔒
The sign-in of each account as its credentials file says now, not as the store last recorded it.
key_account 🔒
An Anthropic API key as an account a Claude agent can be moved onto (docs/specs/SPEC_AGENT_PANE_API_KEY_ACCOUNT_SWITCH_2026_11_16.md).
login_expiry 🔒
A login that expired: its agents move to a valid login by themselves, and the one that was mid-turn carries on.
login_recheck 🔒
A pane left signed out by a login that has since been signed in again clears itself (#47468).
machine 🔒
The account episodes, as a pure state machine: a scan’s blocked panes in, what to publish, raise and tell out (docs/specs/SPEC_UNRESPONSIVE_AGENTS_2026_10_23.md §6.1, §6.2). No clock, no store: mod.rs scans and applies.
moves 🔒
“Move these agents to another signed-in account” (docs/specs/SPEC_UNRESPONSIVE_AGENTS_2026_10_23.md §6.3): agent.account.switch (switch::switch_to) for each agent of the episode, so an agent in a turn is queued.
resume 🔒
After a confirmed sign-in, an agent whose last turn failed on the expired login is told, and answers with where it stands (task #2458).
switch 🔒
agent.account.switch: change which account an agent runs on (docs/specs/SPEC_ACCOUNT_SWITCH_FROM_THE_COMPOSER_NO_BIND_2026_10_26.md §3.1, §3.2, §3.4).
switch_error 🔒
Why an account switch did not happen: what went wrong, for code, and the words the caller reads.

Structs§

AccountAvailability
One account’s episode, as identity.account.availability lists it for the operator’s windows and for agents. The label never goes in a toast or an event; it reaches another machine only through the proven identity.accounts remote operation.
AccountAvailabilityEvent
accountavailability (spec §6.1): an episode opened, changed or closed (ok). A signal for the windows, which then read identity.account.availability: it carries no account label and no move candidates, since any connection can subscribe to an event.
AccountEpisodeAgent
One agent of an episode.
AccountEpisodeTask
A Kanban task an episode’s agent holds (claimed, or blocked on a question).
AccountMoveCandidate
An account the agents can move to.
IdentityAccountAvailabilityResult
identity.account.availability: the open episodes. Open to agents (spec §4.4): it names accounts and their limits, never a credential.
IdentityAccountSignedInReq
identity.account.signed_in: the window’s sign-in to this account completed and its CLI confirmed the credential (#2237).
IdentityAccountSignedInResult
identity.account.signed_in: how many of the account’s panes stopped being signed out.
Runtime 🔒

Constants§

SETTLE 🔒
After a failure or a turn end, how long to wait for the other to land.
TICK 🔒
How often the episodes are rebuilt without a prompt: a reset passing changes them with no event.

Statics§

RUNTIME 🔒

Functions§

after_clearing 🔒
Failures were cleared: replay what was held for those agents, and let the episodes see that their panes left.
after_rebind
An agent was linked to account_id (spec §6.3, “on rebind”): clear the stored failure of each of before (failed_panes) whose run wasn’t on that account, then wake held messages and the episodes. Returns how many were cleared.
after_rebind_telling
after_rebind, and with tell set the agents whose last turn failed on the old login are told they are signed in (resume::start). Set it only when the new login is known to work: a move to an account the choice found valid, or a key that just passed its check. Not for an unlink (no account at all) or a key nobody has checked, whose next turn could fail again.
after_sign_in
account_id’s credentials were just proven good: a sign-in to it completed, or a validate of it passed (#2237). A rebind to the same account clears nothing (after_rebind), so without this its panes stayed signed out until a turn ran. A token refresh isn’t a proof and doesn’t call this. Runs off the async workers; does nothing before install.
agent_name 🔒
announce 🔒
apply 🔒
availability 🔒
The open episodes, as the strips show them. BLOCKING.
baseline 🔒
The failures already stored when srv starts, whether or not their panes have a controller yet.
blocking_failure 🔒
The failure kinds an episode is made of: a usage limit or a refused sign-in.
canonical 🔒
p canonical, or as given when it isn’t a known provider.
clear_signed_out 🔒
Clear the refused sign-in stored on each pane whose run was on account_id, then wake held messages and the episodes. A usage limit stays: it ends at the reset or a move. Returns how many were cleared. BLOCKING.
clear_signed_out_panes 🔒
clear_signed_out, returning the panes it cleared with when their turn failed, for resume::start, which tells those agents. BLOCKING.
covers 🔒
covers_block against these stores at now_ms.
covers_block
Whether an account episode speaks for this pane’s failure, so its own AgentCrashed or “finished” toast is left out (spec §6.2): its stored failure is a usage limit that hasn’t reset or a refused sign-in, on an account. A pane with no account keeps its own toast. BLOCKING.
failed_panes
agent_id’s panes for provider whose stored failure is a usage limit or a refused sign-in, with the accounts their runs count against. Read before a link changes: a pane from before agent:run_account counts against the agent’s links, which the change replaces.
held_tasks 🔒
The claimed or blocked tasks each of block_ids holds, by block, and who requested each one.
identity_accounts 🔒
identity.accounts: every signed-in account here with its stable id and quota. Runs off the async workers.
install
Start following the episodes. Call once at startup.
label_of 🔒
membership 🔒
The pane’s account and state while its stored failure keeps it in an episode: a usage limit whose reset (if known) hasn’t passed, or a refused sign-in, on an account. Read from the stored failure, not the live state: a retry turn shows the pane working for a moment, and that must not close its episode and open a new one with a second toast when the turn fails again. Only a clean turn, a rebind or the reset clears it.
panes_of 🔒
The panes (open, or parked) an agent’s definition has: what a change to the agent’s runtime is written to.
publish 🔒
rebind_clearing 🔒
after_rebind_telling without the telling: how many failures were cleared, and the panes among them (with tell set) whose last turn failed on the login, for the caller to pass to resume::start once the pane is running on the new account. A move restarts its panes after the relink, so telling at the relink would reach the old process, still on the expired login.
refresh 🔒
Rebuild the episodes now and act on what changed. BLOCKING (store reads).
refresh_soon 🔒
Rebuild the episodes soon (a failure, a turn end, a rebind).
register
These RPCs are the operator’s, except agent.account.switch and identity.account.availability: an agent connection (bus:register) is refused for the others, since the move relinks and restarts other agents and a sign-in clears other agents’ state. A switch is open to agents (the caller is ctx.agent_id) and is audited under their name. The availability names accounts and their limits, never a credential, and an agent has to see it to choose where to move (spec §4.4).
requester_items 🔒
For each requester of a task the newly blocked panes hold: the panes, and the refs of that requester’s tasks each one holds.
requester_notes 🔒
The notes to send for the newly blocked panes of account_id’s episode: one per requester per episode (spec §6.2), naming each of its agents and tasks. A requester already told in this episode gets nothing more when another agent joins: the strip shows the rest.
restart_panes_of 🔒
Restarts every open pane of the agent with its conversation resumed. A persistent pane in a turn is restarted when the turn ends. A one-shot (subprocess) pane, a container agent’s, is not restarted: a restart would end the turn it is in, and its next turn reads the agent’s choice anyway; nor is a stopped agent, which would be started by it. Those are counted apart. Returns how many were restarted, how many pick the change up at their next turn, and why the others were not restarted.
scan 🔒
Every agent pane whose stored failure puts it in an account’s episode now.
signature 🔒
switch_account 🔒
agent.account.switch for a caller that is not on the RPC engine (the Identity tool’s HTTP route). caller is the agent’s slug. Runs off the async workers.
switch_all_limited 🔒
Identity switch with the agent all limited. caller is the agent’s slug. Runs off the async workers.
tab_blocks 🔒
Every pane in a tab, and every parked agent block: one in no tab whose agent keeps running with no pane showing it. Its limit or sign-in refusal is as much an episode as a shown pane’s.
toast_key 🔒
The toast’s key for an account: its group, and the id it is taken down by. Hashed, so the account id isn’t in the notification.
view 🔒
What the strips and the event show for ep.