Skip to content

[Bug]: Interrupting and restarting a delegated child thread sends a stale [interrupted] wake to the parent, causing both agents to race in the same worktree #41134

Closed

Description

@nqh-packages

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/server

Steps to reproduce

  1. From a parent thread, call delegate_task with isolation: "worktree" and mode: "async" to start a child thread (run ordinal: 1).
  2. While the child is running, stop/interrupt it from the UI in the child pane and immediately send a new message/steer in the child pane so the child starts a new run (ordinal: 3) in the same worktree.
  3. Observe the parent thread.
  4. Later, cancel/stop the child thread again from the UI.

Expected behavior

  1. If the child thread already has a newer queued or active run (activeRunId / newer ordinal), the parent should NOT receive an unadorned terminal [interrupted] wake that makes the child appear finished, or the wake should clearly state that a newer run is active on that child thread.
  2. Terminal wakes for earlier superseded runs should not be delivered out of order after a newer run has already cancelled or terminated.

Actual behavior

  1. After ordinal: 1 was interrupted while ordinal: 3 was already starting/running in the child pane, the parent thread was woken with a terminal [interrupted]: ... Stopped by user message containing no indication that the child thread was actively running ordinal: 3.
  2. Because the wake looked terminal, the parent began running commands and editing files in the child's worktree concurrently with the live child run ordinal: 3, causing two agents to race on the same checkout and virtual display.
  3. When the user later cancelled the child, the parent received a [cancelled] wake for ordinal: 4 (completedAt: 00:23:50.558Z) and then afterwards received a stale [interrupted] wake for the earlier run ordinal: 3 (completedAt: 00:25:04.592Z).

Impact

Major degradation or frequent failure

Version or commit

T3 Code (Nightly) 0.1.12-nightly.20261122.5071 (0.1.12-nightly.20261122.5071)

Environment

macOS Darwin 27.3.0 (Apple Silicon), T3 Code (Nightly).app 0.1.12-nightly.20261122.5071 (0.1.12-nightly.20261122.5071), parent provider acpRegistry_devin (gemini-4-neon-high), delegated child provider acpRegistry_devin (swe-2-high, isolation: "worktree", mode: "async").

Logs or stack traces

{
  "parentThreadId": "c98b1d80-cd05-4aba-b284-e227554a1fc7",
  "childThreadId": "thread:delegated-task:command%3Amcp%3Ab53f9345-fbd8-4092-8cea-9c1880e977e3%3Adelegate-task%3Amali-batch6-finish-01",
  "recentRuns": [
    { "ordinal": 4, "status": "cancelled",   "requestedAt": "2026-11-23T00:21:31.447Z", "startedAt": null,                       "completedAt": "2026-11-23T00:23:50.558Z" },
    { "ordinal": 3, "status": "interrupted", "requestedAt": "2026-11-23T00:19:09.380Z", "startedAt": "2026-11-23T00:19:22.701Z", "completedAt": "2026-11-23T00:25:04.592Z" },
    { "ordinal": 2, "status": "cancelled",   "requestedAt": "2026-11-23T00:16:51.737Z", "startedAt": null,                       "completedAt": "2026-11-23T00:16:53.182Z" },
    { "ordinal": 1, "status": "interrupted", "requestedAt": "2026-11-22T22:08:07.868Z", "startedAt": "2026-11-22T22:08:15.976Z", "completedAt": "2026-11-23T00:19:15.607Z" }
  ]
}

Workaround

Call t3_thread_read on the child thread after any [interrupted] or [cancelled] wake to verify activeRunId === null before touching the child's worktree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions