Skip to main content

Module switch

Module switch 

Source
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§

AccountSwitchAllEntry
One agent’s outcome in an all limited switch.
AccountSwitchAllResult
Identity switch with the agent all limited: every agent with a pane out of quota.
AgentAccountSwitchReq
agent.account.switch.
AgentAccountSwitchResult

Enums§

AccountSwitchStatus
What agent.account.switch did.
AccountSwitchWhen

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_id launches on: its own, or its bundle’s when it has none.
apply 🔒
Link agent to to and restart each of blocks on it. actor is recorded. now ends 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_pending from the pane’s own meta, without a window.
is_all_limited
Whether agent is the target all 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_out to tell: those in restarted, and none when actor is the login-expiry failover.
prep_of 🔒
receiving 🔒
The account account_id as 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:env config-dir variable at to. The spawn injects the linked account over it, but the window’s auth re-check and login recovery read cmd:env as 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 said when: 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, not now.
switch 🔒
agent.account.switch. caller is 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 quota is 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_id is ignored. BLOCKING.
switch_to 🔒
Move the agent def_id to to (a signed-in account of provider; accounts are 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).