{"record":{"id":"c7d20f5ef44129ba","repo":"n8n-io/n8n","slug":"the-maximum-number-of-files-that-can-be-attached-t","errorCode":null,"errorMessage":"The maximum number of files that can be attached to the assistant is 20","messagePattern":"The maximum number of files that can be attached to the assistant is 20","errorType":"validation","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/v1/actions/assistant/create.operation.ts","lineNumber":229,"sourceCode":"\n\t\t\tif (has_more) {\n\t\t\t\tafter = response.last_id;\n\t\t\t} else {\n\t\t\t\tbreak;\n\t\t\t}\n\t\t} while (has_more);\n\n\t\tif (assistants.includes(name)) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t`An assistant with the same name '${name}' already exists`,\n\t\t\t\t{ itemIndex: i },\n\t\t\t);\n\t\t}\n\t}\n\n\tif (file_ids.length > 20) {\n\t\tthrow new NodeOperationError(\n\t\t\tthis.getNode(),\n\t\t\t'The maximum number of files that can be attached to the assistant is 20',\n\t\t\t{ itemIndex: i },\n\t\t);\n\t}\n\n\tconst body: IDataObject = {\n\t\tmodel,\n\t\tname,\n\t\tdescription: assistantDescription,\n\t\tinstructions,\n\t};\n\n\tconst tools = [];\n\n\tif (codeInterpreter) {\n\t\ttools.push({\n\t\t\ttype: 'code_interpreter',","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/v1/actions/assistant/create.operation.ts#L211-L247","documentation":"When creating an OpenAI assistant, if more than 20 file IDs are provided for code_interpreter tool resources, the code throws a NodeOperationError before making the API call. This mirrors OpenAI's hard limit of 20 files attached to an assistant's code interpreter. The check is client-side pre-validation.","triggerScenarios":"The file_ids array (or comma-separated string) provided to the Create Assistant operation contains more than 20 file IDs. The count is checked after parsing and before the POST request.","commonSituations":"Attaching a large document set to an assistant; merging multiple file collections into one assistant; not realizing OpenAI caps assistant files at 20.","solutions":["Reduce the file_ids list to 20 or fewer entries","Consolidate documents into fewer files before uploading","Use OpenAI's file_search (vector store) tool instead, which supports more files via vector stores"],"exampleFix":"// before — file_ids: ['file1', 'file2', ..., 'file25']\n// after  — file_ids: ['file1', ..., 'file20'] // trim to <= 20","handlingStrategy":"validation","validationCode":"const MAX_FILES = 20;\nconst fileIds = getFileIds(file_ids);\nif (fileIds.length > MAX_FILES) {\n  throw new UserError(`Cannot attach ${fileIds.length} files. Maximum is ${MAX_FILES}.`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Count file_ids before passing them to the create operation","Use vector stores / file_search for document sets larger than 20 files","Consolidate small documents into fewer files before uploading"],"tags":["openai","assistant","file-limit","pre-validation","v1"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}