Skip to content

fix(tracing): nest subagent turns under their spawn_agent call - #109

Merged
hassiebp merged 1 commit into
langfuse:mainfrom
pushkar:fix/subagent-spawn-parentage
Oct 6, 2026
Merged

hassiebp merged 1 commit into
langfuse:mainfrom
pushkar:fix/subagent-spawn-parentage

Conversation

@pushkar

@pushkar pushkar commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Subagent turns currently nest under the parent turn root, so in Langfuse they show up as siblings of the spawn_agent call that started them instead of under it. This parents each subagent rollout on its matching spawn_agent tool observation.

Changes

  • parseSession records the spawn call id for each subagent thread (subagentSpawnCallIds), from spawn_agent tool output, collab_agent_spawn_end, and sub_agent_activity.
  • Also recognizes the item_completed / SubAgentActivity layout that Codex 0.157.x writes for subagent starts.
  • emitTurn parents the child rollout on the matching spawn_agent observation, falling back to the turn root when there's no match. So the old behavior is the fallback, not a regression.

Testing

  • pnpm lint and pnpm test pass (121 tests).
  • New parse test for the item_completed layout. Existing parse tests now assert the thread to call-id mapping.
  • Trace tests assert that the subagent turn's parent is the spawn_agent span, in both standalone and attached (external parent) mode.
Before After
mcp-and-subagents-before mcp-and-subagents-after

Record the spawn call id for each subagent thread and parent the child
rollout on the matching spawn_agent tool observation, falling back to
the turn root when no match is found. Also recognize the item_completed
SubAgentActivity layout that Codex 0.157.x writes for subagent starts.
Copilot AI balanced review requested due to automatic review settings October 2, 2026 16:18

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@hassiebp
hassiebp merged commit 25c4b9f into langfuse:main Oct 6, 2026
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants