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

@nicohrubec nicohrubec 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-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.59 kB - -
@sentry/browser - with treeshaking flags 26.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 flags 74.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/react 29.38 kB - -
@sentry/react (incl. Tracing) 48.34 kB - -
@sentry/vue 32.82 kB - -
@sentry/vue (incl. Tracing) 47.9 kB - -
@sentry/svelte 27.61 kB - -
CDN Bundle 30 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 - uncompressed 89.35 kB - -
CDN Bundle (incl. Tracing) - uncompressed 145.27 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.05 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 149.24 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.59 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 264.28 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 268.24 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 277.98 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 281.93 kB - -
@sentry/nextjs (client) 50.73 kB - -
@sentry/sveltekit (client) 46.43 kB - -
@sentry/core/server 77.73 kB -0.01% -4 B 🔽
@sentry/core/browser 64.05 kB -0.01% -5 B 🔽
@sentry/node-core 62.38 kB - -
@sentry/node 121.22 kB -0.01% -5 B 🔽
@sentry/node/import (ESM hook with diagnostics-channel injection) 69.95 kB - -
@sentry/node/light 50.46 kB +0.01% +1 B 🔺
@sentry/node - without tracing 72.69 kB - -
@sentry/aws-serverless 83.57 kB +0.01% +1 B 🔺
@sentry/cloudflare (withSentry) - minified 180.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 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
Base automatically changed from nh/anthropic-stream-real-sdk to develop July 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 nicohrubec force-pushed the nh/anthropic-stream-stop-reason branch from e4dc3e2 to 67c5f63 Compare July 2, 2026 10:28
@nicohrubec nicohrubec enabled auto-merge (squash) July 2, 2026 10:30
@nicohrubec nicohrubec merged commit dffaca7 into develop Jul 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 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.

2 participants