Block meta: whether the agent should be running, running or stopped. Open, start and a
message that starts it set running; an explicit stop sets stopped.
Held while a desired state is decided and written, so the record in STOPPED_THIS_RUN and the
block’s meta change together: a conditional start (set_running_unless_stopped_since) cannot
overwrite a stop that lands between its check and its write. Never held across a store
transaction’s own work (nothing inside one calls these).
The blocks whose agent was set to stopped since this srv started and not started again, and when
(unix ms). A recorded stopped read from the database at startup is not in it: it may be stale
(something started the agent without recording it), while one in here was decided in this run, so
it is binding.
The controller an agent’s pane runs. A container agent’s turns are docker execs of a subprocess
controller, whatever its provider defaults to (claude’s is persistent, which skips the container exec).
Register the block’s controller when it has none (a pane the frontend made, or a parked block
after a restart), resuming the agent’s session. With revive, a controller whose process has
ended is resynced too, which resumes it (a start, or an open with the setting on). tab_id is
empty for a parked block.
Bring the window to the pane that shows block_id in tab_id: block.reveal makes it its pane’s
visible member and tells its window to restore, un-magnify and focus it; where that finds no open
window, its tab is made active and its pane focused here.
What agent.open (or a start, headless) does when the agent already has a block. The agent has one
pane: super::agent_block::decide_agent_pane says which, and every path that would add one asks it,
so no open makes a second (task #5419):
Record the agent’s desired state on its block. Best effort: a failed write costs a restart’s
resume, not the start or stop itself. A stopped is logged with the caller that decided it: an
agent that comes back from a restart stopped has to be traceable to the code that stopped it.
Record the agent as wanted running, unless a stop was decided as, or after, started_at_ms: the
turn that began then is the one the stop ended or the agent quit in. The check and the write are one
step against set_desired, so a stop that lands in between is not undone. Returns whether it wrote.
Start the agent with no pane: its block (made and parked if it has none) with its process running
and its session resumed. Returns the block. Admission, the spawn gate and the lease apply as for
agent.open. Needs an active tab to create a first block in.
start_agent that never stops another agent to make room: over the cap or the commit limit it is
refused (Err("capacity: ...")). Restart resume starts the agents that were running this way.
The tab agent.open works in, or the agent’s existing pane when it has one (Err: nothing more to
do). A start of a terminal-tier CLI is refused: its term view starts it, and a start
has none. A start needs no tab to run an agent that already has a block, so with no tab left it only
reuses that block; a first block still needs a tab.