Add messagesApi.refusal telemetry and remove noisy unknownContentBlock event#311718
Merged
Add messagesApi.refusal telemetry and remove noisy unknownContentBlock event#311718
Conversation
Contributor
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves Anthropic Messages API telemetry by adding a dedicated refusal event (with category) while removing a noisy “unknown content block” event that was triggering on common block types.
Changes:
- Add parsing/storage of
delta.stop_detailsfrom the Messages API stream. - Emit new
messagesApi.refusaltelemetry whenstop_reason === 'refusal', capturing the refusal category. - Remove
messagesApi.unknownContentBlocktelemetry to reduce noise from benigncontent_block_startevents.
Show a summary per file
| File | Description |
|---|---|
| extensions/copilot/src/platform/endpoint/node/messagesApi.ts | Parses stop_details, adds refusal telemetry, and removes noisy unknown content block telemetry/logging. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 1
dmitrivMS
approved these changes
Apr 21, 2026
…k event - Add dedicated messagesApi.refusal telemetry event that fires on Anthropic refusals, capturing the stop_details category (e.g. cyber, content_policy) - Parse stop_details from message_delta stream events - Remove messagesApi.unknownContentBlock telemetry which was firing on every text content_block_start, producing noise instead of actionable signal
fc5b139 to
5191b2d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
messagesApi.refusaltelemetry event that fires when Anthropic returnsstop_reason === 'refusal', capturing thestop_details.category(e.g.cyber,content_policy). This enables tracking cyber refusals and other policy blocks in telemetry.stop_detailsfrommessage_deltastream events and store on the processor.messagesApi.unknownContentBlocktelemetry — this was firing on everytextcontent block start, producing noise instead of actionable signal. Unrecognized content block types are now silently ignored (their content is still handled viacontent_block_delta).Telemetry
New event:
messagesApi.refusalrequestId— for correlationmodel— the model that produced the refusalcategory— the refusal category (e.g.cyber,content_policy)