Compare AIFind AIAI NewsAI How-To
About Us
PrivacyTermsFAQContactContact
AIB Inc.Company info
© 2026 AIB Inc.

Sentry Fix Restores Gemini Chat Config

Sentry Fix Restores Gemini Chat Config

DEV.to·Friday, August 14, 2026
  • •Sentry JavaScript SDK fix restores Gemini chat config attributes lost after refactor #19990
  • •Patch threads `chats.create()` model and config into `sendMessage` and `sendMessageStream` spans
  • •Tests rose from 38 files / 335 tests to 39 files / 339 tests passing
  • •Sentry JavaScript SDK fix restores Gemini chat config attributes lost after refactor #19990
  • •Patch threads `chats.create()` model and config into `sendMessage` and `sendMessageStream` spans
  • •Tests rose from 38 files / 335 tests to 39 files / 339 tests passing
  • •Sentry JavaScript SDK fix restores Gemini chat config attributes lost after refactor #19990
  • •Patch threads `chats.create()` model and config into `sendMessage` and `sendMessageStream` spans
  • •Tests rose from 38 files / 335 tests to 39 files / 339 tests passing
  • •Sentry JavaScript SDK fix restores Gemini chat config attributes lost after refactor #19990
  • •Patch threads `chats.create()` model and config into `sendMessage` and `sendMessageStream` spans
  • •Tests rose from 38 files / 335 tests to 39 files / 339 tests passing

Asuran published a DEV Summer Bug Smash submission on August 12, 2026, describing a fix for Sentry's JavaScript SDK after Gemini chat traces stopped recording the configuration used for model calls. The bug affected Sentry's Google GenAI auto-instrumentation, which is meant to attach the model, generation config and system instruction to each Gemini span (a timed trace record for one operation).

The regression came from getsentry/sentry-javascript#20086 and followed refactor #19990. Google GenAI chat usage starts with `chats.create({ model, config })`, where `config` can include temperature, top_p, top_k, max output tokens, penalties, tool list and system instruction; actual model calls then happen through `chat.sendMessage(...)` or `chat.sendMessageStream(...)`. Sentry removed the `chats.create()` span because it was not a real model call, but that also removed the place where the create-time config had been captured.

After the refactor, `chat.sendMessage()` and `chat.sendMessageStream()` spans only saw the per-call message. Attributes including `gen_ai.request.temperature`, `top_p`, `top_k`, `max_tokens`, penalties, `available_tools` and `gen_ai.system_instructions` disappeared from traces. The root cause was a deep proxy that re-proxied the chat object returned by `chats.create()` but discarded that call's arguments, leaving the message-span code without the chat config.

The proposed fix is PR getsentry/sentry-javascript#23316 on branch `fix/google-genai-chat-config-attrs`. It adds `mergeChatCreateParams`, passes the `chats.create()` arguments through the proxy, and builds message span attributes from merged parameters. The create-time config is used as the default, while a per-message config replaces it wholesale for that request, matching `@google/genai` behavior as `params.config ?? chat.config`.

The real call to Google still uses its original arguments, so the change does not alter Gemini requests. Non-chat calls such as `models.generateContent` do not receive chat context and are left unchanged. The author also deliberately left create-time `history` off message spans because it is conversation seed rather than per-message input.

Testing added a new file with four cases: config attached to `sendMessage` spans, config attached to `sendMessageStream` spans, per-message config replacing create config, and no leakage into `models.generateContent` spans. On the unfixed code, three of the four cases failed because attributes were `undefined`; with the fix, all four passed. The `@sentry/server-utils` suite increased from 38 files / 335 tests to 39 files / 339 tests, all passing. `oxlint --type-aware`, `oxfmt --check` and source-type `tsc` also passed, while unrelated pre-existing test-config `tsc` errors remained.

The author verified the fix against the live Gemini API using `@google/genai` v1.20.0, real Sentry tracing and model `gemini-2.5-flash`. A test call used temperature 0.8, topP 0.9, topK 40, maxOutputTokens 512, and system instruction "You are a friendly robot who likes to be funny." Before the fix, `gen_ai.request.model` was present but temperature, top_p, top_k, max_tokens and system instructions were missing. After the fix, the same span recorded model `gemini-2.5-flash`, temperature 0.8, top_p 0.9, top_k 40, max_tokens 512 and the system instruction. The author disclosed that Claude from Anthropic assisted development, while design, review and verification were done by the author.

Asuran published a DEV Summer Bug Smash submission on August 12, 2026, describing a fix for Sentry's JavaScript SDK after Gemini chat traces stopped recording the configuration used for model calls. The bug affected Sentry's Google GenAI auto-instrumentation, which is meant to attach the model, generation config and system instruction to each Gemini span (a timed trace record for one operation).

The regression came from getsentry/sentry-javascript#20086 and followed refactor #19990. Google GenAI chat usage starts with `chats.create({ model, config })`, where `config` can include temperature, top_p, top_k, max output tokens, penalties, tool list and system instruction; actual model calls then happen through `chat.sendMessage(...)` or `chat.sendMessageStream(...)`. Sentry removed the `chats.create()` span because it was not a real model call, but that also removed the place where the create-time config had been captured.

After the refactor, `chat.sendMessage()` and `chat.sendMessageStream()` spans only saw the per-call message. Attributes including `gen_ai.request.temperature`, `top_p`, `top_k`, `max_tokens`, penalties, `available_tools` and `gen_ai.system_instructions` disappeared from traces. The root cause was a deep proxy that re-proxied the chat object returned by `chats.create()` but discarded that call's arguments, leaving the message-span code without the chat config.

The proposed fix is PR getsentry/sentry-javascript#23316 on branch `fix/google-genai-chat-config-attrs`. It adds `mergeChatCreateParams`, passes the `chats.create()` arguments through the proxy, and builds message span attributes from merged parameters. The create-time config is used as the default, while a per-message config replaces it wholesale for that request, matching `@google/genai` behavior as `params.config ?? chat.config`.

The real call to Google still uses its original arguments, so the change does not alter Gemini requests. Non-chat calls such as `models.generateContent` do not receive chat context and are left unchanged. The author also deliberately left create-time `history` off message spans because it is conversation seed rather than per-message input.

Testing added a new file with four cases: config attached to `sendMessage` spans, config attached to `sendMessageStream` spans, per-message config replacing create config, and no leakage into `models.generateContent` spans. On the unfixed code, three of the four cases failed because attributes were `undefined`; with the fix, all four passed. The `@sentry/server-utils` suite increased from 38 files / 335 tests to 39 files / 339 tests, all passing. `oxlint --type-aware`, `oxfmt --check` and source-type `tsc` also passed, while unrelated pre-existing test-config `tsc` errors remained.

The author verified the fix against the live Gemini API using `@google/genai` v1.20.0, real Sentry tracing and model `gemini-2.5-flash`. A test call used temperature 0.8, topP 0.9, topK 40, maxOutputTokens 512, and system instruction "You are a friendly robot who likes to be funny." Before the fix, `gen_ai.request.model` was present but temperature, top_p, top_k, max_tokens and system instructions were missing. After the fix, the same span recorded model `gemini-2.5-flash`, temperature 0.8, top_p 0.9, top_k 40, max_tokens 512 and the system instruction. The author disclosed that Claude from Anthropic assisted development, while design, review and verification were done by the author.

Read original (English)·Aug 12, 2026
Coding#sentry#javascript sdk#google genai#gemini#chat config#tracing#span attributes#server utils#sendmessage#devchallenge