Skip to content

fix(ai): classify OpenAI cyber_policy refusals as content policy - #64892

Closed
2118505078xyh1 wants to merge 1 commit into
anomalyco:devfrom
2118505078xyh1:fix-cyber-policy
Closed

2118505078xyh1 wants to merge 1 commit into
anomalyco:devfrom
2118505078xyh1:fix-cyber-policy

Conversation

@2118505078xyh1

Copy link
Copy Markdown

Problem

OpenAI's cyber_policy refusal (an HTTP 400 error body or a mid-stream Responses error frame) is not a known content-policy code, so classifyProviderFailure returns UnknownProvider. Clients that react to content-policy failures cannot distinguish the refusal from a transient error, and retry policy treats it as retry-eligible.

Changes

Added cyber_policy to CONTENT_POLICY_CODES in packages/ai/src/provider-error.ts, so both the HTTP 400 and mid-stream wire shapes classify as ContentPolicy. Added a regression test covering both shapes.

Fixes #64843

Testing

  • bun test test/provider-error.test.ts in packages/ai: 47 passed, 0 failed.
  • bun typecheck in packages/ai: no type errors.
  • oxlint + prettier clean on changed files.

@github-actions github-actions Bot added the needs:compliance This means the issue will auto-close after 2 hours. label Nov 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 72 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@opencodejr opencodejr Bot closed this Nov 19, 2026
@opencodejr

opencodejr Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

Thanks for picking this up and for adding a test covering both wire shapes!

I think this duplicates #64844, which is already open. It adds cyber_policy to CONTENT_POLICY_CODES in packages/ai/src/provider-error.ts with a regression test for the HTTP 400 body and the mid-stream error frame, and it also fixes #64843.

If you think something is missing there, such as test coverage for the response.failed frame shape your test uses, please review, test or comment on #64844.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs:compliance This means the issue will auto-close after 2 hours.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenAI cyber_policy refusals are classified as UnknownProvider instead of ContentPolicy

1 participant