fix(tracing): name streamed task spans after the run's own workflow - #4167
Merged
seratch merged 1 commit intoAug 4, 2026
Merged
Conversation
A task span represents one top-level Runner invocation, and the non-streaming path names it from the workflow name resolved for that run. The streaming path instead named it from `streamed_result.trace or get_current_trace()`. Those two agree only when the run creates its own trace: inside an existing trace `create_trace_for_run` returns `None`, so `streamed_result.trace` is `None` and the streamed run fell back to the enclosing trace's name. The result is that an orchestration trace that fans out several streamed sub-runs gets task spans all labelled with the orchestrator's workflow name, so they cannot be told apart, while the same code run non-streamed labels them correctly. `RunConfig(workflow_name=...)` is silently ignored for streamed runs nested in a trace. Pass the already-resolved workflow name into `start_streaming` and use it, which also drops the `current_trace` guard the non-streaming path never had.
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 task span represents one top-level
Runnerinvocation. The non-streaming path names it from the workflow name resolved for that run; the streaming path named it fromstreamed_result.trace or get_current_trace().Those two agree only when the run creates its own trace. Inside an existing trace
create_trace_for_runreturnsNone, sostreamed_result.traceisNoneand the streamed run fell back to the enclosing trace's name. An orchestration trace that fans out several streamed sub-runs therefore gets task spans all labelled with the orchestrator's workflow name — indistinguishable from each other and from the outer trace — while the same code run non-streamed labels them correctly.RunConfig(workflow_name=...)is effectively ignored for streamed runs nested in a trace.This passes the already-resolved workflow name into
start_streamingand uses it, which also drops acurrent_traceguard the non-streaming path never had (that variable existed only to supply the name, and itsNonebranch is unreachable —create_trace_for_runreturnsNoneonly whenget_current_trace()is truthy).start_streaminglives inagents.run_internaland is not a public export, so the new keyword-only argument is not a public API change. No persisted schema or wire format is affected; only exported telemetry changes, and it changes toward the documented semantics and toward the non-streamed path.Present in released v0.19.2.
Test plan
tests/test_agent_tracing.py::test_wrapped_run_task_span_uses_run_workflow_nameruns the same agent non-streamed and streamed inside one outer trace and asserts both task spans use the run's own workflow name. It fails onmainwithAt index 1 diff: 'outer_workflow' != 'inner_workflow'and passes with this change.uv run pytest tests/test_agent_tracing.py tests/tracing→ 72 passed.bash .agents/skills/code-change-verification/scripts/run.sh→ all commands passed.Issue number
N/A — found while auditing tracing parity between the streamed and non-streamed runners.
Checks
.agents/skills/code-change-verification/scripts/run.sh/reviewbefore submitting this PR