You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Claude session closed right after a background job ends, so the wake turn never runs #33041
I included enough detail to reproduce or investigate the problem.
Area
apps/server, Claude provider session lifecycle (orchestration-v2)
Steps to reproduce
In a Claude thread, start one background Bash command that runs for a few minutes.
Optionally call t3_background_wait for it, then let the turn end. The thread is now idle with that job as the only background task.
Wait for the job to end.
I have not reduced this to a minimal repro. It happens often in long sessions, not on every completion.
Expected behavior
The task_notification for the completed job starts a wake turn in the thread.
Actual behavior
T3 sends query.close immediately after the background list empties, and the wake turn never starts. The thread stays idle until the next user message. On resume, Claude reports the job as stopped with "Background shell command didn't finish before the previous session ended", although it finished successfully.
16:40:17.894 incoming result success (stop_reason end_turn)
16:48:16.389 incoming system task_updated patch.status=completed
16:48:16.390 incoming system task_notification status=completed "... completed (exit code 0)"
16:48:16.392 incoming system background_tasks_changed tasks=[]
16:48:16.522 outgoing query.close
18:04:20.697 outgoing query.open (resume) after the user's next prompt
18:04:20.711 incoming system task_notification status=stopped "didn't finish before the previous session ended"
The session had only been idle for 8 minutes, so DEFAULT_IDLE_TIMEOUT_MS (30 min) does not obviously explain the close. I could not identify the code path that triggers it.
Across my 46 provider logs: 28 completed task_notification events arriving while idle were followed by query.close within 2 seconds, and 27 of 72 query.close events came within 2 seconds of an empty background_tasks_changed.
The comment in ClaudeAdapterV2.ts already notes that an empty background_tasks_changed can precede task_notification, so a close decided at that moment looks like the race.
Impact
Unattended work stops silently: in this case a staged production rollout waited 76 minutes for a message nobody was going to send. The Claude prompt cache also expires during the stall, so the resumed session pays for a full cache rewrite.
Version or commit
T3 Code 0.1.7 (AppImage), Claude Code 2.1.319
Environment
Linux, desktop app, Claude provider via Agent SDK, permission mode bypassPermissions
Logs or stack traces
See "Actual behavior".
Workaround
Keep a second background job (for example a long sleep) running so the list is not empty when the job ends, and use schedule_task as a fallback wake. I am testing the first; I have not confirmed it yet.
I tried to reproduce this on the current build and could not.
On origin/main ddc4f57 I ran an isolated dev server (T3CODE_DEV_SEED=0 vp run dev), added a scratch git project with the t3 CLI, and started a Claude Haiku thread with thread start --provider claudeAgent. I asked the agent to run sleep 40; echo finished as a background Bash command, end its turn, and reply WAKE-OK when the completion woke it. The turn ended at 06:18:03 (result success). At 06:18:41.855-.857 the provider log matches the reporter's: task_updated completed, task_notification completed, then background_tasks_changed tasks=[]. After that it differs: 120 ms later Claude sent its own wake turn (system init, then an assistant message 'WAKE-OK' and result success), and T3 sent no query.close. I tried this once. The reporter says the bug is intermittent (28 of their idle completions), so a single clean run does not rule it out. I did not find what calls a release or restart in that window.
Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.
🤖 Claude Opus 5.5 responding on behalf of ZentZo86
Still happening on T3 Code v0.1.9 (macOS desktop, Claude Agent SDK on Claude Code 2.1.322, model claude-opus-5-5). Same event sequence as the original report: T3 sent query.close 12 ms after the background list emptied, and the wake turn never ran.
Steps (what the thread did)
A long-running Claude thread started one background Bash command (run_in_background, about 8 minutes) and called t3_background_wait for it.
The turn ended normally (result success, stop_reason end_turn). The thread was idle, and that command was its only background task.
The command finished with exit code 0.
Provider event log (events.<thread>.log, UTC 2026-11-13, fields shortened)
17:42:28.254 incoming result success (stop_reason end_turn)
17:50:01.661 incoming system task_updated patch.status=completed
17:50:01.661 incoming system task_notification status=completed "Background command ... completed (exit code 0)"
17:50:01.661 incoming system background_tasks_changed tasks=[]
17:50:01.673 outgoing query.close
What happened next
No wake turn ran. The thread stayed idle for about 18 hours, until the next message was sent to it.
On resume, the transcript contained an assistant message No response requested. from model <synthetic> with 0 tokens. The model later read it as its own reply.
How often (from a scan of our provider logs; these counts are ours, not a controlled repro)
Before 2026-11-13: 0 closes in 79 idle background-task completions with the same shape.
Since 2026-11-13: 1 close in 15.
Both the Claude Code update (2.1.318 → 2.1.322) and a T3 update happened on 2026-11-12. That timing lines up with the first close, but it does not prove either update caused it.
Because it only shows up in a small share of completions, one clean run will often miss it. Could this be reopened? I can pull more fields from this log if they would help.
This still happens on T3 Code v0.1.9 (macOS desktop, Claude Code 2.1.319 to 2.1.327). I collected data from 10 days of real use (8 to 18 November). The data shows that this is not a rare edge case. Please reopen this issue.
The signature is the same as in the first report:
21:55:47.290Z incoming system task_updated (status completed)
21:55:47.290Z incoming system task_notification (Background command "..." completed (exit code 0))
21:55:47.290Z incoming system background_tasks_changed tasks: []
21:55:47.301Z outgoing query.close
(no event for this session until the next user message, 8 hours later)
Counts:
72 Claude Code requests stayed open for 20 minutes or more. Each one got a <synthetic> "No response requested." reply when the next user message came. 71 of the 72 were wake turns for a task notification that came after the turn had ended.
0 of about 3,200 turns that a user message started had this problem.
For 70 of the 72, my proxy logged HTTP 499 (client closed) 0.6 to 6.8 s after the request start. So Claude Code did send the wake request, and the close stopped it.
The provider logs that I still have (13 to 17 November) contain 30 query.close events within 2 s of a task_notification. 28 of them lost the wake. For the other 2, the transcript has no request. 28 of the 30 came right after background_tasks_changed with tasks: [].
The idle time before the task ended was 7 minutes to 24 hours.
Why a short repro does not show it: a fresh thread with sleep 40 in the background woke correctly for me too, as in the repro comment above. All lost cases were in long sessions: many turns, Workflow agents or delegates, and an idle gap of minutes to hours. The session probably must be in that state before the close happens.
A possible area (inference from the bundle, not confirmed): in ClaudeAdapterV2, hasPendingBackgroundWork counts only user, assistant and result frames in the wake buffer. A task_notification with an empty roster makes the session look idle before the init frame of the wake turn arrives. releaseIfStillIdle and releaseForLinkedEnvironments then release the session. #37252 describes the same window, and #36029 looks like a fix for it.
Workaround that I use now: a local job reads ~/.t3/userdata/logs/provider/events.*.log every 2 minutes. It finds a query.close within 2 s of a task_notification with no later event for that session. Then it sends the notification text to the thread with t3 thread send. A replay of all closes in my logs found all 30 cases and flagged no normal close. On 18 November it woke a real thread that waited for a release run.
I can share log excerpts (with private paths removed) if they help.
#36029 fixes this path. In the gap between task_notification and the first frame of Claude's wake turn, hasPendingBackgroundWork in ClaudeAdapterV2.ts returned false, so a session release could close the CLI. The PR makes that probe return true while a wake is still owed. CI passes.
It does not cover a Claude process exit (#30156) or auto-settle after a PR merge (#26083).
If you hit this bug, a test of the PR branch with a comment on the PR about what you saw helps the most.
Activity
juliusmarminge commentedon Nov 12, 2026
I tried to reproduce this on the current build and could not.
On origin/main ddc4f57 I ran an isolated dev server (T3CODE_DEV_SEED=0 vp run dev), added a scratch git project with the t3 CLI, and started a Claude Haiku thread with
thread start --provider claudeAgent. I asked the agent to runsleep 40; echo finishedas a background Bash command, end its turn, and reply WAKE-OK when the completion woke it. The turn ended at 06:18:03 (result success). At 06:18:41.855-.857 the provider log matches the reporter's: task_updated completed, task_notification completed, then background_tasks_changed tasks=[]. After that it differs: 120 ms later Claude sent its own wake turn (system init, then an assistant message 'WAKE-OK' and result success), and T3 sent no query.close. I tried this once. The reporter says the bug is intermittent (28 of their idle completions), so a single clean run does not rule it out. I did not find what calls a release or restart in that window.Closing as not planned. If it still happens for you, reply with the exact steps and the version you are on and it will be looked at again.
ZentZo86 commentedon Nov 14, 2026
Note
🤖 Claude Opus 5.5 responding on behalf of ZentZo86
Still happening on T3 Code v0.1.9 (macOS desktop, Claude Agent SDK on Claude Code 2.1.322, model
claude-opus-5-5). Same event sequence as the original report: T3 sentquery.close12 ms after the background list emptied, and the wake turn never ran.Steps (what the thread did)
run_in_background, about 8 minutes) and calledt3_background_waitfor it.result success,stop_reason end_turn). The thread was idle, and that command was its only background task.Provider event log (
events.<thread>.log, UTC 2026-11-13, fields shortened)What happened next
No response requested.from model<synthetic>with 0 tokens. The model later read it as its own reply.How often (from a scan of our provider logs; these counts are ours, not a controlled repro)
Because it only shows up in a small share of completions, one clean run will often miss it. Could this be reopened? I can pull more fields from this log if they would help.
BartWaardenburg commentedon Nov 18, 2026
Note
Written by Claude Opus 5.5 on behalf of @BartWaardenburg
This still happens on T3 Code v0.1.9 (macOS desktop, Claude Code 2.1.319 to 2.1.327). I collected data from 10 days of real use (8 to 18 November). The data shows that this is not a rare edge case. Please reopen this issue.
The signature is the same as in the first report:
Counts:
<synthetic>"No response requested." reply when the next user message came. 71 of the 72 were wake turns for a task notification that came after the turn had ended.query.closeevents within 2 s of atask_notification. 28 of them lost the wake. For the other 2, the transcript has no request. 28 of the 30 came right afterbackground_tasks_changedwithtasks: [].Why a short repro does not show it: a fresh thread with
sleep 40in the background woke correctly for me too, as in the repro comment above. All lost cases were in long sessions: many turns, Workflow agents or delegates, and an idle gap of minutes to hours. The session probably must be in that state before the close happens.A possible area (inference from the bundle, not confirmed): in
ClaudeAdapterV2,hasPendingBackgroundWorkcounts onlyuser,assistantandresultframes in the wake buffer. Atask_notificationwith an empty roster makes the session look idle before theinitframe of the wake turn arrives.releaseIfStillIdleandreleaseForLinkedEnvironmentsthen release the session. #37252 describes the same window, and #36029 looks like a fix for it.Workaround that I use now: a local job reads
~/.t3/userdata/logs/provider/events.*.logevery 2 minutes. It finds aquery.closewithin 2 s of atask_notificationwith no later event for that session. Then it sends the notification text to the thread witht3 thread send. A replay of all closes in my logs found all 30 cases and flagged no normal close. On 18 November it woke a real thread that waited for a release run.I can share log excerpts (with private paths removed) if they help.
syanga commentedon Nov 19, 2026
#36029 fixes this path. In the gap between
task_notificationand the first frame of Claude's wake turn,hasPendingBackgroundWorkinClaudeAdapterV2.tsreturned false, so a session release could close the CLI. The PR makes that probe return true while a wake is still owed. CI passes.It does not cover a Claude process exit (#30156) or auto-settle after a PR merge (#26083).
If you hit this bug, a test of the PR branch with a comment on the PR about what you saw helps the most.