Skip to content

fix(server): a released provider session ends its tool call nodes too - #39734

Merged
juliusmarminge merged 1 commit into
pingdotgg:mainfrom
jieyuexing:fix/released-tool-call-node
Nov 20, 2026
Merged

juliusmarminge merged 1 commit into
pingdotgg:mainfrom
jieyuexing:fix/released-tool-call-node

Conversation

@jieyuexing

Copy link
Copy Markdown
Contributor

Note

Drafted by Claude Opus 5.5 and Claude Sonnet 5.5 in Claude Code (running inside T3 Code); reviewed and posted by @jieyuexing

Problem

A provider session can be released by detach, stream failure, provider stop or early close. When that happens, writeReleasedToolCallEvents in ProviderSessionManager.ts sets the cut-off tool call turn items to interrupted (turn-item.updated), but it never updates the tool_call execution node with the same nodeId. In the projection the item is interrupted while its node stays running with completed_at empty.

I reproduced it with a real Claude session. The handoff tool (t3_worktree_handoff) detaches Claude's exclusive session, and the handoff's own tool call ends with an interrupted item and a running node. I first saw this state in my own local database: a Claude command_execution item was interrupted and its tool_call node was still running, with the rows written on 2026-11-15 at 04:12Z. That is before #37325 (merged 19:48Z the same day) added the RunExecutionService path. The release path is the one I know of that interrupts an item without ending its node.

Change

writeReleasedToolCallEvents now reads the nodes of the cut-off items. For a node that is still open (isOrchestrationV2WorkActive), it emits node.updated (interrupted, with completedAt) before the turn-item.updated, in the same writeIfTurnItemUnchanged write. So the node is ended only if the item row is still unchanged, which is the guard the item already had. This matches the subagent release path, which already ends node and item together.

Scope

One function. No issue: the unit test below shows the inconsistent state directly. The same leftover after a release (item and tool_call node still running) is described in this #15993 comment. This PR only ends the node on the release path. It does not touch the "Waiting on background task" banner from that issue.

#39708 changes a different path, interruptLostToolCalls in RunExecutionService.ts, and the two changes do not overlap. In the handoff case that path never writes the node. I checked this with a temporary log on #39708 at 1ab15904af: when endWorkLostAfterRootRun runs, the item is already interrupted, so its loop over unsettled items visits nothing.

Verification

I extended the existing test "ProviderSessionManagerV2 clears background work after queued events drain on %s" with a running tool_call node for the cut-off item; no new it was added. On main, all four variants fail (excerpt):

 × ProviderSessionManagerV2 clears background work after queued events drain on detach
 × ProviderSessionManagerV2 clears background work after queued events drain on stream failure
 × ProviderSessionManagerV2 clears background work after queued events drain on provider stop
 × ProviderSessionManagerV2 clears background work after queued events drain on early close
AssertionError: expected 'running' to equal 'interrupted'
 ❯ src/orchestration-v2/ProviderSessionManager.test.ts:3671:16
      Tests  4 failed | 68 skipped (72)

After the fix, vp test run src/orchestration-v2/ProviderSessionManager.test.ts passes (72 tests). vp run check:changed also passes on the final commit: format, lint, knip, graphql, typecheck of 3 packages, and tests of 2 files (74 tests).

The real run used an isolated server from source, Claude Haiku 5.5, a small git repo as the project, and one message that loads and calls t3_worktree_handoff:

select node_id,kind,status,completed_at from orchestration_v2_projection_nodes where kind in ('root_turn','tool_call');
select turn_item_id,type,status from orchestration_v2_projection_turn_items where type in ('command_execution','dynamic_tool');

Rows for the other tool calls (ToolSearch, a sleep command, workspace preparation) are omitted below.

Before. This is an earlier run on #39708's head with RunExecutionService.ts restored to its merge-base version. Its merge-base, e3294d7663, has no differences from this PR's base under apps/server/src/orchestration-v2/.

node:provider:claudeAgent:native-item:toolu_013t4p2GhTyH6EoiedGe4Rrz|tool_call|running|
node:run:…:root|root_turn|completed|2026-11-20T13:48:55.116Z
turn-item:provider:claudeAgent:native-item:toolu_013t4p2GhTyH6EoiedGe4Rrz|dynamic_tool|interrupted

After (this PR):

node:provider:claudeAgent:native-item:toolu_01X4eL4VGUWYnoADmaZKXPh8|tool_call|interrupted|2026-11-20T13:55:34.095Z
node:run:…:root|root_turn|completed|2026-11-20T13:55:34.117Z
turn-item:provider:claudeAgent:native-item:toolu_01X4eL4VGUWYnoADmaZKXPh8|dynamic_tool|interrupted

The dynamic_tool item in both runs is mcp__t3-code__t3_worktree_handoff.

Not verified

  • Only Claude's handoff (detach) was run end to end. The stream failure, provider stop and early close variants are covered by the unit test only.
  • Existing databases that already hold stale running tool call nodes are not repaired.
  • No new test covers the race where the conditional write is rejected because another writer changed the item first.

Done with Claude Opus 5.5 and Claude Sonnet 5.5 in Claude Code (running inside T3 Code).

Releasing a provider session (detach, stream failure, provider stop, early
close) interrupted the cut-off tool call turn items but left the tool_call
execution node with the same nodeId running with no completed_at. The node
update now goes into the same conditional write as the turn item update.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 20, 2026
@coderabbitai

coderabbitai Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

When a provider session is released, the cleanup path now interrupts an associated node if it is still active. The test fixture creates a running tool-call node and checks that cleanup changes its status to interrupted.

Changes: Provider session cleanup

Layer / File(s) Summary
Interrupt associated active nodes
apps/server/src/orchestration-v2/ProviderSessionManager.ts, apps/server/src/orchestration-v2/ProviderSessionManager.test.ts
The release path adds an interrupted event for an associated active node alongside the turn-item interruption. Both updates use writeIfTurnItemUnchanged. The cleanup test checks the node’s resulting status.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • pingdotgg/t3code#35311: Settles open tool nodes and items during planned worktree handoff detaches, overlapping with this change’s handling of unfinished tool nodes during cleanup.

Suggested labels: bugfix

Suggested reviewers: notreliable, macroscopeapp

Merge Risk: Minimal · up to 9a91f

This change makes released provider sessions end their tool-call nodes together with the interrupted tool-call items, so nodes no longer stay stuck as running. No merge-blocking issue was found; stale nodes already stored in existing databases are not repaired.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title "fix(server): a released provider session ends its tool call nodes too" describes the main change. The PR makes writeReleasedToolCallEvents also mark open tool_call nodes as interrupted when…
Description check Passed The description follows the template sections (Problem, Change, Scope, Verification, and an agent attribution line). Problem and Change are clear and specific. Scope links the related issue comment an…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title "fix(server): a released provider session ends its tool call nodes too" describes the main change. The PR makes writeReleasedToolCallEvents also mark open tool_call nodes as interrupted when a provider session is released, which matches the title. It uses a conventional commit prefix and a plain-language description of the fix.

Full details: Description check

Explanation

The description follows the template sections (Problem, Change, Scope, Verification, and an agent attribution line). Problem and Change are clear and specific. Scope links the related issue comment and explains why no issue is linked, and it states that the change is limited to one function. Verification lists the focused test, the before and after results, and the end-to-end run. The Not verified section lists the gaps. The template's HTML comments are removed, and the description covers each required section.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between df09ced and 9a91ff0.

Files selected for processing: 2

  • apps/server/src/orchestration-v2/ProviderSessionManager.test.ts
  • apps/server/src/orchestration-v2/ProviderSessionManager.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 20, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

Evidence

Created identical synthetic one-commit repositories, started real Claude Haiku 5.5 turns, and requested ToolSearch followed by one worktree handoff without continuation. After each completed run, queried the isolated database read-only, joining tool items and nodes by node_id. Linux real dev servers; identical terminal viewport and theme. This defect is in the projection rather than visible web rendering, so proof uses live server/CLI recordings.

Before After
df09ced768 9a91ff0c70
Before: item interrupted, node running without completion After: item and node interrupted with matching completion timestamps
Before recording After recording

Reproduction driver · Transcripts and read-only snapshots

Base leaves the handoff node running after its item is interrupted. Head interrupts both with matching completion timestamps. Later snapshots preserve this difference. No tests were used as evidence.

Not shown:

  • Stream failure, provider stop, and early close release variants were not exercised; this proof covers the reported detach/worktree-handoff path.

@juliusmarminge juliusmarminge added takeover:ready Takeover done; auto-lands when gates pass and removed takeover:in-progress A takeover lead is working on this PR labels Nov 20, 2026
@juliusmarminge
juliusmarminge merged commit 97e7834 into pingdotgg:main Nov 20, 2026
72 checks passed
@juliusmarminge juliusmarminge removed the takeover:ready Takeover done; auto-lands when gates pass label Nov 20, 2026
AIdoesmyjob pushed a commit to AIdoesmyjob/t3code that referenced this pull request Nov 20, 2026
HNRow pushed a commit to HNRow/r3code that referenced this pull request Nov 20, 2026
github-actions Bot added a commit to omarcresp/t3code-flake that referenced this pull request Nov 20, 2026
**v0.1.12-nightly.20261120.5009** · 30 changes from 9 contributors

- **Secret cards.** Enter multiple secret values in one card and show or hide masked values on the web.
- **Shared Antigravity skills.** Use Antigravity skills registered in shared or external directories.
- **Thread failure reasons.** See why the latest thread run failed when checking it from the command line.
- **Draft pull requests.** Create draft pull requests directly without briefly announcing them as ready for review or starting unnecessary CI runs.
- **Azure DevOps Bugs.** Read and edit Bug descriptions stored in Repro Steps from Issues.
- **Stable file previews.** Keep HTML previews and attachments open while agents work, without losing form input to unnecessary reloads.
- **T3 Connect port forwarding.** Forward ports to your machine when connected to another machine through T3 Connect.

### Plus 21 more bug fixes and performance improvements.

<details>
<summary>Full changelog</summary>

## What's Changed
* fix(server): Claude gateway cooldown survives an untyped SDK rejection by @juliusmarminge in pingdotgg/t3code#39695
* fix(release): Windows resource monitor starts without the Visual C++ runtime by @jieyuexing in pingdotgg/t3code#39683
* fix(server): turn authorship works on Git before 2.36 by @juliusmarminge in pingdotgg/t3code#39702
* fix(mobile): new thread says the host has no model instead of asking to connect by @juliusmarminge in pingdotgg/t3code#39713
* fix(antigravity): keep truncated command text valid Unicode by @Lucenx9 in pingdotgg/t3code#39697
* fix(antigravity): honor the saved thinking level in text generation by @Lucenx9 in pingdotgg/t3code#39720
* fix(azure-devops): read and edit a Bug's text in Repro Steps by @juliusmarminge in pingdotgg/t3code#39738
* fix(web): stop reloading unchanged file previews during agent commands by @juliusmarminge in pingdotgg/t3code#39736
* fix(server): a released provider session ends its tool call nodes too by @jieyuexing in pingdotgg/t3code#39734
* fix(server): watch_pull_request says a merge or close wakes the agent by @juliusmarminge in pingdotgg/t3code#39739
* fix(server): replace the device hub when emulator camera support changes by @juliusmarminge in pingdotgg/t3code#39764
* fix(desktop): Cmd+T opens the new-tab menu from a focused browser page by @juliusmarminge in pingdotgg/t3code#39769
* fix(server): port refusals survive T3 Connect's relay by @juliusmarminge in pingdotgg/t3code#39763
* fix(server): Antigravity links and discovers skills from skills.json by @mameli in pingdotgg/t3code#39765
* fix(desktop): WSL backend honors T3CODE_HOME from the distro's login shell by @juliusmarminge in pingdotgg/t3code#39771
* fix(server): pull_request_create opens a draft PR as a draft on GitHub and Azure by @juliusmarminge in pingdotgg/t3code#39772
* fix(server): Antigravity wake runs accept steers again by @juliusmarminge in pingdotgg/t3code#39767
* fix(server): keep DeepSeek ACP probes out of session history by @crisxuan in pingdotgg/t3code#39733
* fix(server): idle threads compact while a delegated task runs by @juliusmarminge in pingdotgg/t3code#39766
* fix(mobile): a settings row an older environment left mixed can be set off by @not-compromised in pingdotgg/t3code#39755
* feat: secret cards get a show/hide toggle and multi-value fields by @gabrielelpidio in pingdotgg/t3code#31257
* fix(ssh): a slow remote server keeps its SSH forward on reconnect by @juliusmarminge in pingdotgg/t3code#39802
* fix(antigravity): a scheduled wake keeps its run open instead of looking finished by @juliusmarminge in pingdotgg/t3code#39806
* fix(ssh): reconnect stops waiting on a remote server that is shutting down by @juliusmarminge in pingdotgg/t3code#39807
* fix(web): open PDF attachments no longer reload while the agent works by @juliusmarminge in pingdotgg/t3code#39815
* perf(linear): overlap issue details and viewer reads by @Adamulek123 in pingdotgg/t3code#39801
* fix(linear): scope issue numbers to the named team by @Adamulek123 in pingdotgg/t3code#39809
* fix(gitlab): pull_request_create opens a draft MR as a draft by @aravhawk in pingdotgg/t3code#39817
* fix(web): scrolling a PR description no longer moves focus to the condensed header by @juliusmarminge in pingdotgg/t3code#39840
* feat(cli): thread show reports why the latest run failed by @juliusmarminge in pingdotgg/t3code#39849

## New Contributors
* @mameli made their first contribution in pingdotgg/t3code#39765
* @crisxuan made their first contribution in pingdotgg/t3code#39733

**Full Changelog**: pingdotgg/t3code@v0.1.12-nightly.20261120.4994...v0.1.12-nightly.20261120.5009

</details>


Upstream release: https://github.com/pingdotgg/t3code/releases/tag/v0.1.12-nightly.20261120.5009
@jieyuexing
jieyuexing deleted the fix/released-tool-call-node branch November 21, 2026 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S 10-29 changed lines (additions + deletions). vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants