Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: A Claude thread waiting on a background command sends a false "Thread completed" alert #15099

Closedf4llenz(GitHub profile, opens in a new tab) opened this issue 6 comments

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

packages/contracts or packages/shared

Steps to reproduce

  1. Set notifications to "Notifications only" or "Notifications with sound".
  2. In a Claude thread, ask the agent to run a long command in the background and to report its result. For example, the agent runs a review script through Bash with run_in_background: true, then ends its turn with "I will wait for it before I write the summary."
  3. Switch to another thread or app.

Expected behavior

No completion alert while the agent is waiting on the command. When the command exits, Claude Code delivers a task notification, the agent wakes, and it continues. The alert should fire once, when the agent has actually stopped.

Actual behavior

"Thread completed" fires as soon as the turn ends. At that moment the composer banner reads "Waiting on command …" and the sidebar row reads "Waiting". The mobile push sends "Agent finished" at the same moment. The agent then wakes when the command exits, and a second, real completion alert follows.

Cause

#14213 (fixing #13965) made pending background work of kind command count as done, on the assumption that a leftover command is a dev server and the agent has finished:

  • packages/shared/src/orchestrationV2PendingBackgroundWork.ts:76-85: backgroundWorkHoldsCompletion returns false for command, and true for subagent, monitor and background_task.
  • apps/web/src/components/ThreadNotificationCoordinator.tsx:130: a waiting thread whose work does not hold completion counts as settled, so the alert fires.
  • packages/shared/src/agentAwareness.ts:108: the mobile push uses the same rule.

Every Claude background Bash is recorded as kind: "command" (local_bash, ClaudeAdapterV2.ts:1692-1716). A command the agent is waiting on and a dev server it left running look the same to this rule. The Claude SDK (0.3.276) carries no field that tells them apart: neither task_started nor BashInput says whether the agent intends to wait. In both cases the command usually wakes the agent when it exits. The fixture claude_background_task_wake records result/end_turn, then the task notification, then a new run. Codex behaves the same: its adapter requests a continuation when a command finishes after the turn settles (CodexAdapterV2.ts:4205-4262). So the premise "a leftover command means the agent is done" does not hold for these providers.

Options

This needs a product decision, because the two reasonable fixes trade against #13965:

  1. Hold completion for any pending background work (backgroundWorkHoldsCompletion becomes tasks.length > 0). This fixes this case on desktop, web and mobile push with a small change. If Claude ends a task without waking the agent (the notification-only path, ClaudeAdapterV2.test.ts:4708), the roster still clears and the alert still fires once. The cost: a thread that leaves a dev server running alerts when the server stops, not when the turn ends. That reverses what #13965 asked for. #14910 would then need its own sidebar rule ("done, command still running") instead of reusing this predicate.
  2. Record per task whether the agent waits on it or leaves it running. Commands would default to waiting, and the agent or user would release a dev server through a reversible server operation exposed over MCP and in the clients. This keeps #13965's turn-end alert, but only when the agent or user actually releases the command. Without that release it behaves like option 1. It also adds a contract field, a server operation and a client control.

My preference is option 1, with option 2 as a later opt-in only if the dev-server delay turns out to matter.

Related: #13625 is the other edge of this timing. That one is an early alert in the gap between background work finishing and the agent's next turn, and it remains under either option. #14910 extends the current command rule to the sidebar.

Impact

Minor bug or occasional failure

Version or commit

0.0.46-nightly.20261003.2610 (desktop); code checked at main @ fed41fa88b

Environment

macOS 26.4.1, T3 Code Nightly desktop, provider Claude (Opus 5.5)

Screenshots, recordings, or supporting files

The screenshot shows the thread when the "Thread completed" alert arrived. The composer banner reads "Waiting on command Run Sol cross-family reviewer seat via Codex", the sidebar row reads "Waiting", and the agent's last message says it is waiting for that command.

Image

Workaround

None. Ignore completion alerts for threads with a pending background command.

  1. Note

    Grok responding on behalf of Julius.

    Triage

    Thanks for the clear write-up, @f4llenz! This reproduces on main at fed41fa88b. The early "Thread completed" alert and the "Agent finished" push are real, and they disagree with the sidebar and the composer banner.

    Why it happens

    Claude names every background Bash local_bash, and that's stored on the background-work roster as kind: "command":

    https://github.com/pingdotgg/t3code/blob/fed41fa88bb27cb4325cb208d571393850bc63c2/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts#L1688-L1716

    backgroundWorkHoldsCompletion treats every command as not holding completion, on the assumption that a leftover command is something like a dev server and the turn is done:

    https://github.com/pingdotgg/t3code/blob/fed41fa88bb27cb4325cb208d571393850bc63c2/packages/shared/src/orchestrationV2PendingBackgroundWork.ts#L62-L85

    The desktop and web alert use that check. A waiting thread whose pending work doesn't hold completion counts as settled, so the toast, sound, and notification fire at turn end:

    https://github.com/pingdotgg/t3code/blob/fed41fa88bb27cb4325cb208d571393850bc63c2/apps/web/src/components/ThreadNotificationCoordinator.tsx#L129-L132

    The mobile push follows the same rule and reports the phase as completed, which is where "Agent finished" comes from:

    https://github.com/pingdotgg/t3code/blob/fed41fa88bb27cb4325cb208d571393850bc63c2/packages/shared/src/agentAwareness.ts#L106-L110

    The sidebar and the composer banner work differently. Any nonempty roster keeps the thread idle, the sidebar shows that as Waiting, and the banner shows "Waiting on command …". That's why your screenshot shows Waiting at the same moment the alert says the thread completed.

    https://github.com/pingdotgg/t3code/blob/fed41fa88bb27cb4325cb208d571393850bc63c2/packages/client-runtime/src/state/models.ts#L162-L171 https://github.com/pingdotgg/t3code/blob/fed41fa88bb27cb4325cb208d571393850bc63c2/apps/web/src/components/Sidebar.logic.ts#L960-L962

    Nothing on the roster says the agent will wake up when the command exits. The adapter only finds that out after Claude actually starts another turn. Codex has the same shape: a command that finishes after the turn has settled can request a continuation, but that also happens after the turn-end alert.

    https://github.com/pingdotgg/t3code/blob/fed41fa88bb27cb4325cb208d571393850bc63c2/apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts#L5167-L5172 https://github.com/pingdotgg/t3code/blob/fed41fa88bb27cb4325cb208d571393850bc63c2/apps/server/src/orchestration-v2/Adapters/CodexAdapterV2.ts#L4206-L4262

    Related, not duplicates

    • #13965 (closed) and #14213 (merged) are the reason command doesn't hold completion. Before that change, a dev server left running suppressed the alert for as long as the process lived.
    • #13625 (open) is a nearby edge: the alert fires in the gap after held work ends and before the wake-up turn starts.
    • #14872 (open) is the sidebar side of #13965. #14910 (open PR) applies the same "commands don't hold" rule to the sidebar, the unread label, and the mobile list. If it lands as-is, this false completion would show up in the thread row as well as the alert.

    On the two options you suggested

    Today, a command the agent is waiting on and a server it left running are the same kind of roster entry, so one check can't handle both:

    • Holding completion for every pending command (option 1) would bring back #13965. The alert would wait until a dev server exits, which can take hours.
    • A per-task wait or release flag (option 2) would keep both cases working. It would need a new signal saying whether a command is detached, a way for the agent or user to set it, and client support for reading it.

    A maintainer will decide on the direction. Until then, the sidebar's Waiting state is the accurate signal while a command is pending, and the alert after the wake-up turn is the real completion.

  2. juliusmarminge added labelsbug

  3. juliusmarminge added labelsvia-triage

  4. Hit the row-side version of this on current builds, now that #14910 / #15114 have landed, as predicted in the triage above.

    A Claude thread started a background Bash command ("Wait for CI and Argo sync of the change in background") and ended its turn, planning to resume when it exited. At the same moment:

    • Composer banner: Running: Wait for CI and Argo sync of the change in background, with a Stop button
    • Thread row: only the timestamp (7m), project, branch and PR badge. No Waiting or Working state, so it looks the same as a finished thread.

    So the row now agrees with the false alert instead of the banner. It's the command case where the agent is actively waiting, not a dev server left running. +1 for a per-task wait/detached signal (option 2); without one, any "wait for CI" style workflow looks finished in the list while the agent is still mid-task.

  5. One more case for a per-task wake signal, from an automated PR review loop on the nightly.

    The loop runs in a Claude thread. Once a review passes, it starts the full test suite with Bash and run_in_background: true, ends its turn with "I'll carry on with the merge when the checks finish," and wakes when the command exits to merge the PR. The suite takes ten minutes or more.

    With the Working section on, the thread leaves Working the moment the turn ends and sits in the inbox looking finished, while the composer shows "Running: Wait for other test runs, then run merge checks" with a Stop button. Eleven minutes later the command exits, the agent wakes and merges, and the thread goes back to Working. For a workflow built on many of these loops, the inbox fills with threads that don't need me yet, which is what the Working section is meant to prevent.

    We thought about getting around it by also starting a Monitor that waits for the same command, since monitor holds completion. We decided against it. Claude Code's own guidance names a background Bash as the tool for waiting on one event, and a Monitor stops after 30 minutes, so the workaround means extra watchers and wakes just to get the label right. We'd rather use whatever per-task signal option 2 ends up being. If the agent has to mark the command itself, for example with a field on the tool call or a convention in its description, a short note in the docs would be enough for us to adopt it.

    Same rule, seen through auto-settle: #17625.

  6. Another report of the row / Working-section manifestation described above: on nightly, an agent starts a background command and waits for its result, the thread loses its status and leaves Working, and it becomes Working again when the command completes and the agent resumes. Previously the thread displayed Waiting during that interval. The reporter's exact installed nightly version and provider were not captured.

    I checked the current upstream sources on October 22, 2026, at 5e8c5eb75aa43f4ef673255abe7cc4ed9b1d19b9. The same command classification is present in the latest published nightly checked, v0.1.2-nightly.20261022.3526 (f054d1b8018721bd997d99cbb918a7b17bf098a4):

    This is source-level confirmation of the existing cause, not a fresh end-to-end reproduction. The focused sidebar test command could not start because this checkout lacks the local vite-plus dependencies. No code changes made.

    Adding this here instead of filing a duplicate. The distinction discussed in #15433 is still relevant: a command whose result the agent is waiting for and a dev server deliberately left running currently receive the same classification.

  7. Note

    🤖 Claude Opus 5.5 responding on behalf of Theo

    Fixed by #24610. When the agent marks a background command it waits on with t3_background_wait, that work now holds completion, so no "Thread completed" alert or push fires until the agent really stops.

Sign in to join this conversation.