Expand description
What keeps agents that outlive their pane from piling up
(docs/specs/SPEC_ALWAYS_AVAILABLE_AGENTS_2026_10_27.md Β§7, D5 and D6; P4a). With
agents:always_available on, closing a pane no longer stops its agent, so two limits stand in for
the pane:
- Idle stop (D5). An agent with no view (its block is parked) that has been idle for the window
(
agents:idle_stop_minutes, default 60, 0 = never;agent:idle_stop_minuteson its block overrides it) is stopped by a sweep once a minute. It stays addressable: a message starts it and resumes its session (jekt_start). Never stopped: an agent in a turn, one waiting on the user, one that holds a claimed Kanban task or has a held message, or one that holds the build slot. - Cap (D6). A start (
agent_attach::start_agent:agent.start, a message, a Job) is admitted while fewer thanagents:max_running(default 24, 0 = no cap) agent processes run and, on Windows, commit use is underagents:commit_limit_pct(default 85, 0 = off). Over either, the agent idle longest with no view is stopped to make room; when none can be, the start is refused withcapacity:and a message stays held.
An agent that is shown in a pane is never stopped by either: it has a view. Off, none of this runs.
StructsΒ§
- Live π
- A running agent process and what the policy needs to know about it.
- Policy π
- The limits, from settings.
None: that limit is off. - Wanted π
- An agent a batch would start: the key its room is held under (its id, or a stand-in while it does not exist yet) and the name a refusal gives it.
EnumsΒ§
- Over π
- Which limit a start is over, and why.
ConstantsΒ§
- COMMIT_
FREED_ πBY_ ONE_ STOP_ GB - What stopping one idle agent frees, in GB of commit: a
claude.exeholds about 1 GB of private commit (agents::runner::DEFAULT_AGENT_COMMIT_RESERVE_GBhas the measurement). - DEFAULT_
COMMIT_ πLIMIT_ PCT - DEFAULT_
IDLE_ πSTOP_ MINUTES - DEFAULT_
MAX_ πRUNNING - META_
IDLE_ STOP_ MINUTES - Block meta: this agentβs own idle window in minutes (0 = never stop it).
- PENDING_
FOR π - How long an admitted start counts as running before its process shows as such.
- SETTING_
COMMIT_ LIMIT_ PCT - SETTING_
IDLE_ STOP_ MINUTES - SETTING_
MAX_ RUNNING - SWEEP_
EVERY π - How often the idle sweep runs.
FunctionsΒ§
- admission π
- One admission at a time: the count, the stop that makes room and the claim of the room are one step.
- admit π
- admit_
batch π - May all of
wantedstart? A batch never stops an agent to make room (a start may stop one idle agent with no view; five of them stopping five would be a mass stop nobody asked for), and it is admitted whole or refused whole. Those already running need no room. Withreservethe room is claimed under the same lock as the check, so a start that comes between this and the batchβs own cannot take it;release_batchgives it back when the batch is done or failed. - admit_
batch_ πwith - admit_
start π - May
agent_idbe started? Yes when it already runs, when nothing is over a limit, or when an idle agent with no view can be stopped to make room; otherwiseErr("capacity: ..."). - admit_
start_ πwith - admit_
start_ πwithout_ eviction admit_startfor a start that must not cost another agent its process (restart resume): over a limit it is refused withErr("capacity: ...")whereadmit_startwould stop an idle agent to make room. The check and the claim of the room are one step under the admission lock.- batch_
held π - The reservations a batch made (
admit_batch): only these let their agentβs start through without counting the room again, and only once. An ordinary reservation (a start that was admitted) does not, or an agent started, stopped and started again withinPENDING_FORwould skip the cap. - build_
slot_ πholder - The agent that holds the hostβs build slot (
~/.agentmux/shared/locks/build-slot.sh), if any. - commit_
over π - The commit use and limit (percent) when use is over the limit, whichever limit
over_limitnames first (it names the cap before commit): a stop for the cap is as useless as one for commit when commit use is past what one stop frees. - commit_
total_ πgb - The commit (GB) the host can hold in all, where it reports one (Windows:
GlobalMemoryStatusEx). - commit_
used_ πpct - Commit use as a percentage of the commit limit, where the host reports it (Windows:
GlobalMemoryStatusEx).Noneelsewhere: Linux overcommits and macOS has no commit limit, so no figure means no refusal. - exempt π
- Why this agent is not stopped even when idle: it holds a claimed Kanban task, has a message held
for it, or holds the build slot.
None: nothing keeps it. - exempt_
agent π exemptfor the agentuid, whose slug (else its id) isagent_id: what a Kanban claim and the build slot name.- holder_
in π - The
agent=line of a build-slot owner file. - idle_
from_ πview_ lost - Move each parked agentβs
since_msup to when it was first seen parked, and forget blocks that are shown again or gone. A sweep sees a paneβs closing within a minute, so the window can only run long. - idle_
override_ πof - The blockβs own idle window:
Some(None)never stop it,Some(Some(ms))its own window. - idle_
window_ πof - The idle window that applies to
block: its own, else the default (None: no window). - install π
- Run the idle sweep once a minute.
- is_
reserved π - Whether
agent_idholds a reservation that has not run out. - live_
agents π - The agent processes running now, one per agent block that has a live controller.
- names_
in_ πwords - βAβ, βA and Bβ, βA, B and Cβ.
- one_
stop_ πbrings_ commit_ down - Whether stopping one idle agent can bring commit use down to the limit.
Errsays how much has to go and that nothing was stopped, so a start that stops an agent for nothing is never made. With no total to size the shortfall against (non-Windows, or a failed read) it cannot tell, and the stop goes ahead. - over_
limit π - Whether the host is at its cap or over its commit limit, given the agents running.
- pending π
- pending_
key π - The key of an admitted start: per store, so two instances in one process (tests) do not count each other.
- pending_
not_ πrunning - The admitted starts of this instance that are not yet running and not yet
PENDING_FORold. One seen amongliveis dropped for good: it counts as itself from then on, and if it is stopped to make room it must not count a second time. - policy π
- rekey_
reservation π - The room
admit_batchclaimed under the stand-in keyfromis now the agenttoβs, in one step: a batch that makes its agents as it goes (spawn) keeps its room under stand-ins until each exists, and the agentβs own start must find its room reserved, not count it against itself. - release_
batch π - Give back the room
admit_batchclaimed forwanted: the batch is done (its agents run, and count as themselves) or failed. - release_
start π - A start that was admitted did not happen (the agent is unknown, its provider has no headless mode, its CLI is missing): its room is free again.
- running_
agent_ πids - The ids of the agents running in this process: the only ones whose memory folders it looks at
(
native_drift::OwnedAgents).Live::uidis thedb_agentsrow id, the same id as the agent definition and the memory roster (AgentInstance::id == definition_id,row.rs). - start_
blocked π - Why
agent_idβs start would be refused now:admit_startwithout its side effects (it stops no one and claims no room), so a sender is not told βstartingβ about a start that will not happen.None: it would go ahead, or no limit applies. - start_
blocked_ πwith - stop π
- Stop
livethe way an explicit stop does (its process; the block, the transcript and the session stay). - stop_
note π - The words of a note to the lead of an agent that was stopped to make room for anotherβs start: who, why, what it was working on (its goal, cut short), and how to get it back.
- sweep_
once π - One idle sweep: stop each agent with no view that has been idle past its window and that nothing keeps running. Returns how many were stopped.
- take_
batch_ πclaim - Whether
agent_idβs start is the one a batch reserved room for, taking that claim: the next start of the agent is counted as any other. - tell_
leader_ πof_ stop - Tell the stopped agentβs lead (see
worker_notes::tell_leader) that admission stopped it: losing an agent in silence is what this exists to prevent. - view_
lost_ πat - When each parked agent block was first seen without a view (ms). The agent-state tracker times how long a state has lasted, shown in a pane or not; the idle window is for the time with no view.
Type AliasesΒ§
- Reservation π
- Starts admitted but not yet seen running, so a burst of starts counts each other.
Each entry holds a
Weakto its instanceβs store: that keeps the storeβs address from being reused while the entry exists, and an entry whose store is gone (a testβs) is dropped.