Skip to content

fix(google-genai): Map messages to the gen_ai conventions - #24352

Merged
logaretm merged 6 commits into
developfrom
awad/google-genai-message-conventions
Sep 14, 2026
Merged

logaretm merged 6 commits into
developfrom
awad/google-genai-message-conventions

Conversation

@logaretm

@logaretm logaretm commented Sep 12, 2026

Copy link
Copy Markdown
Member

Google GenAI reported its own Content shape, so no input message rendered, fixed by mapping parts and roles to the conventions.

I added tests covering each part kind, an object systemInstruction, and a tool call's output messages.

closes #24327

Google's `Content` was reported verbatim, so `gen_ai.input.messages` carried
`{role, parts: [{text}]}` instead of `{role, parts: [{type, content}]}`. The
product's normalizer drops parts it cannot type, so none of the input messages
rendered, and `role: "model"` is not a `gen_ai` role.

Every part kind is now translated (text, thought, function call, function
response, inline data, file data), `model` becomes `assistant`, and bare parts
in one array stay one turn so a multimodal message is not split.

A `config.systemInstruction` passed as a `Content` object also never reached
`gen_ai.system_instructions`: it was routed through `extractSystemInstructions`,
which only reads `.content`. It is now read straight off the config.

Also sets `gen_ai.output.messages`, which this integration never wrote. Relay's
migration of the deprecated `gen_ai.response.text` is lossy for tool calls, so a
turn that only called a tool rendered an empty Output.

Fixes #24327
@github-actions

github-actions Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 28.96 kB - -
@sentry/browser - with treeshaking flags 27.26 kB - -
@sentry/browser - with treeshaking flags tracing without tracing 27.15 kB - -
@sentry/browser (incl. Tracing) 50.51 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 50.52 kB - -
@sentry/browser (incl. Tracing, Profiling) 53.5 kB - -
@sentry/browser (incl. Tracing, Replay) 90.07 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 79.16 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 94.77 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 107.73 kB - -
@sentry/browser (incl. Feedback) 46.46 kB - -
@sentry/browser (incl. sendFeedback) 34.01 kB - -
@sentry/browser (incl. FeedbackAsync) 39.12 kB - -
@sentry/browser (incl. Metrics) 29.98 kB - -
@sentry/browser (incl. Logs) 30.24 kB - -
@sentry/browser (incl. Metrics & Logs) 30.91 kB - -
@sentry/react 30.72 kB - -
@sentry/react (incl. Tracing) 52.81 kB - -
@sentry/vue 36.2 kB - -
@sentry/vue (incl. Tracing) 52.76 kB - -
@sentry/svelte 28.98 kB - -
CDN Bundle 30.7 kB - -
CDN Bundle (incl. Tracing) 51.01 kB - -
CDN Bundle (incl. Logs, Metrics) 32.98 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 52.99 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 73.67 kB - -
CDN Bundle (incl. Tracing, Replay) 88.56 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 90.53 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 94.64 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 96.63 kB - -
CDN Bundle - uncompressed 90.83 kB - -
CDN Bundle (incl. Tracing) - uncompressed 152.33 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 97.41 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 158.29 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 226.82 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 271.9 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 277.85 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 285.6 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 291.54 kB - -
@sentry/nextjs (client) 55.13 kB - -
@sentry/sveltekit (client) 50.93 kB - -
@sentry/core/server 37.13 kB - -
@sentry/core/browser 13.66 kB - -
@sentry/node 130.42 kB +0.4% +514 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 81.83 kB - -
@sentry/node - without tracing 89.62 kB +0.04% +32 B 🔺
@sentry/node - without channel injection 109.35 kB +0.51% +550 B 🔺
@sentry/aws-serverless 97.84 kB +0.03% +20 B 🔺
@sentry/cloudflare (withSentry) - minified 203.36 kB - -
@sentry/cloudflare (withSentry) 506.44 kB - -

View base workflow run

@logaretm

Copy link
Copy Markdown
Member Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale Bugbot comment from a previous run.

@logaretm
logaretm marked this pull request as ready for review September 12, 2026 00:40
@logaretm
logaretm requested review from a team as code owners September 12, 2026 00:40
@logaretm
logaretm requested review from JPeer264 and mydea and removed request for a team September 12, 2026 00:40
@JPeer264
JPeer264 requested a review from RulaKhaled September 14, 2026 09:54

@JPeer264 JPeer264 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.

implementation looks fine IMO. Would wait for @RulaKhaled for a better judgement though

@RulaKhaled RulaKhaled left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm! This used to be a requirement of otel conventions which we no longer follow

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 4745a84. Configure here.

}

// Part kinds we don't know yet render as JSON rather than disappearing.
return { type: 'object', content: part };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thought signatures recorded as object parts

Medium Severity

partToMessagePart never handles thoughtSignature, so a part that only carries that field hits the unknown-part fallback and stores the raw base64 blob on gen_ai.input.messages and gen_ai.output.messages. Thinking models attach these signatures on later turns, which inflates span payloads the same way inlineData.data would.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 4745a84. Configure here.

@logaretm
logaretm merged commit 4c64ad6 into develop Sep 14, 2026
463 of 465 checks passed
@logaretm
logaretm deleted the awad/google-genai-message-conventions branch September 14, 2026 17:57
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.

Google GenAI Integration maps content incorrectly

3 participants