Skip to content

fix(core): Capture Anthropic stream stop_reason from message_delta#21907

Open
nicohrubec wants to merge 1 commit into
nh/anthropic-stream-real-sdkfrom
nh/anthropic-stream-stop-reason
Open

fix(core): Capture Anthropic stream stop_reason from message_delta#21907
nicohrubec wants to merge 1 commit into
nh/anthropic-stream-real-sdkfrom
nh/anthropic-stream-stop-reason

Conversation

@nicohrubec

@nicohrubec nicohrubec commented Jul 1, 2026

Copy link
Copy Markdown
Member

Stacked on #21906.

Small bug that was uncovered by moving the integration test suite to real clients: The stop reason was not being recorded correctly during streaming because it was read from the wrong event.

The Anthropic streaming instrumentation only read `stop_reason` from
`event.message.stop_reason`, but a real stream never populates that —
`event.message` appears only on `message_start` (where `stop_reason` is `null`),
and the final reason arrives on the `message_delta` event as `delta.stop_reason`.
So `finish_reasons` was silently dropped for real streams.

Reads it from `message_delta.delta` (the dead `message.stop_reason` path is
removed) and re-adds the `finish_reasons` assertions to the streaming tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.59 kB added added
@sentry/browser - with treeshaking flags 26.03 kB added added
@sentry/browser (incl. Tracing) 46.05 kB added added
@sentry/browser (incl. Tracing + Span Streaming) 47.79 kB added added
@sentry/browser (incl. Tracing, Profiling) 50.81 kB added added
@sentry/browser (incl. Tracing, Replay) 85.28 kB added added
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 74.89 kB added added
@sentry/browser (incl. Tracing, Replay with Canvas) 89.97 kB added added
@sentry/browser (incl. Tracing, Replay, Feedback) 102.64 kB added added
@sentry/browser (incl. Feedback) 44.77 kB added added
@sentry/browser (incl. sendFeedback) 32.39 kB added added
@sentry/browser (incl. FeedbackAsync) 37.52 kB added added
@sentry/browser (incl. Metrics) 28.67 kB added added
@sentry/browser (incl. Logs) 28.91 kB added added
@sentry/browser (incl. Metrics & Logs) 29.6 kB added added
@sentry/react 29.38 kB added added
@sentry/react (incl. Tracing) 48.35 kB added added
@sentry/vue 32.82 kB added added
@sentry/vue (incl. Tracing) 47.91 kB added added
@sentry/svelte 27.61 kB added added
CDN Bundle 30 kB added added
CDN Bundle (incl. Tracing) 47.98 kB added added
CDN Bundle (incl. Logs, Metrics) 31.57 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) 49.32 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) 70.77 kB added added
CDN Bundle (incl. Tracing, Replay) 85.48 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.76 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) 91.29 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.53 kB added added
CDN Bundle - uncompressed 89.35 kB added added
CDN Bundle (incl. Tracing) - uncompressed 145.28 kB added added
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.05 kB added added
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 149.25 kB added added
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.59 kB added added
CDN Bundle (incl. Tracing, Replay) - uncompressed 264.29 kB added added
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 268.25 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 277.99 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 281.94 kB added added
@sentry/nextjs (client) 50.73 kB added added
@sentry/sveltekit (client) 46.44 kB added added
@sentry/core/server 77.75 kB added added
@sentry/core/browser 64.05 kB added added
@sentry/node-core 62.37 kB added added
@sentry/node 121.24 kB added added
@sentry/node/import (ESM hook with diagnostics-channel injection) 69.95 kB added added
@sentry/node/light 50.46 kB added added
@sentry/node - without tracing 72.68 kB added added
@sentry/aws-serverless 83.52 kB added added
@sentry/cloudflare (withSentry) - minified 180.62 kB added added
@sentry/cloudflare (withSentry) 446.93 kB added added

@nicohrubec nicohrubec marked this pull request as ready for review July 2, 2026 06:10
@nicohrubec nicohrubec requested a review from a team as a code owner July 2, 2026 06:10
@nicohrubec nicohrubec requested review from JPeer264, andreiborza and mydea and removed request for a team July 2, 2026 06:10
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.

1 participant