🐛 fix: Plan extraction with the promoted context resource

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.
This commit is contained in:
Danny Avila 2026-08-31 08:14:06 -04:00
parent c7ca3de668
commit 590698e5ee
2 changed files with 32 additions and 1 deletions

View file

@ -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,

View file

@ -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' });