fix: correct concurrent subagent trace parenting#302
Merged
Kyle-Verhoog merged 2 commits intomasterfrom Mar 16, 2026
Merged
Conversation
2118af4 to
3cf7a0e
Compare
sabrenner
approved these changes
Mar 16, 2026
Contributor
sabrenner
left a comment
There was a problem hiding this comment.
lgtm! just a couple small non-blocking nits but 🚢
When Claude Code spawns multiple concurrent subagents (parallel Task tool calls), the LIFO agent_span_stack caused spans to get parented to the wrong subagent. Fix by using the parent_id captured at PreToolUse time, tracking LLM-to-agent mappings in the link tracker, and adding prompt-based agent matching for first LLM calls. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…_prompt Address review nit — build request_text via direct string concatenation instead of accumulating into a list and joining. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
f7742f7 to
5601412
Compare
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.
Summary
agent_span_stackcaused spans to get parented to the wrong subagentactive_agentsdict to SessionState for concurrent subagent resolutiontest_concurrent_subagents_parent_correctlyTest plan
Claude session:
290749d0-c759-42b7-8d1b-d4edb76c65d3Resume:
claude --resume 290749d0-c759-42b7-8d1b-d4edb76c65d3🤖 Generated with Claude Code