Repository navigation
🪨 fix: Strip Assistant Prefill for Claude 4.6+ on Bedrock - #622
Merged
berry-13 merged 2 commits intoOct 17, 2026
Merged
Conversation
berry-13
marked this pull request as ready for review
October 17, 2026 16:33
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 94da8559cb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
3 tasks done
7 of 8 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
Claude 4.6 and every later model reject a trailing assistant message (prefill) with a 400. #621 widened the gate to every 4.6+ and 5.x id, but only
CustomAnthropicapplies it;CustomChatBedrockConversesends the converted messages as they are, so a Bedrock run onanthropic.claude-sonnet-4-6,global.anthropic.claude-haiku-5-5or any other 4.6+ id that ends on an assistant turn still fails.The Bedrock stream and the local non-streaming converter now drop trailing assistant turns for those models after conversion, using the same
modelDisallowsAssistantPrefillgate. A cache point that rode a stripped turn is re-anchored on the new tail when no surviving message carries one, as the Anthropic path does. Non-streaming calls for those models go through the local converter the stream already uses, since the inherited converter cannot strip and system turns are only lifted out during conversion. Claude 3.x through 4.5 and non-Anthropic Bedrock models (Nova, Llama, Mistral) are unchanged. Theindex.tsdiff includes formatting the pre-commit Prettier hook applied to that file.Tracked in berry-13/LibreChat#398.
Change Type
Testing
npx jest src/llm/bedrock/prefill.test.ts: 25 passed, covering Bedrock, inference-profile and ARN ids for 4.6+, 5.x and Fable as stripped, 3.x through 4.5, dated 4.0, Nova, Llama, Mistral and missing ids as unchanged, cache point re-anchoring, and the invoke and stream requests for Haiku 5.5 (stripped) and Haiku 4.5 (kept), and a prefill followed by a system message. Without theindex.tswiring the two Haiku 5.5 request tests fail.npx jest src/llm/bedrock: 15 suites, 224 passed.npx tsc --noEmitand ESLint on the touched files: clean (only pre-existing warnings).Checklist