OpenAI Assistants not doing file retrievals when invoked by N8N Assistants

Describe the problem/error/question

I setup an OpenAI Assistant in OpenAI Playground. Connected a file search tool. The file search tool uses the OpenAI integrated vector store. You just drag and drop content into it. I can chat and query the content successfully via OpenAI playground.

I created a basic flow which exposes creates a webhook for the OpenAI Assistant endpoint. However, whenever I try to ask content specific questions, it never returns the answers from the content, it just makes things up. I’ve tried it with different models. No dice.

What is the error message (if any)?

No error, the assistant is not retrieving content from the file_search tool via API. Only works in Playground

Please share your workflow

"nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "541ad659-5cf6-41f4-b8be-2230421a192d",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ],
      "id": "4f982144-48d8-4870-bde8-5556452b8f33",
      "name": "Webhook",
      "webhookId": "541ad659-5cf6-41f4-b8be-2230421a192d"
    },
    {
      "parameters": {
        "resource": "assistant",
        "assistantId": {
          "__rl": true,
          "value": "asst_R6L4AyFZrOzNWxFGaTg1y6Pj",
          "mode": "list",
          "cachedResultName": "KB and Macros"
        },
        "prompt": "define",
        "text": "=You are an expert AI assistant specializing in crafting and refining knowledge base (KB) articles. Your primary goal is to produce clear, accurate, concise, and professionally-toned KB articles that effectively answer user questions and guide them through resolution steps.\n\nYou will receive the following information as input for each task:\n1.  **`target_question` (String):** The primary user question the KB article aims to address.\n2.  **`current_article_content` (String):** The current version of the KB article content. This is the MOST IMPORTANT textual input as it may contain user-proposed edits, inline directives (e.g., \"[fix this section: make it simpler]\"), or be an entirely new draft by the user.\n3.  **`article_title` (String):** The current title for the KB article.\n4.  **`sample_phrasings` (Array of Strings):** Examples of how real users might ask the `target_question`. Use these for context on user language and intent.\n5.  **`metadata` (Object):** Contains:\n    *   `visibility` (String): e.g., \"Public\", \"Private\".\n    *   `verification_required` (String): e.g., \"True\", \"False\".\n    *   `suggested_keywords` (Array of Strings).\n    *   Consider these metadata fields for context, but do not explicitly write about them in the article unless instructed by an inline directive within `current_article_content`.\n6.  **`Related KB Articles/Snippets` (Tool-Provided, if available via your tools):** Content retrieved from a vector database or other knowledge sources relevant to the `target_question` or `current_article_content`. This is for context and ensuring consistency. *You will only receive this if the system calling you (e.g., n8n) performs a retrieval step.*\n\nCore Instructions:\n\n**1. STRICT ADHERENCE TO `current_article_content` (USER-PROPOSED EDITS):**\n   Your TOP PRIORITY is to work with the `current_article_content`.\n   - If inline directives (e.g., \"[some directive: text to act on]\" or \"[fix this]\") are present within `current_article_content`, meticulously address the directive for the specified or implied text. The directive itself should be removed from the final output.\n   - Treat the entirety of `current_article_content` as the user's latest version, whether it's a minor edit or a complete rewrite.\n   - Focus on improving the grammar, spelling, clarity, and conciseness of the `current_article_content` while maintaining the user's intended meaning and resolution steps.\n\n**2. PROFESSIONAL AND NEUTRAL TONE:**\n   All output must maintain a professional, helpful, and neutral tone. Avoid jargon where possible, or explain it if necessary.\n\n**3. GRAMMAR AND SPELLING:**\n   Ensure impeccable grammar, spelling, and punctuation.\n\n**4. CONSISTENCY WITH EXISTING KNOWLEDGE (TOOL USAGE, IF `Related KB Articles/Snippets` ARE PROVIDED):**\n   If `Related KB Articles/Snippets` are provided by your tools:\n   - After prioritizing user edits in `current_article_content`, review the retrieved knowledge.\n   - If `current_article_content` directly CONTRADICTS factual information or critical resolution steps found in the retrieved trusted knowledge sources, you MUST prioritize the trusted knowledge sources for factual accuracy of steps.\n   - In such a conflict regarding resolution steps: Attempt to rephrase the user's content to align with the trusted source while still capturing the user's intent if possible. If a direct reconciliation is not possible, clearly flag this conflict in your output (e.g., \"POTENTIAL CONFLICT DETECTED: The provided content suggested X, but a trusted knowledge source indicates Y for this step. The output has been aligned with the trusted source.\").\n   - For non-critical information (e.g., tone, minor phrasing preferences from the user in `current_article_content`), prioritize the user's input unless it makes the article factually incorrect.\n   - Do NOT introduce new resolution steps or information solely from the retrieved knowledge unless it's to correct a factual inaccuracy in `current_article_content`.\n\n## TOOL CALLING\nIf you are not sure about file content or codebase structure pertaining to \nthe user's request, use your tools to read files and gather the relevant \ninformation: do NOT guess or make up an answer.\n\nOutput Format:\n- Produce the complete, revised KB article content based on your processing of `current_article_content` and other inputs.\n- If you detected and had to resolve a significant conflict regarding critical steps (based on retrieved knowledge, if provided), you may briefly note the alignment as described above.\n- Format the article for readability, typically using Markdown (headings, lists, bolding) if the input `current_article_content` suggests this format or if it's standard for KB articles.\n\nInputs:\n\ntarget_question: {{ $json.body.target_question }}\n\narticle_title: {{ $json.body.article_title }}\n\ncurrent_article_content: {{ $json.body.current_article_content }}\n\nsample_phrasings: {{ $json.body.sample_phrasings }}\n\nmetadata:\n  visibility:{{ $json.body.metadata.visibility }}\n  verification_required: {{ $json.body.metadata.verification_required }}\n  suggested_keywords: {{ $json.body.metadata.suggested_keywords }}\n\n\n\n\n",
        "options": {
          "preserveOriginalTools": false
        }
      },
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        220,
        0
      ],
      "id": "aca278d6-b83c-4f8a-9a95-9c984d338139",
      "name": "OpenAI",
      "credentials": {
        "openAiApi": {
          "id": "e0MUcGjsvYa3fYkL",
          "name": "OpenAi account"
        }
      },
      "onError": "continueErrorOutput"
    },
    {
      "parameters": {
        "respondWith": "allIncomingItems",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.2,
      "position": [
        580,
        -100
      ],
      "id": "cf31fe16-856e-49be-9109-1447853da3b7",
      "name": "Respond to Webhook"
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "82f7dea690863da5dbf6d29cc87b03fe5e543a9f3f0bdbfb6a4c79ae13ec5167"
  }
}
```{
  

## Share the output returned by the last node
<!-- If you need help with data transformations, please also share your expected output. -->

## Information on your n8n setup
- **n8n version:** SaaS 
-

Hello @clayau! Welcome in the community! :handshake:

Quick check: in the OpenAI node you have

"options": { "preserveOriginalTools": false }

Turning this flag off strips out every tool that was configured on the Assistant, including file_search – so the run can’t reach your vector store and the model just hallucinates.


  1. Edit the OpenAI node > Options > switch Preserve Original Tools back to ON. or simply delete the option , it’s ON by default.

  2. Keep Knowledge Retrieval enabled on the Assistant itself and make sure the files are attached under File Search.

After you re-enable the tools the answers should match the content exactly as they do in Playground.

Retrieval works best on the latest models (gpt-4o or gpt-4o-mini)

Hello,

Yes, I have tried that.

After more testing I am convinced its a bug in N8N’s implementation of OpenAI Message Assistants.

I have replicated the setup in OpenAI Playground, provide the same inputs and prompts and received correct answers that include retrievals. The identical configuration in Message Assistant and inputs fail to retrieve any information.

Also, when I add additional prompt to N8N driven workflow, and tell it to return an Error if information can’t be retrieved from the attached File_search tool, it actually says Retrieval Error.

I believe it’s because you need to force it to use v1 assistants API (according to OpenAI)

HTTP header OpenAI-Beta: assistants=v1

POST/v1/threads/[threadid]/messages

Hi Clayau, I have exactly the same problem, also the model hallucinate every time I try to use a new file attached to the vector store. So, it’s necessary to force the v1?

I ran into the same retrieval issues described in this thread. Following suggestions here and elsewhere, I replaced the native n8n “OpenAI Assistant” node with manual HTTP Request nodes, in order to have full control over the endpoint and headers.

I tried forcing the header OpenAI-Beta: assistants=v1, but the API now requires assistants=v2 (otherwise it throws a deprecation error and blocks the request). All steps run smoothly and I get correct retrieval on simple queries.

However, the Assistant still only answers some questions correctly. For many retrieval questions (e.g. about prices or payment methods that are present in the uploaded files), the Assistant says it has no information or provides incomplete answers, even though the relevant chunks are clearly present in the vector store.

My system instructions are strict (must quote exactly from the retrieved chunk), and chunking has been tuned, but the behavior is inconsistent: sometimes it finds the info, sometimes not—even for identical or rephrased questions.

  • The new assistants=v2 header is mandatory, v1 is deprecated.
  • Switching from the n8n preset to custom HTTP Requests enables the correct retrieval flow.
  • The Assistant is still inconsistent in returning answers from uploaded files, even with correct system instructions and chunking.

Would love to know if anyone has found a way to improve retrieval consistency in this setup!

Hi, Yeah I reverted to using a chain of HTTP Requests and it fixed the problem for me. Create Thread → Create Message → Run Message → (Wait Loop) Poll Run Status. In short, it’s clearly a bug in n8n. Haven’t upgraded to the latest build though.