Expand description
What state every created agent is in, with or without a pane: agentruntime.list, the
agentruntime:changed:<agent id> event that carries a change, and agent.start
(the always-available agents spec, §3.4 and §5).
One source: the availability view (availability_view, which is what a message to the agent
asks), mapped onto the states a viewer sees. An agent with no live pane is stopped; its row
comes from its definition. A viewer (the Swarm) lists the rows once, then follows the event.
A pane whose process ended keeps its block_id (found by the block’s agent id) and reads stopped.
Two things a viewer must not wait for until the always-available agents build lands: starting
is never produced (a controller just created, with no process yet, reads as idle), and no event
says an agent was deleted (changed_rows only forgets it), so a viewer relists on agents:changed.
An agent wanted running with no process reads idle, not stopped: a persistent agent with no
session on file starts on its first message, and an agent that has only ended its process is
started by the next one. The failure states (limited, signed out, waiting) keep their place.
An agent between turns whose Browser request is still open reads waiting_on_user (browser_request,
with the pane the request waits in): its call answered “waiting” and it ended its turn, so nothing else
says the person is asked. Only what a viewer sees: the availability a message asks is unchanged, so a
message still starts a turn. The same fact is kept in the block’s term:awaiting_browser for the rows
that read block meta (the Swarm’s).
desired is the agent’s own desired state when its block records one (agent:desired, set by an
open, a start and a stop), and otherwise running while a process is alive and stopped if not.
Structs§
- Agent
Runtime - One agent’s runtime state, with what a row needs to show it before it has a pane. The payload of
agentruntime:changed:<agent id>and a row ofagentruntime.list. - Agent
Start Result - What a start gave: the block the agent runs in (the parked block, for an agent never opened).
- Command
Agent Start Data agent.start.
Enums§
- Agent
Desired State - Whether the agent should be running (spec rule 5).
- Agent
Runtime State - The state of one agent as a viewer sees it.
Constants§
- BROWSER_
REQUEST - Why an agent between turns reads
waiting_on_user: a Browser request of its is still open. - LOOK_
EVERY 🔒 - How often the runtime states are looked at for a change.
- META_
AWAITING_ BROWSER - Block meta, true while the agent’s row waits on a Browser request (the Swarm row reads block meta).
- STARTS_
ON_ FIRST_ MESSAGE - Why an agent wanted running with no process reads
idle(state_of’s reasons are codes too).
Functions§
- agent_
of_ 🔒block - The agent a block belongs to, by the id its meta carries.
- begins_
waiting 🔒 - Whether
rowjust began waiting on the user: it is waiting now and was not at the last look. An agent with no block has nothing to notify about, and a Browser request was announced by its own banner, on the Browser pane, under the person’s setting for it. - block_
color 🔒 - The colour the agent’s pane shows (its border colour,
frame:activebordercolor, set when it opens). - blocked_
start 🔒 - Why a start would be refused, for an agent that is stopped and wanted running: its block says running,
or a message waits for it.
whyis asked only then, because it reads every live agent. - browser_
flag_ 🔒fix - What to write to the block’s
META_AWAITING_BROWSERso it says what the row says, if it does not. - browser_
flag_ 🔒fixes - The blocks of
rowswhoseMETA_AWAITING_BROWSERdoes not say what the row says, with what it should say. Blocking: reads the store. - changed_
rows - The rows that differ from what was last sent, and what to remember now: an agent that is gone is forgotten.
- desired_
from - What the agent’s block says it should be doing, when it says: a stop sets
stopped, an open or a startrunning. An agent whose block records nothing is wanted as its state says. - desired_
of - A process is alive in every state but these two.
- ends_
waiting 🔒 - The block an agent was waiting in, when it just stopped waiting (answered, cancelled or ended): the block of the last look, which the row may no longer name.
- error_
reason - Why an agent in
erroris, when its last run’s failure was classified (rate_limited,network…): whether it is worth another try is not inerroritself (#2617). - list 🔒
- The runtime state of every created agent, as of
now_ms. Blocking: reads the store. - mirror_
browser_ 🔒wait - Keep each changed row’s block meta saying whether it waits on a Browser request. Every row is a change at the first look after a start, so a flag a stopped srv left behind is taken down then.
- notify_
waiting 🔒 - “Waiting on you” as an OS notification, for an agent no pane need show (a headless or parked one): the router coalesces it with the question’s own report for the same block, so it adds nothing when the question already notified, and covers a wait that had no such report (an App Server approval).
- pane_
blocks_ 🔒by_ agent - The block of each agent that has one, by agent id: the one in a pane (the first by id when it has several), else the one parked in no tab, which holds the agent’s desired state while it has no process. One pass over the blocks for the whole list.
- register
- request_
pane 🔒 - The pane where the open Browser request of the agent bound under
nameswaits. A request carries the name its call used, which is one of the names the agent’s block is bound under. - resolve_
waiting 🔒 - Take down the notice
notify_waitingraised, so a wait that ended before it showed does not show a stale question, and the next wait on the block is a new notice and not coalesced into the old. - runtime_
of - What a viewer sees of an agent from its status: the state, why, when a limit lifts and what is
wanted. The one place the availability, the wanted state and the controller meet (
state_of,desired_fromandwanted_running_is_idleare its steps). - runtime_
of_ 🔒agent - Where an agent runs: its pane’s mode is the current truth; a definition with no pane says it by its type, so a stopped agent has an answer too.
- spawn 🔒
- Look at the states on a short interval and publish each change to
agentruntime:changed:<id>. - state_
of - The state, its reason and its reset, from what the availability view says.
- waiting_
on_ browser_ request - An idle agent with an open Browser request is waiting for the person. Only an idle one: an agent that works is working (a message started another turn), and one that cannot work says that first.
- waits_
on_ 🔒browser_ request - wanted_
running_ is_ idle - What a viewer sees of an agent that the availability view calls stopped but its block says should
run and a controller holds: it is waiting for a message to start it, which is
idle. With no controller (the server restarted and nothing resumed it yet) it staysstopped: the Swarm lists only controller-backed agents as live, so an idle row there would be listed nowhere, with no Start.