Repository navigation
fix(claude): export background subagents, ignore api-request-blob, time model calls - #170
sergioBMilan wants to merge 3 commits into
Conversation
…span A background subagent (Agent with run_in_background, the default shape in recent Claude Code) returns async_launched at once and stops after the launching turn was exported, often while no turn is open. SubagentStop returned early (no current trace) or buffered a descriptor that no later turn could correlate, so the subagent and every tool it ran were dropped. The launching turn now records, per async launch, the trace and span id of its Agent tool. SubagentStop exports the subagent tree directly under that span, with its real SubagentStart..SubagentStop duration. Subagents that stop inside their launching turn keep the existing foreground path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Duy7FYPv9hkmbYZa3UXUao
Claude Code 2.1.3xx writes the request it replays to the model as api-request-blob records, with copies of earlier tool_use and tool_result blocks. The parser read them as assistant/user messages, so every tool was rendered twice: once complete, once pending under an empty model call, plus nameless Tool spans for the replayed results. Only conversation records (type assistant/user) are events now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Duy7FYPv9hkmbYZa3UXUao
The transcript stamps a model response only when it arrives, so every model call span started and ended at the same instant (0 s). Its request went out at the previous conversation record -- the prompt, the last tool result or the previous response -- so the call now starts there. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Duy7FYPv9hkmbYZa3UXUao
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
|
Hi Arize team, I'm contributing on behalf of my employer, BicicletasMilan, and our legal/management team would prefer to cover our contributions with a Corporate CLA rather than individual signatures. Section 4.1 of Could you share the Corporate CLA and the process to sign it? Once it's signed, how should we get our contributors recognized by the CLA bot? Should each person still comment the sign phrase, or would you add them to the allowlist? In the meantime, I'll hold off on signing the individual CLA for #170. Thanks, and thanks to @AlexZahar for the independent repro in #169. |
Summary
Three fixes to the Claude Code high-fidelity export, all needed for sessions where subagents run in the background (the default
Agentshape in recent Claude Code):Agentspan. When a turn is exported, eachasync_launchedAgent tool records its trace id and span id in session state (async_subagents).SubagentStopthen renders the subagent transcript directly under that span, with its realSubagentStart..SubagentStopduration, even if no turn is open. A subagent that stops inside its launching turn keeps the existing foreground path (buffer + merge atStop).api-request-blobrecords are ignored by the transcript parser. Only conversation records (typeassistant/user, or no type) become events, so replayed tool blocks no longer duplicate every tool or create namelessToolspans.resolves #169
Type of change
How tested
test_background_subagent_is_exported_under_its_launching_agent_spantest_background_subagent_that_stops_inside_its_turn_keeps_the_foreground_pathtest_replayed_request_blobs_are_not_eventstest_model_call_starts_at_the_record_that_sent_its_requestuv run pytest tests/ -m "not slow": 2741 passed, 3 skipped, 1 xfailed.pre-commit run --all-files: clean.claude -plaunching 3 backgroundgeneral-purposesubagents (wc,Read, a failingls), with the main agent ending its turn before they finish. Every subagent arrives under itsAgentspan with its tools (the failinglsasERROR) and model calls. Phoenix's cumulative token count on each subagent span matches the subagent transcript exactly, and model calls last 2-12 s instead of 0 s.Checklist
uv run pytest tests/ -m "not slow")uv run pre-commit run --all-files)code-reviewskill and addressed findings🤖 Generated with Claude Code
https://claude.ai/code/session_01Duy7FYPv9hkmbYZa3UXUao