Repository navigation
Conversation
A teammate launch was marked async, so get_pending_agent_tool_use_ids held the whole turn open until a task-notification arrived. Teammates never send one: they report through team-message rows. The turn only shipped at SessionEnd, which is often cancelled during shutdown, so the main turn, its generations and tool spans were lost entirely. Emit teammate turns at their own Stop. The teammate transcript is attached on a later firing when it is on disk; the emission progress cursors already support adding children to an emitted root without duplicating it. Part of langfuse#100.
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
A teammate launch (
toolUseResult.status == "teammate_spawned") was treated as an async agent launch.get_pending_agent_tool_use_ids()therefore held the entire turn open until a<task-notification>arrived. Teammates never send one — they report through team-message rows — so the turn was only emitted at SessionEnd, which Claude Code often cancels during shutdown (#100). In the reported data, 18 of 220 agent-team members were emitted, and the main turn was held with them.Changes
teammate_spawnedas an async launch inget_async_launch_flag_from_row(). AsyncAgent/Tasklaunches (status: async_launched) keep the existing deferral until their notification arrives.test_named_teammate_transcript_attaches_to_its_launch_at_session_end_flushto model the late transcript: first Stop emits the root +Tool: Agent, then the transcript appears, then SessionEnd attachesSubagent: Build issue 4without a second root.Tests
uv run --group dev pytest -q tests/integration/test_emit_new_turns_from_transcript.py -k teammate: 1 passed.HOME/~, log encoding) that fail identically on unmodifiedmain.uvx ruff check --select F,E9 .: all checks passed.This fixes the teammate-deferral cause in #100. Resumed and nested teammate transcripts described in the same issue need separate offset/recursion work and are not changed here.