Skip to content

feat(hook): trace Claude Code subagent transcripts#11

Open
milanagm wants to merge 21 commits into
langfuse:mainfrom
milanagm:feature/lfe-10510-trace-subagent-transcripts
Open

feat(hook): trace Claude Code subagent transcripts#11
milanagm wants to merge 21 commits into
langfuse:mainfrom
milanagm:feature/lfe-10510-trace-subagent-transcripts

Conversation

@milanagm

@milanagm milanagm commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes LFE-10510

Adds tracing support for Claude Code subagent transcripts so Agent/Task work is included in the same Langfuse conversation trace instead of being missed or emitted as disconnected traces.

This PR:

  • discovers Claude Code subagent transcript files from the transcript subfolder
  • maps Agent/Task tool calls to their corresponding subagent JSONL files
  • emits subagent LLM calls and tool calls under a dedicated subagent span
  • handles task notifications, including notifications that only provide a task id
  • avoids tracing raw task notification rows as standalone conversation turns
  • updates observation names to use Conversational Turn, LLM Call, and Subagent LLM Call
  • avoids sending full local transcript paths in metadata

Testing

Manually replayed existing Claude Code transcripts (JSONL files) through the hook and verified the resulting Langfuse traces in the dashboard as well as "live" testing on cloud.

Checked scenarios:

  • single async Agent with subagent transcript
  • multiple parallel Agent calls
  • task notifications with explicit tool-use-id
  • task notifications that require task-id to tool-use-id mapping via subagent metadata

Also ran:

PYTHONPYCACHEPREFIX=/tmp/pycache python3 -m py_compile hooks/langfuse_hook.py
git diff --check

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.

1 participant