Skip to content

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

Merged
nicohrubec merged 1 commit into
developfrom
nh/anthropic-stream-stop-reason
Jul 2, 2026
Merged

fix(core): Capture Anthropic stream stop_reason from message_delta#21907
nicohrubec merged 1 commit into
developfrom
nh/anthropic-stream-stop-reason

Conversation

@nicohrubec

@nicohrubecnicohrubec commented Jul 1, 2026

Copy link
Copy Markdown
Member

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.

@github-actions

github-actionsBot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser27.59 kB--
@sentry/browser - with treeshaking flags26.03 kB--
@sentry/browser (incl. Tracing)46.04 kB--
@sentry/browser (incl. Tracing + Span Streaming)47.77 kB--
@sentry/browser (incl. Tracing, Profiling)50.81 kB--
@sentry/browser (incl. Tracing, Replay)85.27 kB--
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags74.88 kB--
@sentry/browser (incl. Tracing, Replay with Canvas)89.95 kB--
@sentry/browser (incl. Tracing, Replay, Feedback)102.62 kB--
@sentry/browser (incl. Feedback)44.76 kB--
@sentry/browser (incl. sendFeedback)32.38 kB--
@sentry/browser (incl. FeedbackAsync)37.51 kB--
@sentry/browser (incl. Metrics)28.67 kB--
@sentry/browser (incl. Logs)28.91 kB--
@sentry/browser (incl. Metrics & Logs)29.59 kB--
@sentry/react29.38 kB--
@sentry/react (incl. Tracing)48.34 kB--
@sentry/vue32.82 kB--
@sentry/vue (incl. Tracing)47.9 kB--
@sentry/svelte27.61 kB--
CDN Bundle30 kB--
CDN Bundle (incl. Tracing)48.01 kB--
CDN Bundle (incl. Logs, Metrics)31.57 kB--
CDN Bundle (incl. Tracing, Logs, Metrics)49.33 kB--
CDN Bundle (incl. Replay, Logs, Metrics)70.77 kB--
CDN Bundle (incl. Tracing, Replay)85.48 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)86.76 kB--
CDN Bundle (incl. Tracing, Replay, Feedback)91.3 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)92.54 kB--
CDN Bundle - uncompressed89.35 kB--
CDN Bundle (incl. Tracing) - uncompressed145.27 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed94.05 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed149.24 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed218.59 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed264.28 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed268.24 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed277.98 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed281.93 kB--
@sentry/nextjs (client)50.73 kB--
@sentry/sveltekit (client)46.43 kB--
@sentry/core/server77.73 kB-0.01%-4 B 🔽
@sentry/core/browser64.05 kB-0.01%-5 B 🔽
@sentry/node-core62.38 kB--
@sentry/node121.22 kB-0.01%-5 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection)69.95 kB--
@sentry/node/light50.46 kB+0.01%+1 B 🔺
@sentry/node - without tracing72.69 kB--
@sentry/aws-serverless83.57 kB+0.01%+1 B 🔺
@sentry/cloudflare (withSentry) - minified180.62 kB--
@sentry/cloudflare (withSentry)446.83 kB--

View base workflow run

@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 ownerJuly 2, 2026 06:10
@nicohrubec
nicohrubec requested review from JPeer264, andreiborza and mydea and removed request for a teamJuly 2, 2026 06:10
Base automatically changed from nh/anthropic-stream-real-sdk to developJuly 2, 2026 10:25
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>
@nicohrubec
nicohrubecforce-pushed the nh/anthropic-stream-stop-reason branch from e4dc3e2 to 67c5f63CompareJuly 2, 2026 10:28
@nicohrubec
nicohrubec enabled auto-merge (squash) July 2, 2026 10:30
@nicohrubec
nicohrubec merged commit dffaca7 into developJul 2, 2026
564 of 566 checks passed
@nicohrubec
nicohrubec deleted the nh/anthropic-stream-stop-reason branch July 2, 2026 11:10
Sign up for freeto 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.

2 participants

@nicohrubec@JPeer264