GeezerVison is showing github.com — fix(server): a task delegated from a linked machine settles there once its work is done by juliusmarminge · Pull Request #42210 · pingdotgg/t3code
Conversation
A task handed to another machine with delegate_task stayed listed as unsettled work on that machine for up to 7 days after it finished. The machine that runs the task has no copy of the parent thread, so the thread there records only delegatedFrom and no subagent parent, and the settlement sweep settled promptly only threads with a recorded subagent parent.
The sweep in ThreadSettlementService now uses the existing isDelegatedAppThread predicate, which covers local subagents and tasks delegated from a linked environment. A delegated task now settles on the machine that ran it once its own work is done. A later message to it un-settles it as usual.
Fixes #42197
Reproduction on main
Commit: origin/main 7c42bb1. Started server B from a fresh worktree with T3CODE_DEV_SEED=0 vp run dev:server (fresh database, Replay (dev) provider), registered a scratch git repo as a project and set linkedEnvironmentsEnabled=true in B's own dev settings (with it off, a peer-link session gets HTTP 403 from /mcp). A scratch driver (not committed) issued an MCP client session on B with access full-access and peerLink true, the kind of session an environment link uses, then called t3_thread_launch with the arguments RemoteDelegation sends for a cross-machine delegate_task: projectId, title, modelSelection {devReplay/showcase}, message, clientRequestId delegate:mcp:parent-on-A:…, and delegatedFrom {environmentId: , threadId: 'mcp:parent-on-A', title}. Observed in B's statev2.sqlite (read-only): thread mcp:launch:36c5b174… with delegatedFrom set, linkOrigin.access full-access, lineage.parentThreadId null and relationshipToParent null. Its run reached status completed at 14:22:34.766Z. 90 seconds later (14:24:03Z) settledAt and settledOverride were still null, matching the reporter's rows; B had no copy of the parent thread and no peer_environment_links rows. The sweep code gives the immediate-settle path only to relationshipToParent === 'subagent', so this thread waits for the 7-day sidebarAutoSettleAfterDays window. Side note: when the same call came from a non-peer session, delegatedFrom was dropped, because the launch handler keeps it only alongside a linkOrigin. I did not drive a second server A plus an agent calling delegate_task; the B-side state is the same as what A's forwarded launch creates.
Evidence
Reproduced the forwarded target-side MCP launch on fresh databases using a full-access peer-link session, foreign delegatedFrom parent, and Replay (dev)/showcase. Opened the task, awaited successful completion, and checked for automatic settlement with a 90-second deadline. Same scenario, 1280×800 viewport, and light theme on both commits. scenarios:prove exited 0.
Scenario source. Read-only state snapshots: before, after.
Not shown:
- The full two-server A-to-B delegate_task transport and parent-settlement propagation were not exercised; this proof directly reproduced the forwarded target-side MCP launch used by triage.
Tests
Not in this change
- Forwarding the parent's settlement from the delegating machine to the remote task (what open PR fix(server): settle remote tasks with their parent #37709 proposes) is not needed for this fix and was not done.
- The settle-script skip for children sharing the parent's worktree still checks local subagents only; a remote task's parent is on another machine, so that check cannot apply.
- t3_thread_launch drops delegatedFrom for sessions not on an environment link; that is intended and unchanged.
Who did the work
- Written by Claude Opus 5.5, in Claude Code
- Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
- Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5
Run by the t3code factory in T3 Code.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
…e its work is done
A delegate_task child launched on a linked environment has no parent thread
on that machine, only delegatedFrom, so the settlement sweep skipped the
path that settles subagents and the finished task stayed unsettled until the
inactivity window. The sweep now uses isDelegatedAppThread, so these tasks
settle as soon as their own work is done.
Fixes #42197
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Thread transfer impact
✅ Thread transfer remains within every enforced ceiling.
| Provider |
Metric |
Main baseline |
This PR |
Impact |
PR ceiling |
|
| Codex |
Total thread wire |
5.0 KiB |
5.0 KiB |
0 B (0.0%) |
6.8 KiB |
✅ |
| Codex |
Thread snapshot wire |
3.8 KiB |
3.8 KiB |
0 B (0.0%) |
4.9 KiB |
✅ |
| Codex |
Live turn WebSocket wire |
1.2 KiB |
1.2 KiB |
0 B (0.0%) |
2.0 KiB |
✅ |
| Codex |
Live turn WebSocket decoded |
21.5 KiB |
21.5 KiB |
0 B (0.0%) |
24.4 KiB |
✅ |
| Codex |
Live turn messages |
1 |
1 |
0 (0.0%) |
8 |
✅ |
| Claude |
Total thread wire |
5.0 KiB |
5.0 KiB |
0 B (0.0%) |
6.8 KiB |
✅ |
| Claude |
Thread snapshot wire |
3.8 KiB |
3.8 KiB |
0 B (0.0%) |
4.9 KiB |
✅ |
| Claude |
Live turn WebSocket wire |
1.2 KiB |
1.2 KiB |
0 B (0.0%) |
2.0 KiB |
✅ |
| Claude |
Live turn WebSocket decoded |
21.9 KiB |
21.9 KiB |
0 B (0.0%) |
24.4 KiB |
✅ |
| Claude |
Live turn messages |
1 |
1 |
0 (0.0%) |
8 |
✅ |
Other scenarios
All 64 scenario measurements match main.
All 64 scenario measurements
| Provider |
Scenario |
Metric |
Main baseline |
This PR |
Impact |
PR ceiling |
|
| Codex |
short turn resume |
WebSocket decoded |
10.5 KiB |
10.5 KiB |
0 B (0.0%) |
12.7 KiB |
✅ |
| Codex |
short turn resume |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Codex |
long turn running, cold open |
HTTP decoded |
281.7 KiB |
281.7 KiB |
0 B (0.0%) |
302.7 KiB |
✅ |
| Codex |
long turn running, cold open |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Codex |
long turn running, history page |
HTTP decoded |
92.4 KiB |
92.4 KiB |
0 B (0.0%) |
107.4 KiB |
✅ |
| Codex |
long turn running, history page |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Codex |
long turn finished, cold open |
HTTP decoded |
381.5 KiB |
381.5 KiB |
0 B (0.0%) |
410.2 KiB |
✅ |
| Codex |
long turn finished, cold open |
rows |
151 |
151 |
0 (0.0%) |
151 |
✅ |
| Codex |
long turn finished, socket cold open |
WebSocket decoded |
381.6 KiB |
381.6 KiB |
0 B (0.0%) |
410.2 KiB |
✅ |
| Codex |
long turn finished, socket cold open |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Codex |
long turn finished, socket cold open |
rows |
151 |
151 |
0 (0.0%) |
151 |
✅ |
| Codex |
long turn finished, work page |
HTTP decoded |
186.2 KiB |
186.2 KiB |
0 B (0.0%) |
200.2 KiB |
✅ |
| Codex |
long turn finished, work page |
rows |
150 |
150 |
0 (0.0%) |
150 |
✅ |
| Codex |
idle thread resume |
WebSocket decoded |
65 B |
65 B |
0 B (0.0%) |
200 B |
✅ |
| Codex |
idle thread resume |
WebSocket messages |
1 |
1 |
0 (0.0%) |
1 |
✅ |
| Codex |
fleet shell snapshot |
HTTP decoded |
42.4 KiB |
42.4 KiB |
0 B (0.0%) |
53.7 KiB |
✅ |
| Codex |
fleet shell snapshot |
rows |
27 |
27 |
0 (0.0%) |
27 |
✅ |
| Codex |
fleet shell subscribe |
WebSocket decoded |
65 B |
65 B |
0 B (0.0%) |
200 B |
✅ |
| Codex |
fleet shell subscribe |
WebSocket messages |
1 |
1 |
0 (0.0%) |
1 |
✅ |
| Codex |
fleet shell resume check |
HTTP decoded |
18 B |
18 B |
0 B (0.0%) |
100 B |
✅ |
| Codex |
fleet shell resume check |
rows |
0 |
0 |
0 |
0 |
✅ |
| Codex |
stale shell reload |
HTTP decoded |
42.4 KiB |
42.4 KiB |
0 B (0.0%) |
53.7 KiB |
✅ |
| Codex |
stale shell reload |
rows |
27 |
27 |
0 (0.0%) |
27 |
✅ |
| Codex |
stale shell resume |
WebSocket decoded |
140 B |
140 B |
0 B (0.0%) |
400 B |
✅ |
| Codex |
stale shell resume |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Codex |
stale todo list cold open |
HTTP decoded |
72.4 KiB |
72.4 KiB |
0 B (0.0%) |
83.0 KiB |
✅ |
| Codex |
stale todo list cold open |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Codex |
stale todo list cold open |
nodes |
2 |
2 |
0 (0.0%) |
4 |
✅ |
| Codex |
stale todo list cold open |
subagents |
2 |
2 |
0 (0.0%) |
4 |
✅ |
| Codex |
stale todo list cold open |
plans |
1 |
1 |
0 (0.0%) |
2 |
✅ |
| Codex |
stale todo list cold open |
providerTurns |
1 |
1 |
0 (0.0%) |
2 |
✅ |
| Codex |
stale todo list cold open |
checkpoints |
1 |
1 |
0 (0.0%) |
2 |
✅ |
| Claude |
short turn resume |
WebSocket decoded |
10.6 KiB |
10.6 KiB |
0 B (0.0%) |
12.7 KiB |
✅ |
| Claude |
short turn resume |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Claude |
long turn running, cold open |
HTTP decoded |
283.3 KiB |
283.3 KiB |
0 B (0.0%) |
302.7 KiB |
✅ |
| Claude |
long turn running, cold open |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Claude |
long turn running, history page |
HTTP decoded |
93.4 KiB |
93.4 KiB |
0 B (0.0%) |
107.4 KiB |
✅ |
| Claude |
long turn running, history page |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Claude |
long turn finished, cold open |
HTTP decoded |
384.2 KiB |
384.2 KiB |
0 B (0.0%) |
410.2 KiB |
✅ |
| Claude |
long turn finished, cold open |
rows |
151 |
151 |
0 (0.0%) |
151 |
✅ |
| Claude |
long turn finished, socket cold open |
WebSocket decoded |
384.3 KiB |
384.3 KiB |
0 B (0.0%) |
410.2 KiB |
✅ |
| Claude |
long turn finished, socket cold open |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Claude |
long turn finished, socket cold open |
rows |
151 |
151 |
0 (0.0%) |
151 |
✅ |
| Claude |
long turn finished, work page |
HTTP decoded |
188.1 KiB |
188.1 KiB |
0 B (0.0%) |
200.2 KiB |
✅ |
| Claude |
long turn finished, work page |
rows |
150 |
150 |
0 (0.0%) |
150 |
✅ |
| Claude |
idle thread resume |
WebSocket decoded |
66 B |
66 B |
0 B (0.0%) |
200 B |
✅ |
| Claude |
idle thread resume |
WebSocket messages |
1 |
1 |
0 (0.0%) |
1 |
✅ |
| Claude |
fleet shell snapshot |
HTTP decoded |
43.0 KiB |
43.0 KiB |
0 B (0.0%) |
53.7 KiB |
✅ |
| Claude |
fleet shell snapshot |
rows |
27 |
27 |
0 (0.0%) |
27 |
✅ |
| Claude |
fleet shell subscribe |
WebSocket decoded |
66 B |
66 B |
0 B (0.0%) |
200 B |
✅ |
| Claude |
fleet shell subscribe |
WebSocket messages |
1 |
1 |
0 (0.0%) |
1 |
✅ |
| Claude |
fleet shell resume check |
HTTP decoded |
18 B |
18 B |
0 B (0.0%) |
100 B |
✅ |
| Claude |
fleet shell resume check |
rows |
0 |
0 |
0 |
0 |
✅ |
| Claude |
stale shell reload |
HTTP decoded |
43.0 KiB |
43.0 KiB |
0 B (0.0%) |
53.7 KiB |
✅ |
| Claude |
stale shell reload |
rows |
27 |
27 |
0 (0.0%) |
27 |
✅ |
| Claude |
stale shell resume |
WebSocket decoded |
140 B |
140 B |
0 B (0.0%) |
400 B |
✅ |
| Claude |
stale shell resume |
WebSocket messages |
2 |
2 |
0 (0.0%) |
2 |
✅ |
| Claude |
stale todo list cold open |
HTTP decoded |
73.4 KiB |
73.4 KiB |
0 B (0.0%) |
83.0 KiB |
✅ |
| Claude |
stale todo list cold open |
rows |
75 |
75 |
0 (0.0%) |
75 |
✅ |
| Claude |
stale todo list cold open |
nodes |
2 |
2 |
0 (0.0%) |
4 |
✅ |
| Claude |
stale todo list cold open |
subagents |
2 |
2 |
0 (0.0%) |
4 |
✅ |
| Claude |
stale todo list cold open |
plans |
1 |
1 |
0 (0.0%) |
2 |
✅ |
| Claude |
stale todo list cold open |
providerTurns |
1 |
1 |
0 (0.0%) |
2 |
✅ |
| Claude |
stale todo list cold open |
checkpoints |
1 |
1 |
0 (0.0%) |
2 |
✅ |
Baseline: ae45e00 · PR result: cdce9b5 · Source CI: success
Scenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
coderabbitai
Bot
commented
Nov 24, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.
|

No actionable comments were generated in the recent review.
Walkthrough
-
The settlement service now identifies delegated app threads with isDelegatedAppThread. It includes them in settlement candidates when automatic settlement is disabled and routes them to settlement without a branch lookup. A worker test covers this behavior.
Changes: Delegated thread settlement
| Layer / File(s) |
Summary |
Delegated thread detection and settlement apps/server/src/orchestration-v2/ThreadSettlementService.ts, apps/server/src/orchestration-v2/ThreadSettlementService.test.ts |
The service uses isDelegatedAppThread to include delegated app threads in candidate selection and route them to settlement without a branch lookup. The test checks that a delegated thread settles with its updatedAt snapshot while an ordinary branch thread does not. |
Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix · Severity of issue fixed: Low
Suggested reviewers: johnatfreecoffee, only21mil, gek0v
Merge Risk: Minimal · up to cdce9
-
Tasks delegated from a linked machine now settle on the machine running them once their work is done, instead of waiting for the generic inactivity window. No blocking issue was found. The only edge case is a delegated thread launched without any message, which may settle early and un-settles when a later message arrives.
Pre-merge checks: 4
-
| Check name |
Status |
Explanation |
| Title check |
 |
The title names the main change: a task delegated from a linked machine now settles on that machine once its work is done. It follows the conventional commit form and matches the summary, the descript… |
| Linked Issues check |
 |
Directly linked issue [#42197] requires that a cross-machine delegate_task child (an mcp:launch:* thread with delegatedFrom and relationshipToParent null) settle promptly on the target after its work … |
| Out of Scope Changes check |
 |
The whole-PR changes are limited to apps/server/src/orchestration-v2/ThreadSettlementService.ts and its test file. Both changes serve the settlement objective of [#42197]. The service change swaps the… |
| Description check |
 |
The description states the problem (delegated tasks stayed unsettled up to 7 days on the target machine), the change (the settlement sweep now uses isDelegatedAppThread), and the scope (links issue #4… |
Full details: Title check
-
Explanation
The title names the main change: a task delegated from a linked machine now settles on that machine once its work is done. It follows the conventional commit form and matches the summary, the description, and the linked issue #42197. The scope is narrow and the wording is specific enough for a teammate scanning history.
Full details: Linked Issues check
-
Explanation
Directly linked issue [#42197] requires that a cross-machine delegate_task child (an mcp:launch:* thread with delegatedFrom and relationshipToParent null) settle promptly on the target after its work finishes, instead of waiting for the 7-day top-level inactivity window. The PR summary and the ThreadSettlementService.ts change reported in raw_summary replace the check that tests relationshipToParent === "subagent" with isDelegatedAppThread(thread) in the candidate filter and in settleThread. The issue states that isDelegatedAppThread is true for subagent threads or threads with delegatedFrom, so such threads now take the immediate settle path. Delegated threads also bypass the automatic-settlement-enabled gate and the pull-request lookup. The added worker test covers a delegated thread with automatic settlement disabled and expects a thread.auto-settle dispatch. The issue's second proposed option (recording a real parent in lineage) is not required. Parent-thread synchronization and client nesting are named in the issue but are not coding requirements for this settlement outcome. Limits: the raw diff of the service body was truncated in my read, so I relied on the supplied change summary and the test description for the exact predicate use. The isDelegatedAppThread definition was taken from the issue text, not re-read from the contracts package.
Full details: Out of Scope Changes check
-
Explanation
The whole-PR changes are limited to apps/server/src/orchestration-v2/ThreadSettlementService.ts and its test file. Both changes serve the settlement objective of [#42197]. The service change swaps the subagent-only predicate for isDelegatedAppThread, which admits the same delegated threads the issue describes. The test change adds a regression case for that behavior. The PR description lists related items it does not change (parent settlement forwarding, the settle-script worktree skip, and delegatedFrom dropping for non-peer sessions). These are not present in the summarized change set, so no unrelated change is demonstrated. The truncated diff body leaves minor uncertainty about unlisted edits, but the summary reports only these two files.
Full details: Description check
-
Explanation
The description states the problem (delegated tasks stayed unsettled up to 7 days on the target machine), the change (the settlement sweep now uses isDelegatedAppThread), and the scope (links issue #42197 and explains what is excluded). Verification is detailed: a before/after reproduction on main and after the fix, test results, and check results. It also includes the model/harness attribution the template asks for. The template asks for the description to be focused, and it is mostly complete. The description is long and includes extra material, such as who did the work and the factory note, but the required sections are all filled in.
Finishing Touches
-
Generate unit tests (beta)
-
- Commit to this branch
- 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 ae45e00 and cdce9b5.
Files selected for processing: 2
-
apps/server/src/orchestration-v2/ThreadSettlementService.test.ts
apps/server/src/orchestration-v2/ThreadSettlementService.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Labels
size:S
10-29 changed lines (additions + deletions).
vouch:trusted
Author is trusted by repo permissions or the VOUCHED list.
Milestone
No milestone
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.
|