Skip to content

fix(ai-anthropic): accept unknown refusal categories in RefusalCategory schemas - #11397

Open
standard-librarian wants to merge 1 commit into
Effect-TS:mainfrom
standard-librarian:fix/ai-anthropic-open-refusal-category
Open

standard-librarian wants to merge 1 commit into
Effect-TS:mainfrom
standard-librarian:fix/ai-anthropic-open-refusal-category

Conversation

@standard-librarian

Copy link
Copy Markdown

Summary

  • Patch RefusalCategory and BetaRefusalCategory in packages/ai/anthropic/codegen.yml to append {"type": "string"} to their anyOf unions, matching how Model stays open to newly added values.
  • Apply the corresponding Schema.String union branch (and | string type) to RefusalCategory and BetaRefusalCategory in packages/ai/anthropic/src/Generated.ts.
  • Add regression tests in AnthropicClient.test.ts and AnthropicLanguageModel.test.ts verifying unknown refusal categories decode cleanly in RefusalStopDetails, BetaRefusalStopDetails, BetaFallbackRefusalTrigger, and streaming message_delta events (finishing with reason: "content-filter").
  • Add a patch changeset for @effect/ai-anthropic.

Note: Checked BetaFallbackCreditNotApplied.reason as mentioned in the issue — left it closed because Anthropic's OpenAPI spec explicitly documents it as "A closed enum; additions to the redemption-check vocabulary arrive as deliberate schema updates."

Fixes #11391

Verification

  • Confirmed both new tests fail before the fix (Expected RefusalCategory / Expected BetaRefusalCategory).
  • ./node_modules/.bin/vitest run packages/ai/anthropic/test/ — 3/3 test files, 100/100 tests passed.
  • pnpm --filter @effect/ai-anthropic check (tsc -b tsconfig.json) — 0 errors.
  • ./node_modules/.bin/oxlint on changed TS files — 0 warnings, 0 errors.
  • ./node_modules/.bin/dprint check on changed TS files — passed.

@changeset-bot

changeset-bot Bot commented Dec 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 762b4f5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 43 packages
Name Type
@effect/ai-anthropic Patch
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-amazon-bedrock Patch
@effect/ai-cloudflare Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/ai-typesafe Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/chat-discord Patch
@effect/chat-slack Patch
@effect/chat-teams Patch
@effect/chat-telegram Patch
@effect/chat-whatsapp Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-cloudflare Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/graphql-generator Patch
@effect/openapi-generator Patch
@effect/ui-devtools Patch
@effect/ui-native Patch
@effect/ui-opentui Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@effect-janitor effect-janitor Bot added the 4.0 label Dec 3, 2026
@kachkaev

kachkaev commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

I believe that this PR has been superseded by #11400

This branch is waiting to be deployed

1 waiting deployment
fork — 762b4f53 Waiting Dec 3, 2026 by standard-librarian via approval-gate #29220
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ai-anthropic: a refusal category the generated schema doesn't list fails the turn

2 participants