Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): recover remote delegated launches after source restart #30249

OpenLenoridev(GitHub profile, opens in a new tab)wants to merge 48 commits intomain fromrefs/pull/30249/headopened View on GitHub

Problem

If the source server restarts after the destination accepts a delegated launch but before the response is recorded, the destination thread can keep running without a source task to follow or stop. This continues #20937 on main after its feature-branch base was deleted and that PR closed unmerged.

Summary

 delegate_task to a linked environment
-  launch destination thread
   record source task
+  record launch attempt
+  launch destination thread with the original replay key
+  attach destination receipt
 startup
+  replay pending launches with the same key and link identity
   follow attached tasks

Change

Record resolved launch inputs before the outbound request and retain the accepted task ID across ambiguous failures. Recovery reuses the original request namespace, key, modes and OAuth-grant identity. Replacing a link cannot start another child for an uncertain launch. Cancellation before a request is sent does not launch; cancellation after uncertain acceptance reconciles the original child and stops it.

The destination thread ID is absent until attachment. Task tools and web/mobile navigation handle that pending state, show Launching, and retain actionable launch errors. Existing attached tasks remain readable. No new MCP tool or question/approval forwarding is added.

Scope and approval

Fixes #17051, filed by maintainer @juliusmarminge with this record-before-launch, attach, and startup-replay design. Its triage comment identifies a durability/recovery bug and leaves the changed task-result and restart semantics for manual review. That comment is not represented as implementation or merge approval. The prerequisite #16719 is now merged. This contribution addresses that one recovery window; local approval notices and remote parent-handled questions remain separate.

Evidence

The lost-response test fails on the tested main base with no source task after destination acceptance, and passes with recovery enabled.

The following captures compare the same synthetic pending task in the isolated web client, first with the main-base web components, then with this fix. The right-hand lineage row changes from Running to Launching, with navigation disabled until attachment. This is rendering evidence, not a physical two-host launch reproduction. The fixture retains an older synthetic failure notice in its timeline.

BeforeAfter
Pending task incorrectly says RunningPending task says Launching

Verification

Base tested: 8657eecb28bc8c767510cc6b9d852b628047c604 on main.

  • vp test run src/peer/RemoteDelegation.test.ts --maxWorkers=1 from apps/server: 43 cases pass. Coverage includes a destination accepting while its response is withheld, rebuilding the source follower without an active parent run, attaching the original destination thread, and rejecting reuse after the link grant changes.
  • The same lost-response regression with RemoteDelegation.ts restored from that main base fails at the first persistence assertion: expected [] to have a length of 1 but got +0. Restoring the fix passes the suite.
  • Focused RemoteDelegatedTask, ThreadLaunchService, PeerLinks, PeerForwarding, and ThreadManagementService suites: 89 cases pass.
  • Mobile subagent presentation: 6 cases pass. Total focused cases: 138.
  • Scoped server, web, mobile and contracts type checks pass. Web needed a higher memory budget after the first bounded run timed out.
  • Formatting and changed-file lint pass without findings. vp run check:changed --concurrency 1 passes format, lint, the files/dependencies knip pass, and GraphQL generation. Its export pass reaches the 768 MiB Node heap limit, and its 35-package typecheck reaches the 900-second bound. The remaining broader test stage was interrupted. A separate export retry at 1536 MiB also failed to finish within approximately 15 minutes. These broader checks are incomplete, not green.
  • The launch schema is private to its contracts module; final contracts types, formatting and lint pass after removing its unused export.
  • No paid MCP model-use eval ran because this checkout has no eval API key. No model-facing instructions or input tool descriptions changed.

The remote integration test uses real HTTP/MCP/OAuth and database-backed source state with a controlled destination launch service. It does not prove physical two-host, real-provider restart, Connect, desktop-shell or native-mobile acceptance.

Merge Danger

Door: Two-way for code, with a persisted-state compatibility caveat.

Blast Radius: Remote delegation.

The fix adds optional persisted launch inputs and allows a task to exist before its destination thread ID is known. Both sides continue to enforce link access and caller modes. Rolling back while pending intents exist cannot be assumed to preserve recovery; let those tasks settle before rolling back.

Prepared with GPT-6.1-Sol through the Codex harness in T3 Code.

    1. Pushed31b8016

    2. Pushede28ab72

    3. github-actions[bot](GitHub profile, opens in a new tab) removed labelsneeds-rebase

Sign in to join this conversation.