{"record":{"id":"dc81397b51e73043","repo":"danny-avila/LibreChat","slug":"file-search-is-not-enabled-for-agents","errorCode":null,"errorMessage":"File search is not enabled for Agents","messagePattern":"File search is not enabled for Agents","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"api/server/services/Files/process.js","lineNumber":741,"sourceCode":"    /* Persist under the structured `codeEnvRef` shape — the only key the\n     * post-cutover schema (`metadata.codeEnvRef`) and downstream readers\n     * (`primeFiles`, `getCodeFilesByIds`, `categorizeFileForToolResources`,\n     * controller filtering) accept. Storing under the legacy\n     * `fileIdentifier` key would be silently dropped by mongoose strict\n     * mode and the file would lose its sandbox reference on subsequent\n     * priming turns. */\n    fileInfoMetadata = {\n      codeEnvRef: {\n        kind: codeKind,\n        id: codeId,\n        storage_session_id: uploaded.storage_session_id,\n        file_id: uploaded.file_id,\n      },\n    };\n  } else if (tool_resource === EToolResources.file_search) {\n    const isFileSearchEnabled = await checkCapability(req, AgentCapabilities.file_search);\n    if (!isFileSearchEnabled) {\n      throw new Error('File search is not enabled for Agents');\n    }\n    // Note: File search processing continues to dual storage logic below\n  } else if (tool_resource === EToolResources.context) {\n    const { file_id, temp_file_id = null } = metadata;\n\n    /**\n     * @param {object} params\n     * @param {string} params.text\n     * @param {number} params.bytes\n     * @param {string} params.filepath\n     * @param {string} params.type\n     * @return {Promise<void>}\n     */\n    const createTextFile = async ({ text, bytes, filepath, type = 'text/plain' }) => {\n      const textBytes = Buffer.byteLength(text, 'utf8');\n      if (textBytes > 15 * megabyte) {\n        throw new Error(\n          `Extracted text from \"${file.originalname}\" exceeds the 15MB storage limit (${Math.round(textBytes / megabyte)}MB). Try a shorter document.`,","sourceCodeStart":723,"sourceCodeEnd":759,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/api/server/services/Files/process.js#L723-L759","documentation":"Thrown when `tool_resource === EToolResources.file_search` but `checkCapability(req, AgentCapabilities.file_search)` returns false. Same gating pattern as execute_code: file search must be admin-enabled for the agent before its upload path runs. Thrown before any file processing or storage call.","triggerScenarios":"Upload to an agent with `tool_resource: file_search` when the agent or tenant lacks the file_search capability. Common after admins disable the feature or on fresh installs where it defaults off.","commonSituations":"Stale agent configs referencing file_search after the admin turned the feature off; cross-environment config sync where the target env has file_search disabled; user attempting to enable a tool resource their plan/tenant does not include.","solutions":["Enable the file_search capability for the agent in admin settings.","Remove `file_search` from the agent's tool resources if the feature should stay off.","Frontend: gate the file_search upload affordance on the capability flag.","For multi-tenant: verify the tenant's feature set includes file_search."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"async function assertFileSearchEnabled(req) {\n  const ok = await checkCapability(req, AgentCapabilities.file_search);\n  if (!ok) throw new Error('Enable file_search capability for this agent');\n}","typeGuard":null,"tryCatchPattern":"try { await processAgentFileUpload(params); }\ncatch (e) {\n  if (/File search is not enabled/.test(e.message)) return res.status(403).json({ error: e.message });\n  throw e;\n}","preventionTips":["Gate the file_search upload UI on the capability flag.","Verify the tenant/role capability matrix includes file_search in multi-tenant setups.","Remove file_search from agent tool_resources when the feature is globally off."],"tags":["agent","capability","file-search","authorization"],"backgroundTag":null,"analyzedSha":"5ff282f9006c436e561de1afd39a481bea1ef0d8","analyzedAt":"2026-08-12T21:38:08.145Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}