docs/design/2026-07-22-background-agent-roster-restore.md
Background-agent sidecars and JSONL transcripts persist logical identity and
history, while BackgroundTaskRegistry indexes the current session's
addressable tasks. The resume loader currently restores only sidecars left in
running state. Completed agents therefore disappear from the registry after
their parent session is restored, even though their transcripts remain
available. The model also has no tool for querying the registry.
list_agents tool for on-demand discovery.send_message(task_id) as the continuation operation.task_list tool.The session-directory scan accepts both running and completed sidecars.
Running entries become paused, preserving the existing interrupted-work
behavior. Completed entries remain completed, are marked already notified, and
retain the transcript and metadata paths needed by send_message revival.
New sidecars persist whether the original launch was backgrounded. Completed entries are restored only when this marker is explicitly true, so foreground and legacy unmarked completed sidecars are not exposed as reusable background agents. Legacy running sidecars retain the existing recovery behavior.
The loader verifies the sidecar filename and parent-session owner before registration. A retained row with a missing transcript, mismatched transcript identity, incompatible isolation, or conflicting working directory remains visible but is marked non-continuable. Worktree-isolated rows are treated the same way because their temporary ownership context cannot be reconstructed safely. Only the newest retained completed entries are restored; running entries are not subject to that limit.
list_agents reads the live registry and returns background agents with a
stable task_id, description, type, status, continuation capability, and any
blocking reason. It does not scan disk. The tool is caller-owned and excluded
from subagents and teammates.
After restoration, the next ordinary top-level user prompt receives a single
system reminder to call list_agents and then send_message. Slash commands
and interrupted-turn continuations do not consume this reminder. Bare mode
does not receive it.
Session switches clear the in-memory registry before loading a new roster. Failed resume rollback clears partially restored entries before restoring the old session, and branching is blocked while background work is still active.
send_message can revive a compatible restored completed entry.