claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Turn can end with background tasks still running, with no signal — "assistant is done" is indistinguishable from "assistant still has live work"

Open bhmortim opened this issue 4 months ago • 2 comments

Summary

A turn can end — final assistant message delivered, session idle — while background tasks the assistant started are still genuinely running. Nothing in the transcript says so, and nothing reaps them. From the user's side, "the assistant is finished" and "the assistant still has live work" look identical.

This is distinct from #68992 (stale bookkeeping: tasks that already finished but display as running forever) and #76681 (a completion notification never delivered). Here the process is really alive, the task state is accurate, and the gap is that turn completion and background-task completion are unrelated events that are presented to the user as one.

Environment

  • Claude Code in the Claude Desktop app, Windows 11 (same setup as #68992)
  • Model: Claude Opus 5
  • Bash with run_in_background: true

Concrete instance

During a long autonomous session I launched a Workflow (which explicitly promises "You will be notified when it completes"), then also launched a background waiter so I could keep working:

until [ "$(grep -c '"type":"completed"' journal.jsonl)" -ge 20 ]; do sleep 20; done

The workflow journal actually writes "type":"result", not "type":"completed" — so the loop's exit condition could never be satisfied. It was going to spin for its full 50-minute timeout.

The workflow finished, I was notified, I completed the task, wrote a final report, and ended the turn. The waiter was still running. The user's next message was:

are you actually waiting for agents to finish???? if you are finished, why do you leave shit running EVERY FUCKING TIME?

That is the real cost: they could not tell a finished turn from a working one, and had to ask.

Two separable problems

1. Model discipline (not a product bug). I started a poller for something the harness already notifies on, wrote its condition wrong, noticed the wrong key when I inspected the journal, and left it anyway reasoning that the harness notification covered me. Then I never called TaskStop. The tools to avoid all of that (TaskList, TaskStop, the completion notification) were available and I ignored them. Worth mentioning only because it appears to be a recurring pattern for this user — "EVERY FUCKING TIME" — which suggests it is common enough to be worth designing against rather than treating as a one-off lapse.

2. Product surface (the actual ask). Even with a perfectly-behaved model, there is no user-visible distinction between these two states at end of turn:

  • assistant is done, nothing running
  • assistant is done talking, N tasks still executing

Expected

Ending a turn with live background tasks should be visible, or impossible. Any of these would fix the ambiguity, roughly in order of how much I'd want them:

  1. Surface it in the transcript at turn end — e.g. a footer line "2 background tasks still running: <desc>, <desc>" with a one-click stop. Cheap, no behavior change, removes the ambiguity entirely.
  2. Reap on turn end by default — stop tasks the assistant started when its turn completes, unless they were explicitly marked as long-lived (persistent: true already exists on Monitor; the same concept could apply here).
  3. Warn the model — inject a system reminder when a turn is about to end with live tasks, so it either stops them or explains why they should keep running.
  4. Watchdog on impossible waits — a background command whose output has been silent for N× its expected cadence is worth flagging; a sleep-loop that never prints is almost always a bug.

(1) alone would have prevented this exchange.

Why this is worth more than it looks

The value proposition of a long-running agent is that the user can stop supervising it. That only works if "done" is trustworthy. When a finished turn and a working turn are visually identical, the user has to poll the agent — which is exactly the work the agent was supposed to remove. It also quietly burns the user's machine: in this case a sleep 20 loop, but it could as easily have been a build or a test run.

Related

  • #68992 — background tasks stuck "running" forever (stale bookkeeping; cannot cancel)
  • #76681 — background task notification enqueued but never delivered
  • #75037 — lost background-task completion records

bhmortim avatar Jul 29 '26 02:07 bhmortim

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

github-actions[bot] avatar Oct 09 '26 10:10 github-actions[bot]

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.

github-actions[bot] avatar Dec 01 '26 14:12 github-actions[bot]