Repository navigation
fix(server,web,mobile): keep a subagent's own work inside its spawn card - #539
Merged
Merged
Conversation
Claude streams tool-call deltas only for the parent conversation, so a subagent's tool calls reach the adapter only as whole assistant snapshots. task_started looked for the launching call among streamed in-flight tools, never found it, and so never stamped agentId. Every background shell and nested agent a subagent started then rendered in the parent timeline as "Received N updates" rows and one-agent spawn cards placed wherever it happened to start. The adapter now records the owner of each tool call seen in a subagent snapshot and uses it when the task starts. A resumed subagent keeps its owner and still resolves its messages, which keep the original Agent call as their parent. Web and mobile fold a nested agent into its owner's spawn card. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
A Claude subagent's own background shells and nested agents leaked into the parent timeline as "Received N updates" rows and one-agent "Kicked off 1 subagent" cards. The server now attributes those tasks to the subagent that started them, and web and mobile keep them inside that subagent's single spawn card.
Problem
When a Claude subagent started its own background shells or its own agents, the parent thread's timeline filled with stray rows. Each finished shell became a "Received N updates" row. Each nested agent became a separate "Kicked off 1 subagent" card, placed wherever it happened to start, often between unrelated messages.
The clients already hide a subagent's internal work, but only when the task carries
agentId(its owner). The Claude adapter never set it. It looked for the launching tool call among streamed tool calls, but Claude streams tool-call deltas only for the parent conversation. A subagent's tool calls arrive only as wholeassistantsnapshots tagged withparent_tool_use_id, and the adapter used those snapshots only to refine the model name. In practice no task row ever gotagentId.Upstream has the same gap. The open related PRs don't cover this path: pingdotgg#10575 still depends on child stream events, and pingdotgg#14272 and pingdotgg#14031 address resumed-subagent labels and reactivation.
Fix
task_starteduses that record when no streamed call matches. A subagent's shells therefore carry the subagent'sagentId, and so do its nested agents. A resumed subagent keeps its owner. Its later messages also still resolve to it, because they keep the original Agent call as their parent even though the SDK re-registers the task under theSendMessagecall.agentId.Existing threads are not repaired, because their persisted task rows have no owner to group by.
Validation
sleepshell and a nested background agent, and the nested agent started its own shell. The persisted task rows had the expected owners:ClaudeAdapter.test.ts,session-logic.test.tsandthreadActivity.test.tspass, and server, web and mobile typecheck.Written by an agent (Claude Code, claude-opus-5-5).