Skip to content

Conversation

@ArthurKnaus
Copy link
Member

@ArthurKnaus ArthurKnaus commented Nov 7, 2025

Screenshot 2025-11-07 at 09 16 43

@ArthurKnaus ArthurKnaus requested a review from a team November 7, 2025 08:02
@linear
Copy link

linear bot commented Nov 7, 2025

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Nov 7, 2025
{isTruncated ? (
<Container paddingBottom="lg">
<Alert type="muted">
{t('Due to size limitations, the message history on this span is truncated.')}
Copy link
Member

Choose a reason for hiding this comment

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

Does it make sense for us to show how many messages were truncated? The meta contains the total original length, so we should be able to calculate - or is this one of these where we don't have the information available for some reason?

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah cool if it does, for me the numbers where not adding up as the numbering on the test. messages went up to 24 + an additional user message, whereas the meta had len: 26.
Guess the messages in the test data use a 0 index.
What is the value if just a single message content got truncated?

Copy link
Member

Choose a reason for hiding this comment

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

Yeah the original size is 25 messages + the user request.
If a single message is above the limit, this currently results in that message being discarded & annotated. We re-build the message array "backwards", and check at which point we exceed the limit. Even if we were to put that message into the array with truncation, it would exceed the limit. The case where the last message is the largest one, I think we haven't dealt with well so far - in this case we truncate everything and don't send any messages. I think we have to improve on this, probably by having single-message limit in addition to the limit for the 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.

ah k, that is something we need to improve then. but not blocking this. thx!

Copy link
Member

Choose a reason for hiding this comment

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

I'll add that to the Python SDK - the content truncation will be shown in-line, as we usually do, with an ellipsis (...)

{isTruncated ? (
<Container paddingBottom="lg">
<Alert type="muted">
{t('Due to size limitations, the message history on this span is truncated.')}
Copy link
Member

Choose a reason for hiding this comment

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

Shall we add a link to the docs that specify what the limits are? E.g. a link to here https://develop.sentry.dev/sdk/expected-features/data-handling/#variable-size

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice! Did not think we have docs for that as it is still in motion. Will add 🙂

@ArthurKnaus ArthurKnaus merged commit 091f5eb into master Nov 7, 2025
47 checks passed
@ArthurKnaus ArthurKnaus deleted the arthurknaus/tet-1296-show-that-we-truncated-gen_ai-request-messages-in-ai-trace branch November 7, 2025 09:35
Comment on lines +189 to +190
const messagesMeta = attributesMeta?.['gen_ai.request.messages']?.meta as any;
const originalMessagesLength: number | undefined = messagesMeta?.['']?.len;
Copy link
Collaborator

Choose a reason for hiding this comment

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

just wondering why as any is necessary? Can’t we make the types conform to what we’re trying to do at runtime?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, I am still investigate the current usage to see how to fix the types here. In e.g. logs the value key is used. This could be an SDK / BE or FE bug.

Ahmed-Labs pushed a commit that referenced this pull request Nov 10, 2025
Ahmed-Labs pushed a commit that referenced this pull request Nov 10, 2025
Jesse-Box pushed a commit that referenced this pull request Nov 12, 2025
andrewshie-sentry pushed a commit that referenced this pull request Nov 13, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Nov 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants