Skip to main content

Module fleet

Module fleet 

Source
Expand description

Fleet control — select, broadcast, and bulk-act on many agents at once. See docs/specs/SPEC_MULTI_AGENT_FLEET_CONTROL_2026_08_20.md.

fleet.broadcast/fleet.bulk-stop are thin server-side loops over the EXISTING single-target primitives (ReactiveHandler::inject_message, agent_io::stop_one_agent_block) — no new transport is invented, and every action returns FleetActionResult (succeeded/failed per target), never a single bool, per the spec’s §3 finding that silent partial failure is the single most commonly-cited fleet-ops UX failure mode.

fleet.broadcast is deliberately WS-RPC-only (the human/Swarm-UI path), not exposed over HTTP to agentmux-mcp. It is NOT a jekt: a broadcast is the human typing once to several panes, so each target gets a message routed the way an inter-agent message is (bootstrap::route_agent_message: persistent, ACP and App Server on their own channel, a subprocess or unspawned agent via run_agent_turn) with a one-line [BROADCAST:FROM=user VIA=swarm ...] header from reactive::broadcast_turn_message, instead of a self-declared jekt from unknown. See docs/specs/SPEC_SWARM_BROADCAST_AS_USER_MESSAGE_2026_10_01.md. The turn is MessageOrigin::broadcast() (a User turn): a broadcast is the human’s own message, with the same powers as typing it into each pane, including authorizing an agent’s self-quit (owner decision 2026-10-06, spec §6 q2). The one exception is App upgrade: it is once per machine, so a broadcast doesn’t count and the user is asked (self_quit::gate_upgrade, owner decision 2026-10-23). That adds no power to anything holding the pane key, which could already send any pane a plain User turn through agent.input (spec §2 finding 7, §4.2). srv, not the text, still decides: the label comes from this module only. A target running on another channel on this machine is reached over loopback, the way a stop is (forward_broadcast_to_channel): the sender passes only the target block, the body, the MSGID and the RECIPIENTS count, and the receiving instance builds the header and starts the turn itself (deliver_forwarded_broadcast). An agent on a LAN peer can’t get a user turn: nothing on the LAN proves who is asking (docs/specs/SPEC_SWARM_REMOTE_AGENTS_PLATFORM_TAG_AND_SELECTION_2026_10_03.md §6). It gets a jekt from this instance instead, signed with this instance’s own LAN key, which its instance verifies as it does any agent’s (backend::lan::swarm_broadcast, SPEC_SWARM_REFINEMENTS_2026_10_17.md §4.2). The forward uses the same loopback auth as the stop forward, and reaches only what that channel’s own fleet.broadcast already does. An AGENT-initiated broadcast instead loops the EXISTING signed single-target Message send path client-side (Message broadcast in agentmux-mcp) — srv mints, stores and serves each agent’s keys and the agent’s MCP signs with its copy, so per-message signing happens there, never in a server-side batch RPC. fleet.bulk-stop has no such constraint (a controller stop involves no jekt signing at all, same as agent.stop today) and IS exposed over HTTP (POST /api/v1/fleet/bulk-stop) for FleetBulkStop.

Structs§

BroadcastForward 🔒
What a forwarded broadcast carries. No header text: the receiving instance writes the header, so a caller on loopback cannot supply its own.
BroadcastOutcome 🔒
What happened to one target of a broadcast.
LanSender 🔒
What every LAN delivery of one broadcast shares: this instance’s sender name and key, or why it can’t sign.

Enums§

BroadcastAction 🔒
What to do with one target, given how its controller routes a message.
BroadcastRoute 🔒
How one broadcast target is reached.
Forwarded 🔒
What asking another instance’s user came to.

Constants§

FLEET_BROADCAST_AUDIT_ACTION 🔒
FLEET_BULK_STOP_AUDIT_ACTION 🔒
NO_REGISTERED_AGENT 🔒

Functions§

ask_other_instances 🔒
Ask each target’s own instance (a target running on another AgentMux on this machine) to open its override window, all at once. close: ask for the tab to close (Stop agents) rather than only stop (the migration). The third answer lists the targets of a close that an instance predating the override only stopped at once, leaving the pane open.
broadcast_action 🔒
Maps route_agent_message’s answer to an action. A PTY-based target is refused rather than typed into: a broadcast is prose, and keystrokes into a shell prompt would run it as a command.
deliver_available 🔒
deliver_broadcast_turn for an agent that can work: the words go as a turn of the person’s.
deliver_broadcast_turn 🔒
Delivers one broadcast text to one block the way an inter-agent message reaches it (route_agent_message_from): structured controllers (persistent, ACP, App Server) take it on their own channel, which also steers a turn already running; a subprocess or not-yet-spawned persistent agent gets a turn started with origin. Either way the turn is labelled with origin where the controller tracks provenance at all (persistent and subprocess, the same agents a typed message can authorize a self-quit on).
exceeds_fail_threshold 🔒
batch_failures / batch_len (as a percentage) exceeds max_pct. Cross-multiplies instead of computing a truncated integer percentage first — batch_failures * 100 / batch_len rounds DOWN before comparing, so e.g. 1 failure in a batch of 3 (33.3%) reads as 33 and never exceeds max_pct = 33, silently missing the threshold it was meant to catch (Codex P2, PR #2687 review). batch_failures * 100 > max_pct * batch_len is the same inequality with no rounding.
fleet_broadcast_impl 🔒
fleet_bulk_stop_impl 🔒
fleet_close_agents_with_override 🔒
Stop agents, from an agent: close each target agent’s tab, as the user’s tab × does, after the same 30 s override window as any other shutdown the user didn’t ask for (docs/specs/SPEC_STOP_AN_AGENT_ONE_WAY_AND_SHUTDOWN_TOAST_2026_10_23.md §3.1). The targets no request covers yet share one window, with one notification and one audit entry (request_batch), and the user can keep any one of them; a target that already has a window joins it. Only that agent’s tab closes, so an agent stacked in the same pane keeps running.
fleet_stop_keep_pane_with_override 🔒
Stop agents and KEEP their panes, behind the user’s 30 s override. Internal only, since Stop agents closes the tab (fleet_close_agents_with_override): the fork slug migration, which restarts the agents in the same panes, and Agents stop of another agent are its callers. Every target running on this instance waits for its user’s 30 s override, all windows in parallel (docs/specs/SPEC_AGENT_SELF_QUIT_2026_09_24.md §6.5). A target running on another instance on this machine is asked there, in that instance’s own window (forward_stop_pending). Targets running nowhere go through fleet_bulk_stop_impl as before, staged included.
fleet_stop_keep_pane_with_override_opts 🔒
fleet_stop_keep_pane_with_override with the caller’s explicit stop_background (None: the user’s setting), carried through the window to the stop.
forward_broadcast_to_channel 🔒
Asks the instance at local_url (another channel on this machine, its auth_key from the shared registry, same user) to deliver one broadcast. A channel from before the route answers 404 and is named as such, for that target only.
forward_stop_pending 🔒
A cross-channel FleetBulkStop target: ask ITS instance’s user (/agentmux/agent/stop-pending), whose banner, chime and Keep running are the ones that user sees. The request’s status is served from there; pending_shutdown::remember_remote lets this instance proxy it. An instance without that route (404) gets the plain forward it always did.
forward_stop_to_shared_channel 🔒
Stops targets (block ids) via the existing single-target stop_one_agent_block, one call per target, and — unlike that single-target primitive, which involves no jekt signing and so was never audited — records one AuditLogEntry per target via ReactiveHandler::log_fleet_action_audit, so the Audit pane sees every fleet-initiated stop (SPEC_MULTI_AGENT_FLEET_CONTROL_2026_08_20.md §6; reagent/Codex P2, PR #2687 review — this was missing entirely). Without staged, runs every target as a single batch (still returns full per-target detail, never a bool). With staged, targets are stopped batch_size at a time; if the failure rate WITHIN a completed batch exceeds max_fail_percentage, remaining targets are recorded as failed (untried) and aborted_early is set — caps blast radius on a bad selection rather than plowing through every remaining target. aborted_early is only ever set when targets were genuinely left unattempted — tripping the threshold on the LAST batch (nothing left to skip) must not report “aborted early” when the full list actually ran (reagent P2, same review). Look up block_id in the shared cross-channel registry (this host, other channels — same registry server/reactive.rs’s inject cascade tier-2b already reads) and forward a stop request over loopback HTTP to that channel’s own srv (/agentmux/agent/stop), using its own auth_key from the registry entry — identical trust model to the inject cascade’s own cross-channel forward (same host, same user).
register
register_fleet_broadcast 🔒
register_fleet_bulk_stop 🔒
register_fleet_group_create 🔒
register_fleet_group_delete 🔒
register_fleet_group_list 🔒
register_fleet_group_update 🔒
run_broadcast 🔒
The broadcast logic, with srv’s two touch points passed in so it can be tested without an AppState: resolve maps a block id to its agent id, and deliver starts one turn (block id, full text, origin).
shared_channel_for 🔒
The shared cross-channel registry entry for block_id on ANOTHER instance on this machine: loopback only, never this instance itself.
wait_for_remote_window 🔒
Wait for the other instance’s user to let its keep-running window run out (or keep the agent running).
watch_remote_window 🔒
A close asked of another AgentMux on this machine: its user’s window runs there, so this instance watches it and tells by by note if that user keeps the agent or the close fails.