Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
📦 fix: Strip Assistant Prefill for Claude 5.x Models (#17209)
Marco Berettacac1a354fd5f
diff --git a/api/package.json b/api/package.jsonindex 979b001a12..1342f2c57f 100644--- a/api/package.json+++ b/api/package.json@@ -40,7 +40,7 @@"@azure/storage-blob": "^12.30.0","@google/genai": "^2.8.0","@keyv/redis": "5.1.6",- "@librechat/agents": "^4.0.5",+ "@librechat/agents": "^4.0.6","@librechat/api": "*","@librechat/data-schemas": "*","@microsoft/microsoft-graph-client": "^3.0.7",diff --git a/package-lock.json b/package-lock.jsonindex 644bc2df4f..c9b50149c7 100644--- a/package-lock.json+++ b/package-lock.json@@ -65,7 +65,7 @@"@azure/storage-blob": "^12.30.0","@google/genai": "^2.8.0","@keyv/redis": "5.1.6",- "@librechat/agents": "^4.0.5",+ "@librechat/agents": "^4.0.6","@librechat/api": "*","@librechat/data-schemas": "*","@microsoft/microsoft-graph-client": "^3.0.7",@@ -9216,9 +9216,9 @@}},"node_modules/@librechat/agents": {- "version": "4.0.5",- "resolved": "https://registry.npmjs.org/@librechat/agents/-/agents-4.0.5.tgz",- "integrity": "sha512-huoNIKPTiYviihqkXJB9/Ht4aG5YkNBSMrkGqOvtuspyZgSlqQNTJIU6qGzOGS6phNohP1dANPkH+qkRpWGPyg==",+ "version": "4.0.6",+ "resolved": "https://registry.npmjs.org/@librechat/agents/-/agents-4.0.6.tgz",+ "integrity": "sha512-VUDKfYF1dTem2DEWbbMR/M2rsNchWmBpcNfvRKnKjD9JPuReBR2Q8xD6x1BUusMDuiDjHqinQ2TcfRLnzWb/Jw==","license": "MIT","dependencies": {"@anthropic-ai/sdk": "^0.115.0",@@ -40787,7 +40787,7 @@"@azure/identity": "^4.13.1","@azure/storage-blob": "^12.30.0","@keyv/redis": "5.1.6",- "@librechat/agents": "^4.0.5",+ "@librechat/agents": "^4.0.6","@librechat/data-schemas": "*","@modelcontextprotocol/sdk": "^1.32.1","@opentelemetry/api": "^1.9.0",diff --git a/packages/api/package.json b/packages/api/package.jsonindex ac01e9d2b0..128f385f8e 100644--- a/packages/api/package.json+++ b/packages/api/package.json@@ -112,7 +112,7 @@"@azure/identity": "^4.13.1","@azure/storage-blob": "^12.30.0","@keyv/redis": "5.1.6",- "@librechat/agents": "^4.0.5",+ "@librechat/agents": "^4.0.6","@librechat/data-schemas": "*","@modelcontextprotocol/sdk": "^1.32.1","@opentelemetry/api": "^1.9.0",diff --git a/packages/api/src/endpoints/anthropic/llm.spec.ts b/packages/api/src/endpoints/anthropic/llm.spec.tsindex fa7b8445e5..e8dac7afb5 100644--- a/packages/api/src/endpoints/anthropic/llm.spec.ts+++ b/packages/api/src/endpoints/anthropic/llm.spec.ts@@ -1,4 +1,5 @@import { Providers, getChatModelClass } from '@librechat/agents';+import { AIMessage, HumanMessage } from '@langchain/core/messages';import {AuthKeys,AnthropicEffort,@@ -2514,3 +2515,46 @@ describe('getLLMConfig', () => {});});});++describe('assistant prefill', () => {+ const sendAndCaptureMessages = async (model: string) => {+ const { llmConfig } = getLLMConfig('test-key', { modelOptions: { model, thinking: false } });+ const bodies: Array<{ messages: Array<{ role: string }> }> = [];+ const fetch = jest.fn(async (_url: string | URL | Request, init?: RequestInit) => {+ bodies.push(JSON.parse(String(init?.body)));+ return new Response(+ JSON.stringify({+ id: 'msg_test',+ type: 'message',+ role: 'assistant',+ model,+ content: [{ type: 'text', text: 'ok' }],+ stop_reason: 'end_turn',+ stop_sequence: null,+ usage: { input_tokens: 1, output_tokens: 1 },+ }),+ { status: 200, headers: { 'content-type': 'application/json' } },+ );+ });+ const Anthropic = getChatModelClass(Providers.ANTHROPIC);+ const llm = new Anthropic({+ ...llmConfig,+ streaming: false,+ maxTokens: 1024,+ clientOptions: { ...llmConfig.clientOptions, fetch },+ });+ await llm.invoke([new HumanMessage('Hello'), new AIMessage('Sure,')]);+ return bodies[0].messages.map((message) => message.role);+ };++ it.each(['claude-haiku-5-5', 'claude-sonnet-5-5', 'claude-opus-5-5', 'claude-fable-5-1'])(+ 'drops the trailing assistant turn for %s',+ async (model) => {+ expect(await sendAndCaptureMessages(model)).toEqual(['user']);+ },+ );++ it('keeps the trailing assistant turn for claude-haiku-4-5', async () => {+ expect(await sendAndCaptureMessages('claude-haiku-4-5')).toEqual(['user', 'assistant']);+ });+});