Skip to content

ref(core): Set system message as separate attribute#18978

Merged
RulaKhaled merged 5 commits intodevelopfrom
rolaabuhasna/js-1522-set-system-message-as-separate-attribute
Jan 26, 2026
Merged

ref(core): Set system message as separate attribute#18978
RulaKhaled merged 5 commits intodevelopfrom
rolaabuhasna/js-1522-set-system-message-as-separate-attribute

Conversation

@RulaKhaled
Copy link
Member

So far we put all the messages including the system prompt on gen_ai.request.messages. Instead, the system prompt should be pulled out and set as a separate attribute called gen_ai.system_instructions. For now we will search for the first system message and use that.

Closes #18917

@linear
Copy link

linear bot commented Jan 26, 2026

@github-actions
Copy link
Contributor

github-actions bot commented Jan 26, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.32 kB - -
@sentry/browser - with treeshaking flags 23.83 kB - -
@sentry/browser (incl. Tracing) 42.14 kB - -
@sentry/browser (incl. Tracing, Profiling) 46.78 kB - -
@sentry/browser (incl. Tracing, Replay) 80.75 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.4 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 85.47 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 97.65 kB - -
@sentry/browser (incl. Feedback) 42.04 kB - -
@sentry/browser (incl. sendFeedback) 30.01 kB - -
@sentry/browser (incl. FeedbackAsync) 35.01 kB - -
@sentry/browser (incl. Metrics) 26.43 kB - -
@sentry/browser (incl. Logs) 26.57 kB - -
@sentry/browser (incl. Metrics & Logs) 27.24 kB - -
@sentry/react 27.05 kB - -
@sentry/react (incl. Tracing) 44.37 kB - -
@sentry/vue 29.76 kB - -
@sentry/vue (incl. Tracing) 43.93 kB - -
@sentry/svelte 25.33 kB - -
CDN Bundle 27.89 kB - -
CDN Bundle (incl. Tracing) 42.93 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 43.75 kB - -
CDN Bundle (incl. Tracing, Replay) 79.68 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 85.11 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.03 kB - -
CDN Bundle - uncompressed 81.6 kB - -
CDN Bundle (incl. Tracing) - uncompressed 127.14 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 129.97 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 243.74 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 256.54 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 259.35 kB - -
@sentry/nextjs (client) 46.73 kB - -
@sentry/sveltekit (client) 42.51 kB - -
@sentry/node-core 52.02 kB - -
@sentry/node 166.05 kB +0.19% +311 B 🔺
@sentry/node - without tracing 93.79 kB - -
@sentry/aws-serverless 109.31 kB +0.01% +1 B 🔺

View base workflow run

@github-actions
Copy link
Contributor

github-actions bot commented Jan 26, 2026

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 9,022 - 9,390 -4%
GET With Sentry 1,727 19% 1,749 -1%
GET With Sentry (error only) 6,113 68% 6,320 -3%
POST Baseline 1,205 - 1,225 -2%
POST With Sentry 611 51% 598 +2%
POST With Sentry (error only) 1,063 88% 1,068 -0%
MYSQL Baseline 3,313 - 3,333 -1%
MYSQL With Sentry 476 14% 494 -4%
MYSQL With Sentry (error only) 2,638 80% 2,737 -4%

View base workflow run

@RulaKhaled RulaKhaled requested a review from nicohrubec January 26, 2026 14:44
@RulaKhaled RulaKhaled marked this pull request as ready for review January 26, 2026 14:44
Copy link
Member

@nicohrubec nicohrubec left a comment

Choose a reason for hiding this comment

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

two comments/questions but nothing major so lgtm

[GEN_AI_REQUEST_MODEL_ATTRIBUTE]: 'gpt-3.5-turbo',
[GEN_AI_REQUEST_TEMPERATURE_ATTRIBUTE]: 0.7,
[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]: 2,
[GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE]: 1,
Copy link
Member

Choose a reason for hiding this comment

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

l: are we sure we want to exclude the system message from this count? I would probably expect it to be included given that it is sent by the user in the messages array

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about this too. I chose to exclude it because the messages attribute now reflects messages without the system message. If the original message count is set to 2 but we display the system message in a separate attribute, that feels inconsistent. Also the frontend team won’t be able to tell whether the message was truncated or system attribute was just emitted.

data: expect.objectContaining({
[GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE]: JSON.stringify([
{ type: 'text', content: 'You are a helpful assistant' },
]),
Copy link
Member

Choose a reason for hiding this comment

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

l: I think we should check for these new tests the content of the input messages attribute as well to verify that the system message is no longer there

Copy link

@cursor cursor bot left a comment

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.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

.completed();
});
},
);
Copy link

Choose a reason for hiding this comment

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

Tests don't verify system message removed from input

Low Severity · Bugbot Rules

Flagged per review rules: The new 'extracts system instructions from messages' tests across all integrations (OpenAI, Anthropic, Google GenAI, LangChain, LangGraph, Vercel AI) use expect.objectContaining to verify GEN_AI_SYSTEM_INSTRUCTIONS_ATTRIBUTE is set, but don't verify that the system message is removed from GEN_AI_INPUT_MESSAGES_ATTRIBUTE or that GEN_AI_INPUT_MESSAGES_ORIGINAL_LENGTH_ATTRIBUTE reflects the filtered count. This was explicitly requested by reviewer @nicohrubec in the PR discussion.

Additional Locations (2)

Fix in Cursor Fix in Web

@RulaKhaled RulaKhaled merged commit b0add63 into develop Jan 26, 2026
215 checks passed
@RulaKhaled RulaKhaled deleted the rolaabuhasna/js-1522-set-system-message-as-separate-attribute branch January 26, 2026 17:38
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.

Set system message as separate attribute

2 participants

Comments