danny-avila/LibreChat · error · Error

File search is not enabled for Agents

Error message

File search is not enabled for Agents

What it means

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.

Source

Thrown at api/server/services/Files/process.js:741

    /* Persist under the structured `codeEnvRef` shape — the only key the
     * post-cutover schema (`metadata.codeEnvRef`) and downstream readers
     * (`primeFiles`, `getCodeFilesByIds`, `categorizeFileForToolResources`,
     * controller filtering) accept. Storing under the legacy
     * `fileIdentifier` key would be silently dropped by mongoose strict
     * mode and the file would lose its sandbox reference on subsequent
     * priming turns. */
    fileInfoMetadata = {
      codeEnvRef: {
        kind: codeKind,
        id: codeId,
        storage_session_id: uploaded.storage_session_id,
        file_id: uploaded.file_id,
      },
    };
  } else if (tool_resource === EToolResources.file_search) {
    const isFileSearchEnabled = await checkCapability(req, AgentCapabilities.file_search);
    if (!isFileSearchEnabled) {
      throw new Error('File search is not enabled for Agents');
    }
    // Note: File search processing continues to dual storage logic below
  } else if (tool_resource === EToolResources.context) {
    const { file_id, temp_file_id = null } = metadata;

    /**
     * @param {object} params
     * @param {string} params.text
     * @param {number} params.bytes
     * @param {string} params.filepath
     * @param {string} params.type
     * @return {Promise<void>}
     */
    const createTextFile = async ({ text, bytes, filepath, type = 'text/plain' }) => {
      const textBytes = Buffer.byteLength(text, 'utf8');
      if (textBytes > 15 * megabyte) {
        throw new Error(
          `Extracted text from "${file.originalname}" exceeds the 15MB storage limit (${Math.round(textBytes / megabyte)}MB). Try a shorter document.`,

View on GitHub (pinned to 5ff282f900)

Solutions

  1. Enable the file_search capability for the agent in admin settings.
  2. Remove `file_search` from the agent's tool resources if the feature should stay off.
  3. Frontend: gate the file_search upload affordance on the capability flag.
  4. For multi-tenant: verify the tenant's feature set includes file_search.
Defensive patterns

Strategy: validation

Validate before calling

async function assertFileSearchEnabled(req) {
  const ok = await checkCapability(req, AgentCapabilities.file_search);
  if (!ok) throw new Error('Enable file_search capability for this agent');
}

Try / catch

try { await processAgentFileUpload(params); }
catch (e) {
  if (/File search is not enabled/.test(e.message)) return res.status(403).json({ error: e.message });
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12). Data as JSON: /api/errors/dc81397b51e73043. Report an issue: GitHub.