Repository navigation
fix(sse): map refusal and context-window stop reasons to OpenAI finish reasons - #16453
Merged
diegosouzapw merged 1 commit intoOct 13, 2026
Conversation
…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
merged commit Oct 13, 2026
3e5e1ea
into
cheaper-inference:release/v3.8.52
30 of 51 checks passed
Merged
6 of 7 tasks
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.
Summary
stop. A Clauderefusal, a Bedrockcontent_filteredorguardrail_intervenedstop and amodel_context_window_exceededstop all reached OpenAI-format clients as a clean completion.content_filterandlength, the same valuesutils/finishReason.tsalready uses for these reasons.Related Issues
incomplete)Target Branch
release/v3.8.xbranch (the highest openrelease/v*), notmainv4-featurelabel for the v4 channelValidation
npm run lint(eslint on the changed files: clean)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.tsandopen-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
provider-validation-specialty.test.ts› gemini-web validator.