Repository navigation
fix(server): a task delegated from a linked machine settles there once its work is done - #42210
Conversation
…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 <noreply@anthropic.com>
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosAll 64 scenario measurements match All 64 scenario measurements
Baseline: Scenario and decoded snapshot size10 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.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
…e its work is done (pingdotgg#42210) (cherry picked from commit fbe5033)
A task handed to another machine with
delegate_taskstayed 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 onlydelegatedFromand no subagent parent, and the settlement sweep settled promptly only threads with a recorded subagent parent.The sweep in
ThreadSettlementServicenow uses the existingisDelegatedAppThreadpredicate, 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, clientRequestIddelegate:mcp:parent-on-A:…, and delegatedFrom {environmentId: , threadId: 'mcp:parent-on-A', title}. Observed in B's statev2.sqlite (read-only): threadmcp: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:
Tests
vp test run src/orchestration-v2/ThreadSettlementService.test.ts(apps/server): 53 passed-t "linked environment"and the fix stashed: the new test fails (no auto-settle dispatched), so it reproduces the bugvp run check:changed: format, lint, knip, graphql, typecheck (3 packages), test (2 files) all passNot in this change
Who did the work
Run by the t3code factory in T3 Code.