Repository navigation
fix(ai): classify OpenAI cyber_policy refusals as content policy - #64844
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Looks good. I reproduced it on the base branch: running OpenAI's cyber_policy stream error frame through the Responses providerFailure path gives UnknownProvider, and with this change it gives ContentPolicy. The new test fails on the base branch and passes here. The full provider-error.test.ts suite passes, and tsc --noEmit on packages/ai is clean. The code lookup runs before the quota, auth, rate-limit and server-error checks, so both the HTTP 400 and the mid-stream shapes go through it. The public API is unchanged. No concerns.
This was referenced Nov 19, 2026
Closed
neriousy
enabled auto-merge (squash)
November 19, 2026 16:57
1 task
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.
Issue for this PR
Closes #64843
Type of change
What does this PR do?
OpenAI's cybersecurity safeguard reports its refusals with the code
cyber_policy, both as an HTTP 400 and as anerrorframe mid-stream. That code was not inCONTENT_POLICY_CODESand the wording does not matchCONTENT_POLICY_TEXT, so these refusals fell through toUnknownProvider. Adding the code makesclassifyProviderFailurereturnContentPolicyfor both shapes, sinceproviderCodesalready reads the code from the body or from thecode: messagesummary.How did you verify your code works?
Added a test in
packages/ai/test/provider-error.test.tscovering the 400 body and the stream error frame; it fails without the change and passes with it.bun test test/provider-error.test.tsandbun run typecheckinpackages/aipass.Screenshots / recordings
N/A
Checklist