Reconcile Claude background task state

This commit is contained in:
iris-ai committed 2026-09-15 12:49:22 -04:00
1 parent f0661919bb
commit 9fd21af4e8
6 files changed
+310 -24

No files matched your search

+9 -7
View File
@@ -261,13 +261,15 @@ written, and the fold uses that same predicate to decide a reply is settled.
mid-sentence. `./ui-sandbox.sh` plus `/subagent 3` or `/background 5` in an
echo session is the whole rig; the helpers stagger a second apart so each
reply is its own.
- **Whether work is outstanding has two sources and needs both.** The
translator's `open_tasks` is what it watched start — the only thing that
knows about a backgrounded command — and `Subagents::any_open` reads the
directory, which is the only thing that knows about a subagent started
before this translator existed. That second one is every subagent a session
has when the backend is updated under it: adoption reads stdout from a
recorded offset, so those `task_started` lines are already behind it.
- **Claude's background-task level is authority; two edge sources are the
fallback.** Since Claude Code 2.1.261,
`background_tasks_changed { tasks: [...] }` replaces the live set and repairs
a missed ending edge. An adopted CLI is sent a repeated `initialize` to ask
for the current set. Reconcile only between turns or at a result boundary:
a foreground agent is legitimately absent from a background-only snapshot.
Older CLIs still need both edge sources: `open_tasks` knows about a
backgrounded command, while `Subagents::any_open` finds a subagent whose
`task_started` is behind an adopted stdout offset.
- **A usage limit a subagent hits reaches the session**, not just the
subagent's own transcript; auto-resume can only schedule against a session.
That is the case where the main agent is idle and a background Task is