Skip to content

🧯 fix: Strip Assistant Prefill for Claude 5 and Later Models - #621

Merged
berry-13 merged 1 commit into
LibreChat-AI:mainfrom
berry-13:berry-13/fix-claude-5-prefill
Oct 17, 2026
Merged

berry-13 merged 1 commit into
LibreChat-AI:mainfrom
berry-13:berry-13/fix-claude-5-prefill

Conversation

@berry-13

Copy link
Copy Markdown
Collaborator

Summary

Claude 4.6 and every later model reject a trailing assistant message (prefill) with a 400, and stripUnsupportedAssistantPrefill exists to drop it before the request goes out. Its gate, modelDisallowsAssistantPrefill, only matched claude-(opus|sonnet|haiku)-4-N with 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

  • Bug fix (non-breaking change which fixes an issue)

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 for claude-haiku-5-5 and claude-fable-5-1.
  • npx jest src/llm/anthropic/utils/stripPrefillCache.test.ts: 4 passed.
  • npx tsc --noEmit and ESLint on the touched files: clean (only pre-existing warnings).

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective
  • New and existing unit tests pass locally with my changes

@berry-13
berry-13 marked this pull request as ready for review October 17, 2026 12:10
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T12:16:04.957097Z f07805d Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

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.

1 participant