Skip to main content

Module agent_state

Module agent_state 

Source
Expand description

Whether each agent is working, waiting on the user, idle, stopped or failed, and since when: the agent_status the LAN fleet feed, GET /agentmux/reactive/agent-names and (through the feed’s snapshot) the cloud presence record carry (agentmux-mobile’s SPEC_AGENT_STATUS_AND_LIVE_PANE_FEED_2026_10_07 §3, §13.1).

decide is the rule, pure; current_state reads its inputs from the block’s controller and the block’s meta; a SinceTracker remembers when each block’s state began. Every caller goes through agent_status_of_block or a SinceTracker of its own, so the feed and the names route agree on since_ms.

limited and signed_out are an agent that is alive but can’t work: its last run ended on the plan’s usage limit or a refused sign-in (docs/specs/SPEC_UNRESPONSIVE_AGENTS_2026_10_23.md §3). Read them through unavailable_of_block, so no caller re-derives the rule.

Structs§

AgentStatus
A state and when it began (unix ms, this machine’s clock).
SinceTracker
When each block’s current state began. A state seen for the first time (srv start, a new agent) begins when it is seen; a state that changes begins again; None forgets the block, so a stopped and restarted agent does not inherit an old start.
StateInputs
What decide looks at, as read from the controller and the block.
StoredFailure
The parts of a block’s agent:last_failure the states read. Only these fields: the stored failure leaves out empty ones that reading the whole AgentFailure back would require.
Unavailable
An agent that is alive but can’t work, and why.

Enums§

AgentState
An agent’s state as the wire reports it.

Constants§

LAUNCH_BLOCKED_AT_META_KEY
When (unix ms) the launch stopped there.
LAUNCH_BLOCKED_META_KEY
Written by the agent pane’s launch when it stops at “needs sign-in”, and cleared once the pane registers its controller. Such a pane has no controller, so nothing else says why: a message to it failed with “no controller for block” instead of being held for the sign-in (current_state_at, unavailable_of_block).
LAUNCH_BLOCKED_SIGN_IN
The LAUNCH_BLOCKED_META_KEY value for a launch waiting on a sign-in.
META_AWAITING_USER
Block meta the agent pane sets while a question waits for the user.
RUN_ACCOUNT_META_KEY
The account a pane’s run launched on, written at spawn (build_persistent_spawn_env), so a failure that run records counts against that account even after the agent is linked to another (run_accounts_of_block).

Functions§

agent_status_of_block
The agent on block_id: its state now and since when.
change_wakes_held
Whether a change from from to to can make a held message deliverable: the agent left a state that held messages (out of quota, signed out, not running), or a session that had gone quiet took a turn (a cold session warming). The one place a state change wakes the held-message replay, so a path that forgets its own wake is still covered.
current_state
The block’s state now: its controller’s runtime status and the block’s term:awaiting_user and agent:last_failure. None without a controller (unless its launch stopped at “needs sign-in”: signed_out), or when the block can’t be read.
current_state_at
current_state at now_ms.
decide
The state, or None when nothing tracks this agent’s turns (a terminal pane: shell / cmd, or any controller that isn’t an agent’s) or its process state is unknown. Saying nothing beats a wrong idle.
failure_of_block
The block’s stored failure, or None when it has none (or one this build can’t read).
global_tracker
The tracker the live fleet source and the names route share.
in_turn
Whether the agent in block_id is in a turn: working, or waiting on a question. The one definition of “not between turns”, for everything that waits for a turn to end before it restarts a pane (an account move, a prepared change).
run_accounts_of_block
The accounts a pane’s run counts against: agent:run_account, the account it launched on; a pane from before that key falls back to its agent’s current links. One rule for the spawn gate’s account_blocks, unavailable_of_block and the account episodes.
state_and_unavailable
The block’s state now and, while it is limited or signed_out, why.
unavailable_of_block
Some when the agent on block_id is limited or signed_out at now_ms. With identity, a pane from before agent:run_account gets its agent’s current account link.