Skip to content

fix(server): Claude subagent cards stay grouped when they update during a later turn - #41607

Open
cravvnn wants to merge 3 commits into
pingdotgg:mainfrom
cravvnn:fix/claude-subagent-group-turn
Open

cravvnn wants to merge 3 commits into
pingdotgg:mainfrom
cravvnn:fix/claude-subagent-group-turn

Conversation

@cravvnn

@cravvnn cravvnn commented Nov 23, 2026

Copy link
Copy Markdown

Problem

When Claude runs several background subagents, the "N subagents" group card in the parent thread splits while they work. Some subagents drop out of the group into their own row below it, and the group's count goes down (I saw 5 become 3, with 2 outside the box). Expected: all subagents launched together stay in one group until they finish.

Change

Clients group subagent cards by (runId, providerTurnId). ClaudeAdapterV2 keeps a subagent card's runId and ordinal fixed, but it stamped every card update with input.context.providerTurnId, which is whatever Claude turn is active at that moment. A background subagent that reports progress or finishes after the parent has moved to a later turn (for example, the wake turn for a sibling's completion) took that turn's id and left its group. The Codex adapter already pins its cards to the launching turn (parentContext.providerTurnId).

ActiveClaudeSubagent now records the providerTurnId the card was launched in and reuses it for every update. A resumed subagent that moves to the current run (the existing runId reassignment) also takes the current turn, so its turn stays consistent with its runId.

Scope

Bug fix in one adapter. Small fix for an obvious grouping bug, so no separate issue. #41358 fixes the same class of problem (late updates moving an item to a newer run) for tool items in EventSink, but it does not cover subagent cards.

Verification

  • Added keeps a background subagent's card on the turn that launched it to ClaudeAdapterV2.test.ts. Two background subagents start in turn 1. The first finishes and wakes the parent. The second reports progress and finishes during the wake turn. On main it fails: the second card moves to turn:attempt-claude-card-turn-2. With this change it passes.
  • The rest of ClaudeAdapterV2.test.ts (491 tests) passes. 3 tests fail the same way on main and on this branch on my Windows machine: the native fork cwd test and two "model change after a Claude Code update" tests. They look environment-specific and are unrelated to this change.
  • apps/server typecheck (effect-tsgo tsrs --noEmit) has no errors, and fmt, lint and knip pass.
  • Not checked: I did not reproduce the fix end to end in a running app. The bug needs several real background Claude subagents finishing at different times.

Model: Claude Opus 5.5 in T3 Code

@github-actions github-actions Bot added vouch:unvouched Author is not yet trusted in the VOUCHED list. size:S 10-29 changed lines (additions + deletions). labels Nov 23, 2026
@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The Claude adapter now stores the provider turn associated with each subagent and uses that ID for subagent turn items. A regression test checks two background subagents that complete across the original and continuation turns.

Changes: Subagent turn association

Layer / File(s) Summary
Track provider turns for subagents
apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.ts, apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts
The adapter stores a provider turn ID for each subagent and uses it when creating subagent turn items. New or reassigned subagents receive the current turn ID; other subagents retain their existing association. The test checks that two completed subagent cards share the launching provider turn ID across a continuation.

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

Change: Bug fix

Possibly related issues

  • pingdotgg/t3code#31697 — The PR changes provider-turn association for resumed subagents. It does not change the client fold logic described in the issue, so the reported case may remain open.

Suggested reviewers: juliusmarminge, sshdotcodes

Merge Risk: Minimal · up to 7bf1d

Subagent cards now stay grouped with the turn that launched them when they update during a later turn. No concrete merge-blocking risk was found; the change is small and covered by a regression test.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the fix (Claude subagent cards staying grouped when they update during a later turn), which matches the changeset: ActiveClaudeSubagent now keeps the launching providerTurnId and reuse…
Description check Passed The description covers the problem, the change, the scope, and the verification steps. It follows the template's section headings (Problem, Change, Scope, Verification) and gives reproduction context,…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the fix (Claude subagent cards staying grouped when they update during a later turn), which matches the changeset: ActiveClaudeSubagent now keeps the launching providerTurnId and reuses it for card updates. It is specific and follows conventional commit style. Scope is the server, which matches the changed adapter.

Full details: Description check

Explanation

The description covers the problem, the change, the scope, and the verification steps. It follows the template's section headings (Problem, Change, Scope, Verification) and gives reproduction context, the root cause, a linked related PR, and a specific failing-then-passing test. It names the model used, as the template asks. It does not include screenshots, which the template requires only for UI changes; this change is server-only. The Scope section does not link an issue and gives a reason for not linking one, which the template allows for small obvious fixes.

Finishing Touches

Generate unit tests (beta)

  • 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 0715e61 and 7bf1da1.

Files selected for processing: 1

  • apps/server/src/orchestration-v2/Adapters/ClaudeAdapterV2.test.ts

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

@juliusmarminge juliusmarminge added the takeover:in-progress A takeover lead is working on this PR label Nov 23, 2026
juliusmarminge and others added 2 commits November 23, 2026 19:01
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test fed the second subagent's progress before the wake turn started, so it ran under the launching turn and passed without the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

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

Labels

size:S 10-29 changed lines (additions + deletions). takeover:in-progress A takeover lead is working on this PR vouch:unvouched Author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants