Repository navigation
fix(server): finished Claude delegates release their process - #34934
Merged
Merged
Conversation
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Both review items are correct and describe the same gap: delegatedTaskProgress reports result_available even while unawaited background
command/monitortasks are running (backgroundWorkHoldsCompletion treats them as non-blocking by design), so the early detach killed a delegate's dev server or watcher, which Claude ends with its process. releaseFinishedDelegateSessions now also returns without detaching when any of the child's provider threads has non-empty pendingBackgroundTasks, leaving release to ProviderSessionManager's idle timer and its hasPendingBackgroundWork pin, as on main. A finished delegate with no background work is still released as soon as its result is recorded. Test: the existing DelegatedCompletionDelivery case became an it.effect.each with two rows: no background work (session released) and an unawaited background command (session kept). Each row uses its own IDs because the file's rows share one database. The background row fails without the new guard ('expected +0 to equal 1') and passes with it. No regex or parser added.Fixes #26413
Reproduction on main
Commit 6ba3de7 (origin/main), worktree ~/wt/factory-issue-26413-triage. Ran
T3CODE_DEV_SEED=0 vp run dev, which gave a fresh database (server port 16164). Added a scratch git project witht3 project add. Rant3 thread start --provider claudeAgent --model claude-haiku-5-5 --wait <project> "Use the T3 delegate_task tool exactly once to start a child task on provider claudeAgent with model claude-haiku-5-5 whose task is: 'Reply with the single word DONE.' ...". The parent called delegate_task and the child thread ran once: requested at 07:06:59Z, run status completed at 07:07:10.7Z. The parent got the result 'DONE' and its own run completed at 07:07:14Z. Afterwards the child's provider session stayedreadyin orchestration_v2_projection_provider_sessions, and itsclaudeprocess (child of the dev server, about 245 MB RSS) was still alive 93 s after the run completed. Nothing settles the child or queues a release for it. A background watcher on that PID was still waiting at hand-off, so the full 30-minute lifetime was not observed in this run. The code path matches it: DEFAULT_IDLE_TIMEOUT_MS = 30 * 60 * 1000 in ProviderSessionManager.ts:62, applied at :468, and no caller passes idleTimeoutMs. The settle path that releases early was not re-tested. Cleanup was not finished at hand-off: dev server PID 25436, its 3 claude children, the watcher, the worktree and /tmp/factory-issue-26413-triage are still in place.Evidence
Run the real server on each commit with a fresh database and synthetic project. Start one parent that delegates a single 'Reply with the single word DONE.' task, waits for its result, and starts no background work. Observe child-bound processes for 90 seconds after the parent finishes.
Base retained approximately 216 MiB in Claude alone, plus MCP descendants, through the observation window. Head released the observed child process approximately one second after completion. Both parents received DONE. The session projection still reads ready on both commits.
Driver · Environment details · Before samples · After samples
AI-assisted; verified with the tests and tools listed above.
Not shown:
Tests
vp test run src/orchestration-v2/DelegatedCompletionDelivery.test.ts -t "provider history handoff": 2 passed (background row fails with the guard stashed: 'expected +0 to equal 1'); vp test run on DelegatedCompletionDelivery, RemoteDelegatedTask, SubagentProjection, Orchestrator.control-reads, ThreadStop, OrchestratorMcpToolkit.integration, TaskCancelUsageLimit.integration, TaskCancelNativeSubagent.integration, SteeringCompletion.integration, OrchestratorMcpService, RestartContinuation, peer/RemoteDelegation: 12 files, 370 tests passed; vp run check:changed: format, lint, knip, graphql, typecheck (3 packages), tests (5 files, 90 tests) all pass.
Not in this change
AI-assisted; verified with the tests and tools listed above.