Skip to content

feat: correlate telemetry spans with the conversation - #7533

Merged
chenghao-mou merged 2 commits into
mainfrom
chenghao/feat/AGT-3603-conversation-span-correlation
Oct 4, 2026
Merged

chenghao-mou merged 2 commits into
mainfrom
chenghao/feat/AGT-3603-conversation-span-correlation

Conversation

@chenghao-mou

Copy link
Copy Markdown
Member

Spans from speech processing and tools need the same conversation ID for session grouping. Attach the room SID through the LiveKit tracer, preserve explicit IDs, and omit the field outside a job.

Adapts @SanjuMLGeek’s proposal in #7396 and handles positional attributes without mutating caller mappings.

Stacked on #7532.

Addresses AGT-3603

Request summary and agent context

Model: GPT-6-Astra

Split the proposed telemetry improvements into focused PRs that are easy to review and revert. Use general problem summaries and omit customer details.

@chenghao-mou
chenghao-mou force-pushed the chenghao/feat/AGT-3603-conversation-span-correlation branch from c90da2f to 9f782ff Compare September 29, 2026 11:23
Base automatically changed from chenghao/fix/AGT-3602-fallback-token-usage to main October 4, 2026 15:16
Co-authored-by: Sanjay Kukadiya <43816307+SanjuMLGeek@users.noreply.github.com>
@chenghao-mou
chenghao-mou force-pushed the chenghao/feat/AGT-3603-conversation-span-correlation branch from 9f782ff to 735f51e Compare October 4, 2026 15:16
@chenghao-mou
chenghao-mou marked this pull request as ready for review October 4, 2026 15:17
@chenghao-mou
chenghao-mou requested a review from a team as a code owner October 4, 2026 15:17

@devin-ai-integration devin-ai-integration Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Note

Newer findings are available below. Devin Review posted a newer report on this PR, in addition to the findings presented here.

🔍 Devin Review: 1 flag

Not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)

Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

Devin Review

Comment on lines -425 to -426
if (conv := _conversation_id()) is not None:
attrs[trace_types.ATTR_GEN_AI_CONVERSATION_ID] = conv

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 External GenAI spans lose conversation grouping

When an integrator calls set_tool_attributes on a span from their own tracer, it no longer receives a conversation ID. Only the LiveKit tracer injects that ID, so external tool spans disappear from conversation-grouped views.

Learn more

The exported GenAI attribute setters accept any OpenTelemetry span. Previously, set_tool_attributes attached the room SID to a recording span even if another tracer created it. The LiveKit tracer now adds that attribute at span creation, but an SDK tracer obtained from a provider does not pass through that wrapper. The same loss affects the request, agent, and workflow setters when used with external spans. An integrator using the public setters with an SDK tracer therefore emits GenAI spans without conversation grouping.

Example: Inside a job for room RM_42, an integration creates span = provider.get_tracer("custom").start_span("function_tool"), then calls gen_ai.set_tool_attributes(span, name="lookup"). The exported span has gen_ai.tool.name, but no gen_ai.conversation.id; previously it carried RM_42.

Recommended fix: Preserve a fallback in all four GenAI setters for spans without an existing conversation ID. Ensure that fallback does not overwrite an explicit ID already present on a span created through the LiveKit tracer or supplied by its caller.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

external tracer will have to take care of conversation id themselves when choosing not to use ours

@davidzhao davidzhao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

lg

@chenghao-mou
chenghao-mou merged commit 11af1ba into main Oct 4, 2026
26 checks passed
@chenghao-mou
chenghao-mou deleted the chenghao/feat/AGT-3603-conversation-span-correlation branch October 4, 2026 20:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants