Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Cross-machine delegate_task children never settle on the target machine (mcp:launch threads stay unsettled) #42197

Closeddeanyou(GitHub profile, opens in a new tab) opened this issue 0 comments

What happened

Cross-machine delegate_task children are created on the target machine as mcp:launch:<hash> threads. They carry delegatedFrom (the source environment and source thread), but their lineage.relationshipToParent is null and lineage.parentThreadId is null — they are top-level rows on the target, not subagent rows.

The consequence is that they never settle when their work finishes. On the target machine, 24 of 25 completed mcp:launch:* threads still have settledAt: null hours after their runs completed, so they keep showing up as active/unsettled work forever (until the generic 7-day auto-settle window elapses). Same-machine delegate_task children settle immediately, because those are relationshipToParent: "subagent" and the settlement sweep has a dedicated branch for them.

Two related facts observed on the target:

  • The originating parent thread is not synced to the target. thread_id like 'mcp:5f2d74d8%' → 0 rows, even though every child records delegatedFrom.threadId = 'mcp:5f2d74d8…'. The delegated chain cannot be walked locally, so the client cannot nest the children under anything.
  • peer_environment_links is empty on the target, even though the traffic arrived over that link. So the client's environment-delegated-under-parent rule (delegatedFrom.environmentId must be in the client's environment catalog) does not fire, and the children surface as ordinary top-level threads rather than being hidden under a parent.

Diagnosis

Settlement branches on lineage.relationshipToParent, not on delegatedFrom:

apps/server/src/orchestration-v2/ThreadSettlementService.ts:

const candidates = threads.filter(
  (thread) =>
    (automaticSettlementEnabled || thread.lineage.relationshipToParent === "subagent") &&
    isAutoSettlementCandidate(thread, nowMs),
);

and inside settleThread:

if (thread.lineage.relationshipToParent === "subagent") {
  // settles immediately, with the parent
  ...dispatch({ type: "thread.auto-settle", threadId: thread.id, ... })
}

A cross-machine mcp:launch:* child has relationshipToParent: null, so it takes the generic top-level path instead. That path settles only when resolveAutoSettlementAt finds the thread inactive for sidebarAutoSettleAfterDays (default 7, DEFAULT_SIDEBAR_AUTO_SETTLE_AFTER_DAYS in packages/contracts/src/settings.ts), or when something settles it explicitly. The subagent fast path — and finalizeAppOwnedSubagent, which is what settles a same-machine delegated child when its parent's work settles — never applies.

The client-side classification already treats these threads as delegated (isDelegatedAppThread is relationshipToParent === "subagent" || delegatedFrom != null), so the server's settlement rules and the client's classification disagree about the same thread.

Steps to reproduce

  1. Link environment A to environment B (Linked environments on).
  2. From a thread on A, call delegate_task with target.environmentId = B, several times. Let each child finish on B.
  3. On B, read the projection for those threads.

Expected behavior

A cross-machine delegated child that has finished its work settles like a same-machine delegated child does — promptly, and not via the 7-day top-level inactivity path. It should not stay "unsettled"/active on the target after its run completed.

Actual behavior

Every completed mcp:launch:* thread on B keeps settledAt: null and settledOverride: null, with pendingBackgroundTasks: 0 and activityRunStatus: null (i.e. it is idle and done, just not settled). Same-machine children on A settle immediately with settledOverride: "settled".

Impact

Minor bug or occasional failure

Version or commit

Target (B): 0.1.12-nightly.20261120.5009 (Linux x64). Source (A): 0.1.12-nightly.20261120.5009 (macOS arm64). Server code paths read on main @ 40dcbc5f6a and on the installed bundle.

Environment

A: macOS arm64 desktop app + server. B: Linux x64 server. Linked with full access over Tailscale. Providers used: codex (kilo/openrouter/free), claudeAgent (claude-haiku-5-5), pi (magpie/minimax-cn/MiniMax-M3.1-Flash).

Logs or stack traces

Read-only query against the target's statev2.sqlite (orchestration_v2_projection_threads):

mcp:launch:3b5ff6ba9570c179be92dde08f0c3c6b9 | settledAt: None | settledOverride: None | pendingBg: 0 | activityRunStatus: None | lastRun.status: completed | lastRun.completedAt: 2026-11-24T12:14:15.847Z
mcp:launch:d3dc6e1991f4c1b0a058b7a590b79923f | settledAt: None | settledOverride: None | pendingBg: 0 | activityRunStatus: None | lastRun.status: completed | lastRun.completedAt: 2026-11-24T13:08:24.814Z
mcp:launch:1628bda98813e670a174770a793877288 | settledAt: 2026-11-24T13:18:52.838Z | settledOverride: settled | pendingBg: 0 | activityRunStatus: None | lastRun.status: completed | lastRun.completedAt: 2026-11-24T13:18:52.838Z
mcp:launch:2d47b6b77a768c37718010b4169916ce0 | settledAt: None | settledOverride: None | pendingBg: 0 | activityRunStatus: None | lastRun.status: failed | lastRun.completedAt: 2026-11-24T13:38:29.375Z
mcp:launch:f98840bd4528ae3d2e10ac7336d152c06 | settledAt: None | settledOverride: None | pendingBg: 0 | activityRunStatus: None | lastRun.status: completed | lastRun.completedAt: 2026-11-24T13:47:31.913Z

All 25 mcp:launch:* threads on B share:

projectId       = 9c99c34f-841d-4250-9d8d-7c94c2724d44
creationSource  = mcp, createdBy = agent
linkOrigin      = {sessionId: da3254fa-…, label: "T3 Code · <A>", access: full-access}
lineage         = {parentThreadId: null, relationshipToParent: null, rootThreadId: <self>}
delegatedFrom   = {environmentId: a076e5b9-…, threadId: mcp:5f2d74d8…, title: "…"}

Only 1 of 25 has settledAt set. The parent thread mcp:5f2d74d8… is absent from B (thread_id like 'mcp:5f2d74d8%' → 0 rows), and peer_environment_links has 0 rows on B.

For contrast, on A the same-machine delegated children settle immediately:

thread:delegated-task:command%3Amcp%3Aaf59a630-… | rel: subagent | settledAt: 2026-11-21T01:37:12.401Z | settledOverride: settled

Possible fixes

Either of these would do:

  • Make the settlement sweep treat a thread with delegatedFrom like a subagent thread for the purpose of the fast path, so a finished cross-machine child settles promptly instead of waiting for the top-level inactivity window.
  • Or record the cross-machine child's real parent in lineage on the target (it currently has parentThreadId: null), so the existing subagent branch applies and the client can nest the child under the originating thread.
  • #36956 (closed) covered the MCP list filter and the missing delegatedFrom in t3_thread_list / t3_thread_read.
  • #27004 (open) covers t3_thread_launch with an agent-supplied delegatedFrom being hidden from the sidebar and missing from the parent's Lineage panel. That is the t3_thread_launch path; this report is the delegate_task path and the server-side settlement behaviour.
  • #26854 (closed) / #35263 (closed) covered how the desktop and mobile apps nest cross-machine delegated children.

Filed by

Codex via T3 Code, on behalf of the operator.

  1. tanstack-source added labelsbug

  2. juliusmarminge closed this

Sign in to join this conversation.