Skip to content

fix(model): omit request model attribute instead of setting 'unknown' - #25379

Closed
kashish00208 wants to merge 2 commits into
getsentry:developfrom
kashish00208:fix/remove-unknown-model-fallback
Closed

kashish00208 wants to merge 2 commits into
getsentry:developfrom
kashish00208:fix/remove-unknown-model-fallback

Conversation

@kashish00208

Copy link
Copy Markdown

Summary

Fixes #25353

Fixes an issue where AI spans defaulted gen_ai.request.model to 'unknown' and generated span names like <operation> unknown when no model was provided.

Changes

Across all AI integrations (openai, anthropic-ai, google-genai, langchain, workers-ai):

  • Removed 'unknown' fallback return values from model extraction helpers.
  • Omitted gen_ai.request.model attribute when no model can be resolved.
  • Updated span name formatting so spans are named <operation> instead of <operation> unknown when model is undefined (consistent with and without span streaming).

Affected Integrations

  • packages/server-utils/src/ai/openai/ & integrations/openai.ts
  • packages/server-utils/src/ai/anthropic-ai/ & integrations/anthropic.ts
  • packages/server-utils/src/ai/google-genai/ & integrations/google-genai.ts
  • packages/server-utils/src/ai/langchain/
  • packages/server-utils/src/ai/workers-ai/

Test Plan

  • Verified that gen_ai.request.model is not set when model is absent.

@kashish00208
kashish00208 requested a review from a team as a code owner October 15, 2026 07:02
@kashish00208
kashish00208 requested review from JPeer264 and mydea and removed request for a team October 15, 2026 07:02
@github-actions github-actions Bot added the external PR from an external contributor label Oct 15, 2026

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

[GEN_AI_OPERATION_NAME]: operationName,
[SENTRY_ORIGIN]: WORKERS_AI_ORIGIN,
[GEN_AI_REQUEST_MODEL]: typeof model === 'string' ? model : 'unknown',
[GEN_AI_REQUEST_MODEL]: typeof model === 'string',

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Workers AI records boolean as model

High Severity

GEN_AI_REQUEST_MODEL and the span-name modelName are assigned typeof model === 'string' (a boolean) instead of the model id. Every Workers AI span therefore reports true/false as the request model, and static span names become values like chat true rather than the real model.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f459c34. Configure here.

Comment thread packages/server-utils/src/ai/openai/index.ts
Comment thread packages/server-utils/src/ai/google-genai/index.ts
Comment thread packages/server-utils/src/integrations/google-genai.ts
operationName: string,
): void {
// Store embeddings input on a separate attribute
if (operationName === 'embeddings' && 'input' in params) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Fix PR has no covering tests

Medium Severity

This is a fix PR but the diff has no unit, integration, or E2E tests for omitting gen_ai.request.model or for the new span-name behavior. Existing tests still expect 'unknown' (and 'chat unknown' / 'embeddings unknown' in static mode) and were not updated, so the regression this PR claims to fix is not covered. Flagged because the review rules require a fix PR to include a test that fails without the change and passes with it.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit f459c34. Configure here.

@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 4 potential issues.

There are 6 total unresolved issues (including 2 from previous reviews).

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit f339a32. Configure here.

return originalResult.then(result => {
addResponseAttributes(span, result, options.recordOutputs, operationName);
return originalResult.then((result) => {
addResponseAttributes(span, result, options.recordOutputs);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Decide spans lose recorded outputs

High Severity

The non-streaming OpenAI path now calls addResponseAttributes without operationName. Decision answers are only recorded when that argument is 'decide', so gen_ai.output_messages is no longer set on decisions.create spans.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f339a32. Configure here.

span: Span,
params: Record<string, unknown>,
operationName: string,
): void {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Decide inputs overwritten as chat messages

High Severity

The early return that skipped addRequestAttributes for decide operations was removed. Decision input is already recorded in evaluation format at span start; this path now re-reads params.input as chat messages and overwrites gen_ai.input_messages.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f339a32. Configure here.

const spanConfig = {
name:
(typeof model === 'string' && model !== 'unknown') || !(client && hasSpanStreamingEnabled(client))
(typeof model === 'string') || !(client && hasSpanStreamingEnabled(client))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing model interpolates as undefined

Medium Severity

When no model is resolved, the name still interpolates model whenever span streaming is off (and in the Google GenAI integration, even when it is on). Template strings then produce names like chat undefined instead of chat or chat unknown. Empty-string models also become chat with a trailing space.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f339a32. Configure here.

): Record<string, SpanAttributeValue | undefined> {
const system = langSmithMetadata?.ls_provider;
const modelName = invocationParams?.model ?? langSmithMetadata?.ls_model_name ?? 'unknown';
const modelName = invocationParams?.model ?? langSmithMetadata?.ls_model_name;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Chat models still default to unknown

Medium Severity

extractChatModelRequestAttributes still falls back to 'unknown' for the model, so LangChain chat spans keep setting gen_ai.request.model to 'unknown' and naming spans {operation} unknown. The LLM helper was updated; the chat-model path, which is the common one, was not.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f339a32. Configure here.

@Lms24
Lms24 requested a review from andreiborza October 15, 2026 07:48
@andreiborza

Copy link
Copy Markdown
Member

Hi @kashish00208, thanks for the PR. We are still debating whether to do this in v11 or wait until the next major. Will get back to you once we decided.

@JPeer264
JPeer264 removed their request for review October 15, 2026 09:52
@kashish00208

Copy link
Copy Markdown
Author

Hi @kashish00208, thanks for the PR. We are still debating whether to do this in v11 or wait until the next major. Will get back to you once we decided.

Thanks for the update! I appreciate you taking the time to consider this.

@github-actions

Copy link
Copy Markdown
Contributor

👋 @mydea, @andreiborza — Please review this PR when you get a chance!

@andreiborza

Copy link
Copy Markdown
Member

Hi @kashish00208, we decided to keep the current behavior until our next major 12.0.0. I added a milestone to that ticket.

We will close this PR until then, but thank you again for the contribution. Feel free to subscribe to the original issue and reopen your PR then.

@kashish00208
kashish00208 deleted the fix/remove-unknown-model-fallback branch October 21, 2026 16:39
@kashish00208
kashish00208 restored the fix/remove-unknown-model-fallback branch October 21, 2026 16:39
@kashish00208
kashish00208 deleted the fix/remove-unknown-model-fallback branch October 23, 2026 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external PR from an external contributor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Drop 'unknown' model fallbacks across AI integrations

2 participants