Uh oh!
There was an error while loading. Please reload this page.
fix(core): surface refusal category and explanation on content filter - #37392
Closed
cyllas wants to merge 1 commit into
Closed
fix(core): surface refusal category and explanation on content filter#37392cyllas wants to merge 1 commit into
cyllas wants to merge 1 commit into
Conversation
6 tasks
Contributor
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
This was referenced Aug 16, 2026
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 freeto 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.
Issue for this PR
Closes#35736
Type of change
What does this PR do?
When Anthropic returns
stop_reason: "refusal", opencode maps it to acontent-filterfinish and shows one hardcoded message — "The response wasblocked by the provider's content filter" — dropping the
stop_detailstheprovider sends. As #35736 notes, that makes every refusal look identical even
though the categories call for different responses.
Anthropic's
stop_details.categorycan becyber,bio,frontier_llm, orreasoning_extraction(see Anthropic's "Refusals and fallback" docs).@ai-sdk/anthropicalready surfaces these on the finish event'sproviderMetadata.anthropic.stopDetails, but they were never read.This PR:
ContentFilterErrorwith optionalcategoryandexplanationResponse refused by provider (reasoning_extraction): ...) when present, falling back to the currentmessage when they are not
No behavior change when
stop_detailsis absent — every non-refusal stop, or arefusal with no named category.
How did you verify your code works?
reasoning_extractionrefusal fromclaude-fable-5end toend. The surfaced error changed from the generic message to
Response refused by provider (reasoning_extraction): <explanation>. ConfirmedproviderMetadata.anthropic.stopDetailsarrives on the step-finish event withcategory/explanationand is read correctly.test/session/content-filter.test.tscovering the metadata parsing(category + explanation, partial, and the empty/absent cases);
bun testpasses.bun typecheckpasses inpackages/coreandpackages/opencode.Screenshots / recordings
N/A (error text change).
Checklist