Skip to content

fix(sse): map refusal and context-window stop reasons to OpenAI finish reasons - #16453

Merged
diegosouzapw merged 1 commit into
cheaper-inference:release/v3.8.52from
pacocartones:audit/finish-reason-map
Oct 13, 2026
Merged

diegosouzapw merged 1 commit into
cheaper-inference:release/v3.8.52from
pacocartones:audit/finish-reason-map

Conversation

@pacocartones

Copy link
Copy Markdown
Contributor

Summary

  • The Claude to OpenAI stream translator and the Bedrock executor turned every stop reason they did not know into stop. A Claude refusal, a Bedrock content_filtered or guardrail_intervened stop and a model_context_window_exceeded stop all reached OpenAI-format clients as a clean completion.
  • They now map to content_filter and length, the same values utils/finishReason.ts already uses for these reasons.

Related Issues

Target Branch

  • Base is the active release/v3.8.x branch (the highest open release/v*), not main
  • New feature? From 3.8.55 on it is held with the v4-feature label for the v4 channel

Validation

  • Change type: other (translator / executor)
  • Focused tests and category gates from the golden path
  • npm run lint (eslint on the changed files: clean)
  • Reconciled with the current active release base; focused checks rerun afterward
  • Production-code changes include a new or updated automated test in this PR

Tests Added Or Updated

  • tests/unit/finish-reason-refusal-mapping.test.ts (new): 9 tests. 6 fail on the base and all 9 pass with the fix.

Coverage Notes

  • open-sse/translator/response/claude-to-openai.ts and open-sse/executors/bedrock.ts: the new test drives both the streaming and the non-streaming Bedrock paths, and checks that the existing mappings stay as they were.

Reviewer Notes

  • 55 test files that import these modules pass, except one inherited failure that also fails on the base: provider-validation-specialty.test.ts › gemini-web validator.

⚠️ base-red inherited: #15306

…h reasons

The Claude->OpenAI stream translator and the Bedrock executor collapsed every unrecognised stop reason into "stop". A Claude refusal, a Bedrock content_filtered or guardrail_intervened stop and a model_context_window_exceeded stop therefore all looked like a clean completion. They now map to content_filter and length, matching the shared normalizer in utils/finishReason.ts.
@diegosouzapw
diegosouzapw merged commit 3e5e1ea into cheaper-inference:release/v3.8.52 Oct 13, 2026
30 of 51 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants