Skip to content

fix(google_genai): Make sure streaming spans attach to correct parent#484

Merged
Abhijeet Prasad (AbhiPrasad) merged 2 commits into
mainfrom
livekit-agents-vertex-not-in-trace
Jun 1, 2026
Merged

fix(google_genai): Make sure streaming spans attach to correct parent#484
Abhijeet Prasad (AbhiPrasad) merged 2 commits into
mainfrom
livekit-agents-vertex-not-in-trace

Conversation

@AbhiPrasad
Copy link
Copy Markdown
Member

Implemented a red/green fix for the Google GenAI streaming parent-span issue.

This was noticed when examining a trace w/ livekit agents + vertex ai.

What was happening:

  • In trace.json, generate_content_stream LLM spans were parented to the outer/root span instead of the correct parent.
  • Root cause is in py/src/braintrust/integrations/google_genai/tracing.py: streaming wrappers created the Braintrust span only when the returned stream was consumed, not when the stream was created.
  • Vertex creates the stream while the session parent is active, but consumes it later in a different context, so the parent was lost.

Fix:

  • Capture the active Braintrust parent when generate_content_stream / async stream is created.
  • Re-apply that captured parent when the stream is later consumed.

@AbhiPrasad Abhijeet Prasad (AbhiPrasad) force-pushed the livekit-agents-vertex-not-in-trace branch from ee60098 to 7176584 Compare June 1, 2026 15:19
@AbhiPrasad Abhijeet Prasad (AbhiPrasad) merged commit b3f292a into main Jun 1, 2026
82 checks passed
@AbhiPrasad Abhijeet Prasad (AbhiPrasad) deleted the livekit-agents-vertex-not-in-trace branch June 1, 2026 15:29
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.

2 participants