Expand description
Prepare, then proceed (SPEC_AGENT_PREP_BEFORE_SESSION_RESTART_2026_11_14.md §3): when a user action is about to restart an agent’s session, the agent gets a short window to reach a safe point and leave a handoff, then the action runs.
An action calls [decide]. Skip means nothing is lost or the agent cannot take a turn: the
action runs at once, as it always did. Ask means open: one [AgentMux] note starts a turn
on the agent, the agent answers with Agents ready (a handoff, or once for more time), and the
action’s closure runs when the agent has answered and its turn has ended, when the person presses
“Switch now”, or when the window runs out. A window, never a gate: nothing waits for an agent that
cannot answer, and the closure runs exactly once.
Re-exports§
pub use carry::hold_for_other_panes;pub use decide::decide;pub use decide::Decision;pub use handlers::handle_ready_self;pub use handlers::register;pub use ledger::cancel;pub use ledger::is_open;pub use ledger::open;pub use ledger::open_with;
Modules§
- carry 🔒
- Where the handoff an agent left goes once its session has restarted (spec §3.4). A persistent
Claude pane reads it in its own spawn (
carry_prep_handoff), as the first section of the packet or a held note. A pane of any other controller (a subprocess, ACP or app-server agent) has no such step, so the action that restarted it hands the handoff over here, as a note held for the pane’s next message. - decide 🔒
- Whether an agent is asked at all (spec §3.2). Only one that has something to lose and can take a turn to say so; for every other agent the action runs at once, as it did before this existed.
- handlers 🔒
- The two ways a window is answered from outside: the agent’s
Agents ready(POST /api/v1/agent/self/ready) and the person’s “Switch now” (agent.prep.now). - ledger 🔒
- The open windows, one per agent. A window is read and changed under the lock and nowhere else, and
its closure is taken out under the same lock by the window’s task alone, so it runs exactly once
however
Agents ready, “Switch now”, a cancel and the deadline race. - meta 🔒
- The pane meta a pending change shows through. The composer’s chip reads it live, and it outlives a window reload, as the queued account switch’s own meta does.
- note 🔒
- The words the agent is sent (spec §3.2). One
[AgentMux]system note that starts a turn: nothing else can forge the marker (sanitize::neutralize_markers), and it names who asked and what will happen, never asking for approval. - window 🔒
- One window’s task: ask the agent, then wait for whichever comes first (spec §3.5). It is the only place a window’s closure is taken and run, so it runs once, and the deadline is the one thing that always ends the wait: no state of the agent holds the person’s action back.
Structs§
- Prep
- What a user action asks of the agent before it restarts the agent’s session.
Enums§
- How
- How the window ended.
Constants§
- AUDIT_
ANSWERED - AUDIT_
REQUESTED - The audit actions: one when the agent is asked, one when it has answered or the window ended.
- EXTENDED_
WINDOW - The one extension an agent may ask for (a push or a deploy in progress), from the same moment.
- META_
PREP - The pane meta the composer’s chip reads:
{id, until_ms, extended, why, action}. - WINDOW
- How long the agent has, from the person’s action.
Type Aliases§
- Proceed
- What the action does once the window ends. Runs exactly once, on a blocking thread.