Skip to content

[Bug]: t3_thread_read reports cancelled after a queued run is removed or steered while an earlier run completes #46106

Done

Description

@smirea

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. Start T3 Code with defaultRuntimeMode: "approval-required" and the Replay (dev) provider.
  2. Add a project and start a thread with the approval replay recording (so run 1, ordinal:1, pauses waiting on approval).
  3. While run 1 is active, queue a follow-up message: t3 thread send <threadId> "Queued follow-up" (creates run 2, ordinal:2, status queued).
  4. In the web client, remove the queued message (Remove queued message) — or promote it to steer (Send now). Run 2 transitions to status: "cancelled" with startedAt: null.
  5. Click Approve so run 1 completes cleanly.
  6. Compare t3 thread list --project <project> --json (t3_thread_list) with t3 thread show <threadId> --json (t3_thread_read).

The same mismatch affects t3_thread_wait with no runId: calling it while run 1 is still running returns run 2 (status: "cancelled") immediately instead of waiting for run 1, and calling it after run 1 finishes still returns run 2 (status: "cancelled").

Root cause: OrchestratorMcpService.threadDetail derives thread.status and thread.latestRunId from ThreadManagementService.latestRun(projection) (raw highest ordinal) instead of reusing the already-loaded shell (presentedShellRunId / latestUnheldRun) that t3_thread_list uses, and ThreadManagementService.waitForThread uses the same raw latestRun when runId is omitted.

Expected behavior

t3_thread_read (t3 thread show) agrees with t3_thread_list and the UI shell (latestUnheldRun / presentedShellRunId, #35661; aligned with t3_thread_read in #36610): a queued run cancelled before it started while an earlier run outlived it does not replace that run as latest, so thread.status is "completed" and thread.latestRunId is ordinal:1. t3_thread_wait with no runId waits on and returns ordinal:1.

Actual behavior

After run 1 finishes cleanly:

  • t3_thread_list (t3 thread list) reports status: "completed" and latestRunId: "...:ordinal:1".
  • t3_thread_read (t3 thread show) reports status: "cancelled" and latestRunId: "...:ordinal:2".
  • t3_thread_wait without runId returns ordinal:2 (status: "cancelled") immediately even while run 1 is still running, and after run 1 completes.

Impact

Minor bug or occasional failure

Version or commit

v0.1.14-nightly.20261129.5452 (58a4e59962) and main @ e4c315a896 (also observed on 0.1.13)

Environment

Reproduced in an isolated instance on macOS 27.2.1 (arm64), Node v26.13.1, headless Chromium with Replay (dev) (no provider account required; platform-independent server behavior). Originally hit on 0.1.13 after a queued follow-up on a delegated thread was promoted to steer (ordinal:2 cancelled at 18:57:31Z with startedAt: null, ordinal:1 completed cleanly at 19:12:21Z).

Logs or stack traces

t3_thread_list -> status: "completed", latestRunId: "run:thread:...:ordinal:1"
t3_thread_read -> status: "cancelled", latestRunId: "run:thread:...:ordinal:2"

Screenshots, recordings, or supporting files

Base df2cbe3961: t3_thread_list reports completed while t3_thread_read reports cancelled

Workaround

Check t3_thread_list for the thread's shell status, or inspect recentRuns in t3_thread_read instead of thread.status / thread.latestRunId.

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