{"record":{"id":"d1d66f95b6567904","repo":"n8n-io/n8n","slug":"the-maximum-number-of-files-that-can-be-attached-t-d1d66f","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/update.operation.ts","lineNumber":155,"sourceCode":"\t\tmodelId,\n\t\tname,\n\t\tinstructions,\n\t\tcodeInterpreter,\n\t\tknowledgeRetrieval,\n\t\tfile_ids,\n\t\tremoveCustomTools,\n\t\ttemperature,\n\t\ttopP,\n\t} = options;\n\n\tconst assistantDescription = options.description as string;\n\n\tconst body: IDataObject = {};\n\n\tif (file_ids) {\n\t\tconst files = getFileIds(file_ids);\n\t\tif (files.length > 20) {\n\t\t\tthrow new NodeOperationError(\n\t\t\t\tthis.getNode(),\n\t\t\t\t'The maximum number of files that can be attached to the assistant is 20',\n\t\t\t\t{ itemIndex: i },\n\t\t\t);\n\t\t}\n\n\t\tbody.tool_resources = {\n\t\t\t...((body.tool_resources as object) ?? {}),\n\t\t\tcode_interpreter: {\n\t\t\t\tfile_ids: files,\n\t\t\t},\n\t\t\t// updating file_ids for file_search directly is not supported by OpenAI API\n\t\t\t// only updating vector_store_ids for file_search is supported\n\t\t\t// support for this to be added as part of ADO-2968\n\t\t\t// https://platform.openai.com/docs/api-reference/assistants/modifyAssistant\n\t\t};\n\t}\n","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/v1/actions/assistant/update.operation.ts#L137-L173","documentation":"When updating an OpenAI assistant, if the parsed file_ids list contains more than 20 entries for the code_interpreter tool resource, the code throws a NodeOperationError before the PATCH request. This is the same 20-file limit as create, enforced client-side during update. Note: file_search file_ids cannot be updated directly (per the inline comment about OpenAI API limitations).","triggerScenarios":"The Update Assistant operation is called with file_ids (comma-separated string or array) containing more than 20 entries. The count is checked after getFileIds parsing.","commonSituations":"Adding more files to an existing assistant that already has several; bulk-updating assistants from a list; not realizing the 20-file cap applies to updates too.","solutions":["Trim the file_ids list to 20 or fewer entries","Remove unused files from the assistant before adding new ones","Use vector stores (file_search) for larger document sets which have higher limits"],"exampleFix":"// before — file_ids: 'file1,file2,...,file25'\n// after  — file_ids: 'file1,...,file20'","handlingStrategy":"validation","validationCode":"const MAX_FILES = 20;\nconst files = typeof file_ids === 'string'\n  ? file_ids.split(',').map(s => s.trim())\n  : Array.isArray(file_ids) ? file_ids : [];\nif (files.length > MAX_FILES) {\n  throw new UserError(`Cannot attach ${files.length} files. Maximum is ${MAX_FILES}.`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Count files before passing to the update operation","Remove unused files first if adding new ones would exceed 20","Use vector stores for larger document sets"],"tags":["openai","assistant","file-limit","pre-validation","update","v1"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T09:17:06.757Z"}