Skip to main content

Module agent_lifecycle

Module agent_lifecycle 

Source
Expand description

Agents start, stop, detach and delete (POST /api/v1/agent/{start,stop,detach,delete}): an agent runs, stops, leaves its pane or is deleted without the operator’s window (a stop of another agent keeps its override window) (docs/specs/SPEC_ALWAYS_AVAILABLE_AGENTS_2026_10_27.md §5.1). Each acts as the agent its token names; a request without one is refused, so a change is never attributed to the operator, and each one, and each refusal, is recorded in the audit log under the calling agent.

  • start: agent_attach::start_agent, the one start path (admission, the spawn gate and the lease apply), after the per-sender start limit (start_rate). Running already is not a start.
  • stop: agent_teardown::stop, which also records the agent as wanted stopped. Not your own agent: Stop self is the way to end yourself. Another agent’s stop waits for the person’s 30 s override window, like Stop agents (fleet_stop_keep_pane_with_override); a worker the caller opened is stopped at once.
  • detach: the agent’s pane closes and its block is parked, whatever agents:always_available says (the setting decides what closing a pane does; this is the explicit action).
  • delete: only an agent the caller made (Agents create, or a worker it spawned), only when it is stopped and has no open pane, never the caller itself; the same deletion the window’s Delete does.

Structs§

Actor 🔒
The agent making the request.
LifecycleRequest 🔒
Refusal 🔒

Functions§

acting 🔒
Who acts: the calling agent, or, for a request that carries no agent token (the person at the UI), that person acting through the agent named: its leader, or the agent itself when it has none (the agent whose key signs what is sent to another computer). A person must name the agent.
actor_of 🔒
answer 🔒
audit 🔒
delete 🔒
delete: the agent definition goes, with its container storage. Only for the agent that made it, and only once it is stopped and shows no pane: a running agent is stopped first (Agents stop), which for another agent’s agent is the person’s call.
delete_answer 🔒
Agents delete’s answer: what went, and that the workspace folder did not (with where it is).
detach 🔒
handle_agent_delete 🔒
handle_agent_detach 🔒
handle_agent_start 🔒
handle_agent_stop 🔒
is_running 🔒
Whether a start has nothing to do. A turn in flight is a process, whatever was recorded. In the states that do not say (idle, and limited or signed out, which show over an ended process) the explicit stop settles it: a subprocess agent that was stopped reads idle because its process exits between turns, and a stop is not undone until a start or a message sets it running again.
kept_workspace 🔒
The folder an agent worked in, when it is on this machine. A delete leaves it: it may hold work that was never pushed, and deleting an agent is not a reason to lose it. (A new agent made with the same name gets this folder again, clone and all, unless its owner removes it first.)
may_have_process 🔒
Whether a stop has anything to stop: any state with a process may be one, so the teardown decides, not the recorded intent (a message to a stopped agent can run it again without clearing that).
needs_window 🔒
Whether caller stopping target waits for the person’s override window: always, except for itself and for a worker it opened (agent_spawn::worker_of).
refuse 🔒
row_json 🔒
What the answer says about the agent now: its state (re-read after the change).
run 🔒
run_as 🔒
run_remote 🔒
start or stop of agent for an agent on another machine (remote_ops::agent_ops): the same code a local call runs, with who (slug@machine) as the actor. Such a caller owns no worker here, so a stop of another agent always waits for the person’s override window.
start 🔒
stop 🔒
target_of 🔒
The agent named, as its runtime row: an id, slug or name of an agent created on this machine. A template is not an agent.