Repository navigation
🧯 fix: Strip Assistant Prefill for Claude 5 and Later Models - #621
Merged
berry-13 merged 1 commit intoOct 17, 2026
Merged
Conversation
berry-13
marked this pull request as ready for review
October 17, 2026 12:10
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. |
This was referenced Oct 17, 2026
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, and
stripUnsupportedAssistantPrefillexists to drop it before the request goes out. Its gate,modelDisallowsAssistantPrefill, only matchedclaude-(opus|sonnet|haiku)-4-Nwith N >= 6, so every Claude 5.x id passed through unchanged:claude-opus-5,claude-sonnet-5,claude-sonnet-5-5,claude-opus-5-5,claude-haiku-5-5,claude-fable-5-1. Any run that ends on an assistant turn against those models fails.The gate now parses the family version once (opus, sonnet, haiku, fable, mythos) and treats 4.6 and any later major as prefill-disallowing. The minor is limited to one or two digits, so an 8-digit release date (
claude-opus-4-20250514) still reads as 4.0 and keeps its prefill; number-first legacy ids (claude-3-7-sonnet) never match. Bedrock (global.anthropic.claude-opus-5-5-v1:0), Vertex (claude-sonnet-5-5@20260801) and dotted (claude-haiku-5.5) forms are covered.Tracked in berry-13/LibreChat#392.
Change Type
Testing
npx jest src/llm/anthropic/llm.spec.ts -t 'assistant prefill': 40 passed, covering 4.6+, 5.x, Fable/Mythos and provider id forms as disallowing, and 4.0 to 4.5, 3.x, dated 4.0 ids, non-Claude and empty ids as unchanged; the strip test now also runs forclaude-haiku-5-5andclaude-fable-5-1.npx jest src/llm/anthropic/utils/stripPrefillCache.test.ts: 4 passed.npx tsc --noEmitand ESLint on the touched files: clean (only pre-existing warnings).Checklist