Expand description
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).
The one door for the composer’s login email, the failure row, and agents
(Identity switch). It does what bindAccountToAgent did in the window
(replace the link, clear the old account’s limits, restart the panes with
--resume), in srv, so every caller gets the same result and the same audit
row. An agent in a turn is not restarted under it: the choice waits on its
panes (agent:pending_account) and is applied when none of them is in a turn.
Structs§
- Account
Switch AllEntry - One agent’s outcome in an
all limitedswitch. - Account
Switch AllResult Identityswitchwith the agentall limited: every agent with a pane out of quota.- Agent
Account Switch Req agent.account.switch.- Agent
Account Switch Result
Enums§
- Account
Switch Status - What
agent.account.switchdid. - Account
Switch When
Constants§
- META_
PENDING_ ACCOUNT - A pane’s pending switch: the account id the agent moves to once none of its panes is in a turn. The pane’s meta carries it, so the composer chip shows it live and it survives a restart.
- META_
PENDING_ 🔒BY - Who asked for it, for the audit row written when it is applied.
Functions§
- actor_
named 🔒 - How a switch names who asked: the person for the window, else the agent with its prefix, so no agent id can read as the person or as AgentMux’s own failover.
- agent_
provider 🔒 - The provider the agent
def_idlaunches on: its own, or its bundle’s when it has none. - apply 🔒
- Link
agenttotoand restart each ofblockson it.actoris recorded.nowends a turn in progress; otherwise the caller has seen that no pane is in one. - apply_
pending 🔒 - Apply each queued switch whose agent has no pane in a turn. Runs with every episode refresh (a turn ending pokes it). BLOCKING.
- clear_
stale_ 🔒prep - Clear the chip’s countdown from panes whose window is gone: srv restarted in it, so the choice it
waited on is applied by
apply_pendingfrom the pane’s own meta, without a window. - is_
all_ limited - Whether
agentis the targetall limited, in the words an agent may type. - is_
asked 🔒 - Whether the agent is asked to prepare before this switch (
server::prep): a switch already waiting on its window is the window’s, a failover never asks (AgentMux acts because the account failed, and the agent can seldom answer), and any other agent is asked when it has something to lose. - open_
panes 🔒 - panes_
to_ 🔒tell - The panes of
signed_outto tell: those inrestarted, and none whenactoris the login-expiry failover. - prep_of 🔒
- receiving 🔒
- The account
account_idas it is now, when it can take an agent: it, its provider and the provider’s accounts. - refresh_
auth_ 🔒env - Point the pane’s own
cmd:envconfig-dir variable atto. The spawn injects the linked account over it, but the window’s auth re-check and login recovery readcmd:envas it is. - resolve_
named 🔒 - The agent a person or agent named: by id or slug, else by the display name the panes show (“Camper-2”) when exactly one agent has it.
- set_
pending 🔒 - settle 🔒
- What a switch does when its window ends: as it would have without one. A turn still running waits for
its end, unless the switch ends turns (
now: the caller saidwhen: now, or the person pressed “Switch now”). BLOCKING. - stop_
turn 🔒 - End the pane’s turn by replacing its process. A forced resync of a persistent pane in a turn
only defers the restart to the turn’s end, which is
after_turn, notnow. - switch 🔒
agent.account.switch.calleris the connection’s agent slug, empty for the window. BLOCKING (store reads, link writes, restarts).- switch_
all_ 🔒limited - Move every agent that has a pane out of quota (a usage limit that hasn’t reset) to
req.account(any with quotais chosen per agent, so each lands on an account that can run). One agent that can’t move doesn’t stop the others.req.agent_idis ignored. BLOCKING. - switch_
to 🔒 - Move the agent
def_idtoto(a signed-in account ofprovider;accountsare all of the provider’s, for the labels): at once, or queued while a pane of it is in a turn. Also the door for the account strip’s move of a whole episode (moves::move_agents). - tell_
signed_ 🔒out - Tell the panes of
signed_out(whose last turn failed on the login the move left) that they are signed in, now that each has restarted on the new account: before the restart the note would reach the old process, still on the expired login, and mark a turn active that defers or kills the restart. A pane that didn’t restart is not told: it keeps its failure’s notice and runs on the new account when it next starts. The login-expiry failover tells its own interrupted panes (super::login_expiry::resume).