Skip to content

fix(server): t3_background_wait error says Workflow runs already keep the thread working - #42661

Merged
juliusmarminge merged 2 commits into
mainfrom
factory/issue-42655
Nov 25, 2026
Merged

juliusmarminge merged 2 commits into
mainfrom
factory/issue-42655

Conversation

@juliusmarminge

@juliusmarminge juliusmarminge commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

When a Claude agent passed a Workflow task ID to t3_background_wait, the error told it which IDs don't belong there but left out Workflow. Agents then told users that workflows can't be waited on, although T3 already keeps the thread working until a workflow finishes. The unmatched message of ThreadManagementBackgroundWaitError now says that subagent, Agent tool and Workflow runs already keep the thread working, and still says delegate_task IDs don't go there.

Fixes #42655

Reproduction on main

Commit: origin/main 95411e3. From a Claude Code session running inside T3 Code, I loaded t3_background_wait with ToolSearch and called it with {"taskIds":["wg53xzo6q"],"waiting":true}, an ID shaped like a workflow task ID. It failed with invalid_request and the reporter's exact text: "None of these IDs is running background work on this thread, so this request registers no wait for them. If the task already finished, read its output now. Otherwise pass the task ID of a background command or Monitor you started. Subagent, Agent tool, and delegate_task IDs don't go here." That server is this VM's preview build, not origin/main; main has the identical string in ThreadManagementService.ts (ThreadManagementBackgroundWaitError, reason 'unmatched'). I did not start a real Workflow, because agents may launch one only when the user asks. In the code, ClaudeAdapterV2.awaitBackgroundTasks matches IDs only against pendingBackgroundTasksByNativeThread, which holds only CLAUDE_OPAQUE_BACKGROUND_TASK_KINDS (local_bash). local_workflow tasks are tracked as subagent items, so a workflow ID can never match and always gets this message. CLAUDE_BACKGROUND_WAIT_INSTRUCTIONS in ClaudeAdapterV2.ts does not mention workflows either. I added a test to ThreadManagementService.test.ts that checks the unmatched message contains 'Workflow'; it fails on main with the message above.

Evidence

Run the same real Claude call on both commits: load t3_background_wait through ToolSearch, call {"taskIds":["wg53xzo6q"],"waiting":true}, then expand the raw tool response in T3 Code. No Workflow was launched. Environment: fresh isolated dev servers, synthetic project, Claude Haiku 5.5, browser viewport 1280×800 at 2× density, light theme.

Before After
95411e3cd7 e8593ef4ae
Before: error omits Workflow After: error explains Workflow runs already keep the thread working
Before recording After recording

Seed and reproduction driver · Browser steps · Runtime transcript

The call remains invalid on both commits, as expected. The verified fix is the explanatory error text.

Not shown:

  • Claude background-wait instructions were not improved by this commit: the diff changes only the unmatched error message, so the optional instruction improvement remains outstanding.
  • Actual Workflow lifetime and Working-state retention were not exercised; this follows the supplied reproduction using a Workflow-shaped ID without launching a Workflow.

Tests

  • vp test run src/orchestration-v2/ThreadManagementService.test.ts (apps/server): 39 passed, including the repro test from factory/repro-42655
  • vp run check:changed: format, lint, knip, graphql, typecheck (3 packages) and tests (2 files) all pass
  • CI on e8593ef: all 8 required checks passed

Not in this change

Who did the work

  • Written by Claude Opus 5.5, in Claude Code
  • Reviewed by GPT-6.1 Sol, in Codex, and by Claude Opus 5.5, each on its own
  • Proof captured by GPT-6.1 Sol and checked by Claude Opus 5.5

Run by the t3code factory in T3 Code.

juliusmarminge and others added 2 commits November 25, 2026 06:25
Fails on main: the message lists Subagent, Agent tool and delegate_task IDs
but not Workflow, so agents conclude workflows cannot be waited on (#42655).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the thread working

A Workflow task ID passed to t3_background_wait never matches a background
command, so the agent gets the 'unmatched' error. That error listed only
Subagent, Agent tool and delegate_task IDs as not belonging there, and agents
concluded workflows could not be waited on. Name Workflow too, and say these
runs already keep the thread working until they finish (#42655).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:XS 0-9 changed lines (additions + deletions). labels Nov 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Other scenarios

All 64 scenario measurements match main.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.4 KiB 92.4 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅

Baseline: c6c8b20 · PR result: e8593ef · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@coderabbitai

coderabbitai Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The unmatched background-task wait error now explains that delegate_task IDs are not accepted and that Subagent, Agent tool, and Workflow runs keep the thread working until completion. A unit test checks that the message mentions Workflow.

Changes: Background wait guidance

Layer / File(s) Summary
Update unmatched error guidance
apps/server/src/orchestration-v2/ThreadManagementService.ts, apps/server/src/orchestration-v2/ThreadManagementService.test.ts
The unmatched error message now names Workflow runs and explains that these runs keep the thread working. A unit test checks for “Workflow” in the message.

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: voltcrash

Merge Risk: Minimal · up to e8593

This updates an error message to mention Workflow runs. It does not change wait behavior, and no meaningful merge risk remains.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the t3_background_wait error for background-task waits now says Workflow runs already keep the thread working. It is specific and matches the changeset (the unmatched …
Linked Issues check Passed [#42655] The expected behavior requires that an unmatched workflow ID produce an error that says workflows already hold the thread, as subagents, Agent tool and delegate_task IDs do. The head changes …
Out of Scope Changes check Passed The whole-PR diff against the merge base 95411e3 touches two files. ThreadManagementService.ts changes one string in the unmatched case of ThreadManagementBackgroundWaitError, which is the erro…
Description check Passed The description follows the repository template closely. It has a clear Problem section (agents told users workflows cannot be waited on, though the thread already stays Working until a workflow finis…
Full details: Title check

Explanation

The title names the main change: the t3_background_wait error for background-task waits now says Workflow runs already keep the thread working. It is specific and matches the changeset (the unmatched message in ThreadManagementService.ts and its test). It follows a conventional commit format with a 'fix(server)' scope.

Full details: Linked Issues check

Explanation

[#42655] The expected behavior requires that an unmatched workflow ID produce an error that says workflows already hold the thread, as subagents, Agent tool and delegate_task IDs do. The head changes the unmatched message of ThreadManagementBackgroundWaitError in apps/server/src/orchestration-v2/ThreadManagementService.ts to: "Subagent, Agent tool, and Workflow runs already keep the thread working until they finish, and delegate_task IDs don't go here either." The diff shows this change and no other source change. The added test in ThreadManagementService.test.ts asserts that the message contains "Workflow". The test is a substring check and does not exercise the full wait path, but it covers the stated error requirement. The issue title and the 'Actual behavior' section also mention CLAUDE_BACKGROUND_WAIT_INSTRUCTIONS. The PR leaves that constant unchanged and states the reason (an MCP tool-use eval and model API keys are needed). The issue's expected behavior does not require that constant to change, and the issue says no eval case is needed. This deferral is noted, not treated as a failure. The coding requirement for the error text is met.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff against the merge base 95411e3 touches two files. ThreadManagementService.ts changes one string in the unmatched case of ThreadManagementBackgroundWaitError, which is the error text the linked issue targets. ThreadManagementService.test.ts adds one test that checks that message. Both changes connect directly to #42655. No unrelated code, refactoring, or configuration change appears in the diff. The PR description's deferred items (CLAUDE_BACKGROUND_WAIT_INSTRUCTIONS, open PR #37015) are not implemented here, so they add no out-of-scope change.

Full details: Description check

Explanation

The description follows the repository template closely. It has a clear Problem section (agents told users workflows cannot be waited on, though the thread already stays Working until a workflow finishes), a Change section (the unmatched message of ThreadManagementBackgroundWaitError now names Subagent, Agent tool, and Workflow runs), a Scope section linking issue #42655, and a Verification section with specific focused test commands, observed results (39 passed), a before/after reproduction with evidence, and an explicit list of what was not exercised. It also names the models and harness used, as the template asks. The description is complete and specific, so it passes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between c6c8b20 and e8593ef.

Files selected for processing: 2

  • apps/server/src/orchestration-v2/ThreadManagementService.test.ts
  • apps/server/src/orchestration-v2/ThreadManagementService.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@juliusmarminge
juliusmarminge merged commit 6adff22 into main Nov 25, 2026
39 checks passed
@juliusmarminge
juliusmarminge deleted the factory/issue-42655 branch November 25, 2026 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: t3_background_wait error and Claude instructions don't say Workflow tasks already hold the thread

1 participant