Expand description
What an agent has running in the background while no turn is in flight
(docs/specs/SPEC_AGENT_STATE_BACKGROUND_WORK_2026_11_01.md §5, §9 step 1).
Shadow only. This decides nothing yet: no state, no surface reads it. Every
[SAMPLE_EVERY_MS] the fleet look hands over the agents that read Idle, and for each this works out
the set it would call Background and logs when an agent enters or leaves it (target
background_shadow), with a count for App health to read later (shadow_counts). A week of that
log sets the denylist and the grace period (D7) before the state is switched on.
Two sources in this step: the declared background shells (db_background_tasks rows still
running) and the process trees an agent left behind (the pane’s tracker). Background subagents and
Monitor come with the state itself (the Monitor’s task type is not verified, §5).
Structs§
Enums§
Constants§
- GRACE_
MS - A process tree counts once it has run this long: a command that is about to finish is not background work.
Functions§
- for_
block - What the agent in pane
block_idhas running in the background now: its declared background shells and the process trees its calls left behind, past the grace period and not a daemon on the denylist. Empty when none, or when the tracker or the store is not up. Blocking: reads the tracker and the store. - from_
tasks - The declared background shells that still run: a row counts while its pid is in the tracker, or, with
no pid, for [
NO_PID_FOR_MS]. - from_
tracker - The trees among
membersthat count: past the grace period, and not a daemon on the denylist. - set_of
- Everything one agent has in the background now: the declared shells, then the trees left behind that are not one of those shells.
- shadow_
counts - How many agents are in the would-be Background set now, and how many times an agent has entered it since srv started.
- shadow_
sample - One look, from the fleet’s once-a-second observation:
idleis the agents that read Idle (agent, block). Only every [SAMPLE_EVERY_MS]. Blocking: reads the tracker and the store. - watch
- Where the declared background shells are read from. Called once, with the fleet source.