From 590698e5eefc3131c2136e1732f908c467830c99 Mon Sep 17 00:00:00 2001 From: Danny Avila Date: Mon, 31 Aug 2026 08:14:06 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix:=20Plan=20extraction=20with?= =?UTF-8?q?=20the=20promoted=20context=20resource?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An auto-routed text upload promotes its effective resource to context, but the extraction planner still received the original undefined tool_resource and returned no document-parser plan. On deployments without RAG a text-routed DOCX/ODT/XLSX then reached parseText with native fallback and was decoded as UTF-8 instead of parsed. --- api/server/services/Files/process.js | 2 +- api/server/services/Files/process.spec.js | 31 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/api/server/services/Files/process.js b/api/server/services/Files/process.js index 17488bf269..641575e7c6 100644 --- a/api/server/services/Files/process.js +++ b/api/server/services/Files/process.js @@ -926,7 +926,7 @@ const processAgentFileUpload = async ({ req, res, metadata, sseStream }) => { const fileConfig = mergeFileConfig(appConfig.fileConfig); const extractedTextPlan = getUploadExtractedTextPlan({ endpoint: metadata.endpoint, - toolResource: tool_resource, + toolResource: effectiveToolResource, mimeType: file.mimetype, fileConfig, ocrConfigured: appConfig?.ocr != null, diff --git a/api/server/services/Files/process.spec.js b/api/server/services/Files/process.spec.js index 024608e0ee..0a0afcf5f9 100644 --- a/api/server/services/Files/process.spec.js +++ b/api/server/services/Files/process.spec.js @@ -1530,6 +1530,37 @@ describe('processAgentFileUpload', () => { ); }); + test('plans extraction with the promoted context resource for auto-routed text uploads', async () => { + const { getUploadExtractedTextPlan } = require('@librechat/api'); + mergeFileConfig.mockReturnValue(makeFileConfig()); + const storageUpload = jest.fn().mockResolvedValue({ + filepath: '/uploads/user-123/file-uuid-123__upload.bin', + bytes: 128, + filename: 'upload.bin', + embedded: false, + }); + getStrategyFunctions.mockReturnValue({ handleFileUpload: storageUpload }); + const req = makeReq({ + mimetype: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + ocrConfig: null, + }); + req.body.endpoint = EModelEndpoint.agents; + + await processAgentFileUpload({ + req, + res: mockRes, + metadata: { + agent_id: 'agent-abc', + message_file: 'true', + file_id: 'file-uuid-123', + }, + }); + + expect(getUploadExtractedTextPlan).toHaveBeenCalledWith( + expect.objectContaining({ toolResource: EToolResources.context }), + ); + }); + test('resolves llmDeliveryPath from the agent provider config for agent uploads', async () => { const { createFile, getAgent } = require('~/models'); getAgent.mockResolvedValueOnce({ provider: 'Custom Provider' });