t3code icon indicating copy to clipboard operation
t3code copied to clipboard

[Bug]: A follow-up delegated task takes its result from the turn that queued a continuation on its own thread; the original task waits for it

Open baohappy02 opened this issue 3 weeks ago • 0 comments

Before submitting

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

Area

apps/server

Steps to reproduce

  1. delegate_task a child whose turn calls t3_thread_send on its own thread (mode: "queue", freshContext: true, message "reply FINAL-B") and then ends with "HANDOFF-A".
  2. The queued run runs and replies FINAL-B. The task's result is FINAL-B: correct, the parent waits for the queued run.
  3. Send the finished child a follow-up with t3_thread_send (a new task): same steps, ending with "HANDOFF-C", the queued run replying FINAL-D.
  4. task_status of the follow-up task.

Expected behavior

The follow-up task waits for the run its child queued on its own thread, as the original task does: summary FINAL-D.

Actual behavior

summary is HANDOFF-C, delivered when that turn ends; FINAL-D shows only as latestTerminalSummary and never reaches the parent as the task's result.

Source (apps/server/src/orchestration-v2/Orchestrator.ts): recordSubagentFollowup tags only runs sent by the parent, the user or a notification with delegatedTaskId, so the self-queued run is untagged. finalizeAppOwnedSubagentTask then picks the latest run tagged with the follow-up task's id (the queuing turn), which is terminal, and finalizes. The original task is guarded in finalizeAppOwnedSubagent by delegatedTaskProgress(...).state !== "result_available", which counts the queued run as active; follow-up tasks skip that guard.

Impact

Major degradation or frequent failure

Version or commit

0.1.8-nightly.20261106.4288

Environment

macOS 26.5, desktop nightly, Claude provider

Logs or stack traces


Screenshots, recordings, or supporting files

No response

Workaround

The child's last line asks the parent to t3_thread_wait the child thread with untilDelegatedWorkSettled: true and read its last message.

baohappy02 avatar Nov 07 '26 14:11 baohappy02