[Bug]: V2 closes Claude sessions while local_workflow batches are still running #16697
Before submitting#
- I searched existing issues and did not find an exact duplicate. Related reports are linked below.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/server
Summary#
Two long-running Claude Workflow batches stopped unfinished on the V2 nightly. In both cases, T3 sent an outgoing query.close a few seconds after an internal build/test command finished, persisted the provider session as stopped with lastError: null, and never delivered a workflow result or an interruption notice. The parent threads showed completed, although their workflows still had work left.
Sending resume recovered the saved implementation work and launched fresh workflows. Both recovery turns confirmed the previous workers were gone.
Steps to reproduce#
Observed twice with real development batches; a minimal synthetic reproduction has not been run yet:
- In a Claude thread, launch a background
Workflowwith multiple sequential stages and member agents. These batches implemented issues, reviewed them, opened PRs, waited for CI, and assembled a stack. - Let the foreground launch turn finish while the workflow continues. Claude reports
task_type: "local_workflow"and emits workflow progress and internallocal_bashtask events. - Leave the workflow running for several hours without another user message.
- Observe an internal command's terminal notification followed seconds later by an outgoing
query.close, while the workflow itself has no terminal result. - Inspect the workflow journal: its last member has a
startedentry without a matchingresult. The member transcript ends mid-stage. A new user message is required to recover.
Expected behavior#
An unfinished workflow and its member agents keep the provider session alive until they finish or the user stops them. If a lifetime limit deliberately stops live work, T3 should visibly report the interruption and preserve an actionable recovery state.
Actual behavior#
- Batch A had shipped its first PR and implemented/reviewed its second slice. It stopped while the shipping agent was investigating two tests that intentionally reproduced review findings. Seven later slices never started.
- Batch B had opened all seven PRs and reached final stack integration. Its last build succeeded, but the workflow stopped before pushing the assembled stack or returning its report.
- Neither workflow journal contains a final result. Parent thread status alone made them look completed.
Impact#
Major degradation or frequent failure
Long unattended batches silently stop, leaving PRs and local work incomplete until someone inspects on-disk journals and explicitly resumes them.
Version or commit#
T3 Code (Nightly) desktop 0.0.46-nightly.20261005.2702, using Orchestrator V2. Version read from the installed app's package metadata.
Environment#
macOS 26.7; provider claudeAgent; Claude Opus 5.5; full-access threads. Installed Claude Code reports 2.1.291 at investigation time. No provider/model/worktree change was made to trigger either closure.
Logs or stack traces#
Sanitized excerpts from the two provider event logs, UTC:
Batch A — 2026-10-06
22:10:59.782 incoming system.task_started:
task_type=local_bash, owned_by_subagent=true
description="Run red tests against unchanged production code"
22:14:56.046 incoming system.task_notification:
status=failed, summary="Run red tests against unchanged production code"
22:14:59.706 outgoing {"type":"query.close"}
22:14:59.709 provider-session.updated: status=stopped, lastError=null
Batch B — 2026-10-07
00:33:54.957 incoming system.task_started:
task_type=local_bash, owned_by_subagent=true
description="Build layer 7"
00:36:04.335 incoming system.task_notification:
status=completed, summary="Build layer 7"
00:36:04.737 member transcript: build returned exit=0
00:36:07.211 outgoing {"type":"query.close"}
00:36:07.231 provider-session.updated: status=stopped, lastError=null
Batch A's test failure was expected red-test evidence, not a workflow failure. The member transcript continued with a command to inspect those failures; no workflow failure result was recorded. Batch B likewise had no workflow completion notification or integration result.
Suspected lifecycle gap — not a confirmed root cause#
Inspecting the installed server bundle shows:
ProviderSessionManageruses a 30-minute idle timeout and a four-hour maximum background-work pin.CLAUDE_OPAQUE_BACKGROUND_TASK_KINDSrecognizeslocal_bash, but notlocal_workflow.ClaudeAdapterV2.hasPendingBackgroundWorkForThreadchecks the opaque task roster; its session-wide check also considers running subagent records.
These observations suggest investigating workflow classification/liveness, the handling of member command terminal notifications, and the maximum pin. They do not establish which release path caused these two closures: the retained incident evidence confirms query.close and stopped sessions, but does not identify the release reason. A workflow can also be represented as a subagent, so the missing opaque-task classification alone is not proof that it was unprotected.
Suggested regression coverage: an unfinished local_workflow remains live across member command completion/failure and between stages after the parent's foreground turn settles. If the maximum pin intentionally expires, surface that interruption rather than leaving an unfinished workflow behind a completed parent thread.
Workaround#
Send resume in the original batch thread after confirming old workers have exited. This recovered saved work in both incidents, but does not prevent recurrence.
Related#
- #4198: older background-work reaping report, closed as fixed by #5677. This incident occurs on V2.
- #15235: subagent-owned background jobs on stable V1; its triage describes V2's new idle-release/pin behavior.
- #15173: V2 parent session released while waiting for an app-owned delegated child. These incidents used native Claude
Workflowjobs and could recover with a user message. - #15448: V2 workflow classification/display gap. This report concerns execution lifetime and silent interruption.
- #5523: configurable idle thresholds; the installed build still has internal defaults.
Investigated and filed by GPT-6.1 Sol through the Codex harness in T3 Code, at the maintainer's request. No private paths, server addresses, credentials, session IDs, or raw transcript attachments are included.
juliusmarminge added labelsbug
juliusmarminge added labelsvia-triage
maria-rcks closed this
Sign in to join this conversation.
Note
Grok responding on behalf of Julius.
Triage#
Thanks @uzairansaruzi for the two incident timelines, the journal evidence, and the careful “suspected, not confirmed” framing. I checked this on
main(bfec2387b).Confirmed on main#
Your opaque-task / idle-pin observations match the code:
CLAUDE_OPAQUE_BACKGROUND_TASK_KINDSmaps onlylocal_bash→command.local_workflowis not listed (ClaudeAdapterV2.ts). Roster parsing returnsnullfor any othertask_type(L1862–L1865), and a comment still says “Only local_bash is opaque background work today” (L3298).hasPendingBackgroundWorkForThreadonly inspects that opaque Waiting roster for the native thread (L7643–L7656). Session-widehasPendingBackgroundWorkalso counts runningsessionSubagentsByTaskIdentries and non-empty wake buffers (L7616–L7641), so a workflow that is registered as a running session subagent can still pin idle release — but an unfinishedlocal_workflowthat never lands on the opaque roster (and is not counted as a running session subagent) will not.ProviderSessionManagerstill defaults to a 30-minute idle timeout and a 4-hour max background pin (ProviderSessionManager.ts).releaseIfStillIdledefers whilehasPendingBackgroundWorkis true, then releases withidle_timeoutonce the pin budget is spent (L1054–L1104) — with no workflow-result / interruption surface for the unfinished batch.So: yes, unfinished
local_workflowbatches can fail to keep the session alive the way only-local_bashopaque tracking would suggest, and silentquery.close+stopped/lastError: nullwith a completed-looking parent is a real V2 lifetime gap.Unconfirmed (same caveat as the report)#
The two captures prove outgoing
query.closeand a stopped session a few seconds after a memberlocal_bashtask_notification. They do not identify which release path fired (idle timer with no recognized pending work vs pin expiry vs another close). Multi-hour unattended runs make the 4h pin plausible; the ~3s correlation with bash completion is consistent with “pending work flipped false when the opaque command cleared,” but that is still a hypothesis until a release log line (idle-release-deferred/idle-release-pin-expired) or a retainedhasPendingBackgroundWorksnapshot is attached.Related (not duplicates)#
delegate_taskchild (also missing from Claude’s pending-work probe). Same session-lifetime family; different work model. These incidents are native ClaudeWorkflow/local_workflow, andresumerecovered them.local_workflowto the opaque roster or change idle/pin lifetime. No open PR found that fixes this close path.Next step#
Actionable bug on Orchestrator V2 + Claude:
local_workflow(and its unfinished members) as session-keeping background work — either extendCLAUDE_OPAQUE_BACKGROUND_TASK_KINDS/ roster admission, or guarantee the workflow stays arunningsession subagent for the whole pin probe.local_workflowmust survive memberlocal_bashcompletion/failure and inter-stage gaps withoutquery.close.The
resumeworkaround is good for recovery; it should not be the steady-state path for unattended batches.