# Background work and response completion

Background processes and subagents have explicit ownership. The default remains
`execution`; a user request to keep work alive across replies uses
`run_in_background: true, lifetime: "conversation"` on Bash or Task.

## Lifetimes

- A **model turn** is one provider response and its tool calls.
- A **run** serves one goal/request and ends with a checked ReportOutcome, a
  final answer under conversational completion, or a forced ending. An execution may serve more than one queued run.
- An **execution** holds a session's lease while driving its log. Ordinary
  completion, suspension and cancellation can end it.
- A **conversation** is the parent session ID across executions and user messages.
- An **agent host** is the live Agent instance. Agent.Close joins its executions,
  completion waiters and owned processes. Closing a client subscription does not
  close the Agent.

| Work | Reply/execution ends | Client detaches, same host | Agent.Close | Host restart |
|---|---|---|---|---|
| Foreground shell | Moves to the background at its timeout, and what it leaves running in its group moves there when it ends; killed only where no registry can take it | Execution continues | Cancelled | No active-work guarantee |
| Execution process | Killed and recorded `ProcessEnded{killed}`; a ProcessReconciler environment may retain it instead | Execution continues | Attached processes closed | Environment-dependent lookup only; local processes die with the host |
| Background check | Killed, even with a ProcessReconciler; recorded as not completed | Execution continues | Closed | Dies with a local host; recorded lost by the next Verify |
| Conversation process | Retained, including its output cursor | Retained | Attached processes closed | No generic guarantee; reconciler may recover it; local processes die with the host |
| Persistent process | Retained by independent supervisor | Retained | Detached | Reattach to original live supervisor; supervisor/machine loss has no guarantee |
| Execution child | Cancelled and joined | Execution continues | Cancelled and joined | Log can be resumed, active worker lost |
| Conversation child | Worker or uncollected result retained | Retained | Cancelled and joined | History and waiting requests persist; explicit recovery resumes unfinished runs |

The local environment can't find a process again once its host process is
gone. On Unix, a watchdog kills the process group when the host dies. On
Windows, the kernel kills the process tree when the host's job handle closes. Conversation lifetime outlives
an execution, not the host.

Conversation ownership does not mean an infinite model loop: a child finishes
when its task ends, or suspends for outside input. Budgets and turn limits still
apply. Interrupting or cancelling a parent execution stops its execution-owned
work, as the execution's end does. A subagent stopped so is interrupted, as
TaskStop does, so its log ends its run as interrupted, and the parent records
it as ended while it still holds the session; cancelled instead, a child left a
run open in its log, read as running for good and was never settled. Explicitly conversation-owned jobs require ProcessKill, TaskStop,
Agent.StopBackground after the parent goes idle, or Agent.Close.

Conversation closure is a host operation: call StopBackground before discarding
the session. The TUI does this before session deletion, and before applying a
Settings change the user chose to stop the work for, after which the
conversation goes on: so the log records each process StopBackground stops as
ended, as a host's KillProcess does. Catalog tombstones and closing a UI tab alone do not own Agent resources.
StopBackground requires an idle parent and refuses a readable workspace-root
mismatch. If the session cannot be opened or read, it joins locally owned
watchers and children and reports the read failure. Process stops require a
readable log so their withdrawals can commit first.
TaskStop records durable interruption; host cleanup
leaves unfinished child runs recoverable.

PowerShell supports explicit background starts and foreground moves. Its wrapper reports leftover process presence as unknown. The Windows Job Object tracks completion of the full process tree, including descendants after PowerShell exits. A foreground call can still move at its timeout, and stopping a handle terminates the job. See [the PowerShell tool contract](/internals/tools/#powershell-tool-coreinternalbuiltinshell).

## Inspect, attach, message, collect, stop

- ProcessList shows stable process handles, lifetimes and observed states without
  consuming the model's output cursor. It bounds rows to 128, attached jobs first,
  and command previews to 256 bytes. Historical `ended` differs from an attached
  process, an unreachable process and a lost process. Output still being drained
  can keep completion unobserved until ProcessOutput collects it.
- ProcessOutput pages output and records exit status when drained. ProcessInput
  sends stdin. ProcessKill stops the process tree after a two-second grace that
  ends early once the tree is gone. Unix sends SIGTERM, then SIGKILL. A
  descendant outside its process group that holds the output open can make
  Unix wait out the grace. Windows has no graceful stop: each command runs on
  a hidden console of its own, never the host's, which a console control
  event from the host can't reach, so ProcessKill terminates the command's
  job at once. The host's ProcessOutput uses
  its own cursor and KillProcess can stop a retained process between executions.
  Status.Processes is recorded history, not proof of a live worker.
- TaskList / Agent.BackgroundTasks inspect durable child links plus live host
  ownership. States include running, waiting, completed, failed, cancelled and
  stopped (unfinished log, no worker here). Results are collected by TaskOutput
  exactly once into the parent log. If an in-memory handle is gone, collection
  checks durable ownership and reads the child log, without restarting work.
- TaskMessage records steering for active children and additional context for
  waiting children; a message to a finished child continues it with the message
  as its next task. It never guesses user answers. TaskOutput.answers resumes a
  waiting child; TaskContinue runs a new task in a finished child's history with
  current policy.
- A child that ended without being collected is settled by the runtime: when an
  execution of its parent starts, inside TaskMessage/TaskContinue, and before
  each Verify check, so a child that finished during the run doesn't leave the
  run's own evidence "freshness unknown". A child
  has ended when no worker in this agent runs it, its log is idle with a
  recorded last run, and it waits for no input. Settlement records
  `ChildFinished`, so the child is no longer a possible writer. No tool result
  reports what the child used, so the ending carries the usage
  and the reducer charges it: always to the session, and to the run under way
  if there is one. The report stays readable:
  TaskOutput renders it from the child's log, without usage, so it is charged
  once. Before this, an uncollected finished child kept
  every check "freshness unknown" and refused continuation.
- The model's TaskContinue resolves the sequence of an idle child inside the
  effect, so a stale or guessed `expected_seq` cannot misdirect it; a recovered
  effect reuses the originally recorded sequence. Hosts keep the strict
  expected-sequence `ContinueChild` command.
- TaskStop cannot reach a foreign child. Waiting or stopped owned children can
  be interrupted through their durable session even without a live handle.

There are at most 16 attached processes and 5 concurrently running children per
session. At most 128 uncollected child handles are retained per parent; collect
reports before launching more. Finished, uncollected children free running slots.
Output remains bounded by the environment's output buffers. Completed process
handles release output when collected; retained conversation processes consume a
slot until collected/stopped. Persisted log and blob quotas continue to apply.
Child usage settles when collected; retaining a worker does not authorize an
unbounded task or remove its configured budget. Background writers keep evidence
freshness unknown: successful startup is not evidence the eventual task passed.

## Completion wakeups

Every background job tells the agent that started it when it ends, unasked,
as Claude Code's do: the model started it to act on its result. A job kept
across replies (`lifetime` conversation or persistent) wakes the session: its
notice starts a run if none is under way, or joins the one that is. Processes
wake on exit; children wake on completion or suspension for input. The Agent
owns and joins each waiter, and records the job's `ChildStarted` or
`ProcessStarted` with `notify_on_completion` set: the wake is owed, and
recovery after a restart delivers it. Before, a job woke its agent only when
the model had set `notify_on_completion`, which it was told to do only when the
user asked to be told; a session's `sleep 300` ended unheard, and the TUI
counted it running half an hour later, until someone asked. The rule behind
that, that a notice must not start a run because the user didn't say it, had
no basis: the user asked for the work, and its result arriving is the rest of
that request. The woken run is the model's like any other: permission modes,
the classifier and approvals apply, and the notice is framed as the
background's (`OriginBackground`), not the user's.

A subagent's notice says how its run ended (`BackgroundNotice.Outcome`) or
that it waits for input (`Waiting`), with the task's description; a view marks
it by that, as it marks a process's exit. A process's notice carries its exit
code or signal (`BackgroundNotice.Exited`, `Code`, `Signal`), so the model
reads how it ended without a call, and the
fold records the exit on the process (`loop.Process.Exited`): the session's
status says it ended at once, while `Running` stays true until the model
collects its output, which records `ProcessEnded`. A command that ends at once
can end before the call that started it is recorded; its notice waits for
`ProcessStarted` in the log, or the fold would find no process to record the
exit on. A conversation child can also finish before its launching call
commits. Its watcher waits for the parent's writer to confirm `ChildStarted`
is durable so that any subsequently accepted completion is tracked for
withdrawal. The writer confirms an append when it succeeds and when the
driver reads an ambiguous one back and finds it landed
(`driver.LandedObserver`), so a store that loses commit acknowledgements
delays no wake. The watcher looks for the link from the parent's last
confirmed append when the launching call started, not from the start of the
log, and leaves that subscription as soon as it finds the link, so a child
that runs long holds no read of the log open.

Which wake owed survives which end of the parent's execution:

- The execution ends before the link is recorded: no wake was authorized. The
  attempt that records the link, if the call is re-run after a crash,
  establishes the wake obligation.
- The execution ends after the link is seen but before its append is
  confirmed, because the append failed (a failed sync, say): the watcher
  can't tell whether the link is durable, so it drops the wake and relies on
  recovery. Once the parent is idle, recovery derives an outstanding
  completion from the link in the parent's log and the linked child's log.
- The link is confirmed: the watcher waits for the child and delivers the
  wake, even if the parent's execution has ended by then.

Child settlement records the outcome independently of wake delivery.

### Stopping processes

A stop records `WakeWithdrawn` while the process or child owes a wake.
A process stop commits the withdrawal before the kill and retires the monitor source. Queued and staged notices
that the model has yet to see disappear from later requests. Notices in
requests that may have reached a provider worker stay as sent. The
withdrawal pins those command IDs before acknowledging the stop.

A watch that saw its command end records the exit in its last occurrence,
which may wait in the inbox while another holder has the lease. The
withdrawal discards that occurrence, so an idle stop records the exit it
carries as the process's end in the same append, and returns it. Whatever
else would record a process lost because nothing can find it again (a
stop during an execution, the model's process tools, recovery) first takes
the exit such an occurrence carries, so a process whose watch saw it end
is never recorded lost. A withdrawn process's recovery takes that exit
before it asks the backend, and an execution's admission records it before
it discards the withdrawn occurrence that carries it, so a stop cut short
between its withdrawal and its end loses nothing either.

The exit lookup uses the Watch source bound to the process's recorded
backend identity. A late exit can remain in the old inbox after deletion,
but admission, idle stop, process inspection and restart recovery use only
the inbox for the process they are settling.

| Stop path | Withdrawal | Backend and durable exit |
| --- | --- | --- |
| Model `ProcessKill` | Commits in the tool attempt's `EffectStarted` batch, even if the attempt never reaches a worker | The tool records a confirmed exit with its result. Recovery does not repeat an attempt left open by a crash. |
| `Agent.KillProcess` during a local execution | The execution's writer commits it | The writer stops the process and records the confirmed end. Append errors reach the caller and end dispatch. |
| Idle `Agent.KillProcess` or `StopBackground` | The host adopts the log under the lease and commits the target withdrawals together | The host captures the target watchers under the lease. `StopBackground` also captures the child handles. After releasing the lease, it joins the selected workers and stops the recorded processes. It then reacquires the lease, adopts and refolds, and records ends still missing. A busy lease returns `ErrSessionBusy`. |

An already-ended process returns its recorded exit. A successful local kill
joins the process. On Windows this includes waiting for an empty job and
closed owned streams. A backend can acknowledge a kill before the exit is
available, so for every backend the stop waits for the exit at most
`driver.RecordTimeout`, or until its caller cancels, and then returns
`ErrStopUnconfirmed`: a stop holds the session's writer and lease while it
waits. Authoritative absence records a killed, lost
process with exit code -1. A host without an attachment or a backend that
can confirm absence returns `ErrStopUnconfirmed` and leaves the exit pending.
Other backend errors also return `ErrStopUnconfirmed` with the original error.
The process remains listed and can be stopped again. A locally attached
process continues to use its slot. Only an attempt under way keeps its job
from execution cleanup. Once an unconfirmed
attempt returns, the end of the execution that owns the job closes it as
usual and records its exit.

A watch, `ProcessList` or startup recovery can record a withdrawn
process's known exit or loss without delivering a notice. A retained
process leaves the registry after its end commits. When a host reads a log
in which another host committed the end of a withdrawn process it still
holds, whether in a watcher, an adoption under the lease or the start of an
execution, it releases its attachment if the recorded `ProcID` is the one it
holds, so the slot stops counting against the session's limit. This allows deletion
to proceed once no process remains running. A run parked while idle
whose only triggers were withdrawn ends interrupted without another model
call and nothing else run: an idle `KillProcess` or `StopBackground` ends
it under its own lease before returning, without admitting commands or
firing timers. If another writer holds the session, the stop returns
`ErrSessionBusy`, and that writer's execution, or the session's next one,
including an inbox poke, ends the run. It
leaves no note telling the next run how it ended: the model never worked
on it, and the notice the note would point to is withdrawn.
`StopBackground` withdraws child completion wakes in the same batch as
process wakes. A completion already in flight is subject to the withdrawal
at admission, and recovery skips delivery of withdrawn completions. The
parent still settles completed children from their logs and can read their
reports with `TaskOutput`. Children started after the stop releases the
lease stay with the parent.

**Run notices.** A job that ends with its parent's execution (the default
`lifetime`), a subagent or a command, started in the background or moved
there, tells the run when it ends (a subagent also when it waits for input),
so the model doesn't poll for it: a recorded session spent nine full-context
turns hearing "still running". The parent execution owns the waiter, which
gives up when the execution ends. Its `background_notice` sets `Running`: the
fold queues it for the run's next model call, and drops it when no run is under
way (the job ended with the run, so there is nothing to wake for) or when the
job's ending is already recorded (its output was collected). It is not
recorded as notification intent and isn't delivered after a restart: the job
didn't survive the execution either. The tool descriptions tell the model it
will be told, and to wait with a long `wait_ms` when it has nothing else to do.

A waiter submits a `background_notice` command with a stable
`background-completed:<job>` command ID through Session.Send (long job identities use a stable SHA-256 suffix to fit
the command ID bound). Existing command deduplication prevents repeated events
from creating duplicate runs. Send queues against an active execution or starts
an idle one through the existing serialization and lease checks. Both paths
verify that the current log still records the originating job. The process
ID includes the backend generation, and `ChildStarted.wake_id` distinguishes
child links even when reuse of a session ID repeats the same effect and child
IDs. The notice asks the agent to inspect and collect the actual result before reporting.

The notice is the runtime's, not the user's. The model sees it as a user-role
item with origin `background` at the next model call; a run it starts keeps the
session's goal instead of taking the notice as a new request; it runs no
UserPromptSubmit hook and starts no permission review; compaction doesn't
retain it as a user message; the TUI draws it as a notice line and ACP
`session/load` doesn't replay it.
The follow-up remains owned by the Agent after the waiter finishes. The TUI
discovers these executions while idle, attaches from its last sequence, and
reloads completed follow-ups that finished between checks.

BackgroundNotices exposes the last 128 delivery results for host inspection. A
queue/lease/storage error is surfaced there and logged, not silently retried or
reported as delivered. Notification intent is recorded with ProcessStarted/ChildStarted. After reopening
an idle conversation, a host calls Agent.RecoverBackground to restore observation
and unacknowledged delivery. Command acceptance is the durable acknowledgement;
the same command ID and content are used on every delivery attempt. Completed,
collected and lost processes still produce the requested inspection follow-up.
Transient observation errors never change the command payload. Timed scheduling
and automatic recovery while no interactive host is running require a host worker. No timer-based scheduler
or perpetual agent loop is implied.

## Completion presentation

Batch hosts still require ReportOutcome; the TUI and ACP use conversational
completion, where the final answer ends the run. Evidence checks are unchanged. Transcript
assistant messages are provisional until the run accepts a matching final answer.
The TUI labels earlier candidates as Update and live text as Working. A missing
report triggers the existing bounded continuation. It is never auto-converted to
success merely because ordinary assistant text looks final.

## Verification

Tests cover separate completed replies, stable IDs, cross-message stdin/output/
stop, active-child messages, retained collection, foreign ownership, cancellation,
completion command deduplication and waiter shutdown. Existing process cleanup,
reconciliation, child continuation, evidence and replay suites remain required.

<a id="upgrading-an-existing-conversation"></a>

## Updating recorded tools

A recorded built-in tool keeps the schema and wording it was recorded with; the Agent never rewrites one. The root Agent uses the driver's explicit WithToolMigration hook only to follow what the host has now: a tool the agent no longer has leaves the session, and the host's tools, memory's, the web's and, when the agent schedules, the cron tools join it unless the session's policy names its tools and leaves them out (`TestReconfigureTogglesCronTools`, `TestReconfigureCronToolsFollowPolicy`). The same hook then makes the session's MCP tools the agent's, so a host that connects or removes servers keeps the conversation (see the MCP package README). Unrelated schemas, trust, reservation and scheduling changes still fail CheckTools without appending a migration. Other session configuration is preserved. Tool updates require an idle session; in-flight work must finish under its recorded tool contracts (`TestReconfigureCronToolsWaitForIdle`).

A check that Verify runs in the background is a process of the `check`
lifetime that only Verify collects: ProcessOutput and ProcessInput refuse its
handle, ProcessKill and ProcessList work on it, and nothing reconciles it.
The registry keeps its report mark so the collecting Verify can render the
result as a foreground check's; it releases the entry only once the log
records the ending. Its evidence rules are in
[completion](/internals/completion/#verification-evidence).

## Host recovery

RecoverBackground acquires the parent lease before inspecting ownership. It
resumes only uncollected, unfinished conversation children, through the ordinary
driver reconciliation path. It never answers waiting requests. Child policies
must remain within both the recorded parent and current host ceilings; recovery
refuses incompatible policies. Completed children are never rerun. Recovered
workers are owned and joined by the new Agent. The host explicitly selects
nondeleted conversations; opening a Session alone starts no background work.

Recovery is for a session a host has just opened from its log. The TUI
recovers a resumed session once, as it first reads its log, and never a
session it created. Repeated recovery leaves this agent's own live subagents
alone (`TestRecoveryLeavesALiveSubagentAlone`). Before, no host called it, so a wake
owed at a restart was never delivered. ACP recovers on `session/load`, once
per session in a `zelk acp` process and never for a session the process
started itself (`acp.Recoverer`, `TestLoadDeliversAnOwedWake`): its executions
outlive connections, so a client that reconnects to live work in the same
process finds nothing to recover, and a running session is left to the
process that runs it.

A host's brief holds on a session's lease (recovery, `KillProcess`
recording a kill, `StopBackground`) and the start of an execution are
ordered per session (`Agent.holds`): a start waits for a hold to end.
Before, a message sent while recovery held the lease was refused as if
another host held the session, and the TUI then made the session read-only.

`Session.Send` and occurrence admission choose, per session, between the
execution that runs and a new one (`Agent.sends`), so two of them can't both
start one. The gate is one session's, not the agent's, and a wait for it ends
with its context. Waiting for a command's or a poke's acknowledgment takes
no gate. The host's session context callback runs inside a new session's
start once the start is tracked, so `Agent.Close` cancels and waits for it,
and before the start takes the session's lease or execution slot. A `Send`
lends its gate back for the callback's duration and takes it again after;
if another start took the session meanwhile, the send queues on that
execution. So the callback holds nothing a call it makes could wait for: it
may send to other sessions or stop their background work, which joins their
watchers, and a call into its own session finds it not yet started. A start
of its own session, directly or through a chain of callbacks, can't be
served until the callback returns, so it fails with `ErrSessionStarting`;
the mark that refuses it travels in the callback's context, is the agent's,
and ends when the callback returns. A start made under another context
isn't recognized and waits for the callback, as does anything that waits for
the session's own start or claim, such as following it; the callback must
not wait for those.
The callback and the configuration it feeds come from the same agent, a
child's from the agent that configures it, and the result goes straight to
that configuration. If the log emptied after the start looked, the start
gives way and runs again, gathering, rather than calling the host under the
lease. Every start takes the lease and claims the session under the send
gate, so a send whose start let the gate go can't miss another start that
took the session meanwhile. Starts of one new session that race may each run the callback;
the session records one result. Before, one agent-wide mutex held through
the callback made a watcher wait on a callback that waited for the
watcher.

Reattaching a shell process requires an environment ProcessReconciler or a
persistent supervisor that retains process identity and I/O. Local environments cannot recover
pipes after host death. On Unix, on the same OS boot and in the same process
namespace, the local backend can confirm loss when the process owning the
watchdog pipe has died or when the pipe has been released in the current
process. The ID records the owner's start time as well as its PID, so a
later process given the same PID counts as the owner gone, not as the owner.
A start time that can't be read after the PID was found, as under a procfs
mounted `hidepid=2`, confirms nothing. After a reboot of the same machine the
boot differs, and the local backend confirms every process it recorded there
as gone: local processes die with their host, so a reboot ends them all. The
ID records the machine's identity (`/etc/machine-id` on Linux, the hardware
UUID on macOS) for this; a different machine, an unknown identity, or a
platform without one leaves the process pending. Other Unix targets read no
identity without cgo, so there nothing is confirmed after a restart. It keeps
the pipe open while a confirmed exit can still be recorded.

On Windows the process ID records the installation and kernel boot identifiers,
the owning host's PID and creation time, and a per-command kernel event name.
A clean close releases the event after confirming an empty job and joining
its streams, so a replacement environment can confirm loss while the old
host is still alive. The event lives in the global namespace so observers in
other Windows sessions can see it if permitted. Opening the event holds no
reference to the job. During host teardown, event absence alone confirms
nothing, since Windows can release the event before the job handle. A
confirmed owner exit, PID reuse on the same boot, or reboot of the same
installation also establishes loss. Access denied and unverified identity
leave the process pending.

Other observers leave the process pending unless an authoritative reconciler
or supervisor confirms its absence. `ProcessList` shows such a process as
unreachable, and `ProcessOutput` reports that it cannot be reached.
Recovery leaves an unobservable process's completion pending and never
restarts a command. Process attachment restores a fresh observation cursor,
so bounded retained output may be repeated after a host restart.
A session whose process records stay unreachable refuses `Delete`, which
can't tell them from running work; `ForceDelete` records them lost and removes
the session ([retention](/internals/retention/), Delete).

## Durable timed messages

New one-shot schedules create an idle-only source of kind schedule, atomically
with their exact message and absolute due instant. Due occurrences are numbered
under the session lease, without an inbox. The driver checks them after queued
commands and between dispatches; a user message that wins waits out its run
before the schedule fires. No core timer is introduced. DispatchWakes and
DispatchScheduled can explicitly poke an idle session.

Acceptance of `schedule:<id>:1-1` queues the recorded text with origin
`background`, advances the source cursor and ends the one-shot source atomically.
The wake retains the goal and permission review and runs no UserPromptSubmit
hook. The text may be the model's own; it is never recorded as something the
user said. Cancellation ends the source; cancellation that wins admission prevents
dispatch. A dispatched wake cannot be recalled. Overdue schedules fire once.
The 128-pending limit and permanent schedule IDs (1–96 UTF-8 bytes) remain.

Creating a schedule creates its source, and cancelling it ends the source. Every
delivery is a SourceOccurrence acceptance, with its payload checked against the
recorded due text under the lease. Recurring crons
are in [wakes](/internals/wakes/), Cron.

WithScheduling offers CronCreate, CronList and CronDelete to root
conversations, within the configured tool ceiling. Child tools exclude all
three. An idle tool update may offer these tools when the host explicitly
enables scheduling; unrelated recorded tool contracts remain checked.

A host that keeps the workspace open calls DispatchWakes(ctx, workspace) on its
own tick (the TUI every five seconds, `zelk acp` on its own loop). It admits due
and recorded occurrences for sessions with live sources, never resumes an
unrelated unfinished run, and leaves a session another host holds alone. Nothing
runs while zelk is closed: a time missed then fires once when a host next
dispatches.

## Independently supervised process lifetime

Bash also accepts `lifetime: "persistent"` when the host explicitly injects
WithPersistentProcesses. Launch without that capability is refused before any
process starts. The independent owner retains process identity, stdin and output
across response completion, Agent.Close and interactive client process exit.
Agent shutdown detaches these handles. ProcessKill and explicit StopBackground
kill/release owned jobs; host process APIs and cleanup discover durable owned
handles after restart without starting a model run. Existing execution and
conversation lifetime cleanup remains unchanged.

The local adapter is `env/supervisor`, explicitly served by `zelk processes serve`
and connected through `-process-socket`. Use an AF_UNIX socket outside the
workspace. Unix requires a 0700 parent directory and a 0600 socket. Windows
requires a private NTFS directory. Its socket is created under a current-user
DACL and both ends verify the peer's Windows user SID. Publication uses a hard
link under an exclusive lock, and cleanup removes the path only when it
still names that listener's socket. A replacement can recover a stale endpoint.
Configuration identity binds the workspace and confinement settings. The Agent
also checks the backend's process enforcement against its workspace. The
service uses the same workspace, launcher and network broker construction as
interactive hosts.

On Windows the supervisor owns each command's kill-on-close Job Object. An
interactive client can exit independently of the supervisor. Start the
supervisor separately, for example in an independent terminal or service.
No breakaway is requested. An enclosing Windows job can still limit or
terminate the supervisor and its descendants. For example, an IDE's
kill-on-close job can end the supervisor it started when the IDE exits.

Each start key deduplicates within one service generation. Changed command
content is refused, and released keys remain bounded tombstones. A new generation
cannot impersonate an old handle, even if PIDs are reused. The service retains
at most 128 jobs, at most 1 MiB output per job, and 4096 used start keys. These
bounds add no CPU/RAM containment beyond the supplied environment's profile.
Starters honor cancellation; shutdown cancels and joins an in-flight start before
releasing retained jobs. Every process observer is joined.

This lifetime depends on the independent owner remaining alive. Supervisor or
machine restart may lose processes and output. An unavailable service is
unreachable. A replacement can report an old local process lost when the
environment confirms the original process identity is gone. On Windows that
check uses the machine and boot identifiers, the owner PID and creation time,
and the per-command presence event. Inaccessible or unrecognized identities
leave the exit pending. No lost command is blindly
restarted. Root recovery restores process observation and unacknowledged
completion notices when the original service is available. Host-restart process
output cursors start fresh and may repeat bounded retained output.

Observation failures remain unacknowledged completion intent. They are surfaced in BackgroundNotices and logs; a failed connection never proves the job ended. Recovery can replace a stopped child execution handle in the same Agent without collecting a final report or settling its original allocation early.
