n8n-io/n8n · error · NodeOperationError
The maximum number of files that can be attached to the assi
Error message
The maximum number of files that can be attached to the assistant is 20
What it means
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.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/v1/actions/assistant/create.operation.ts:229
if (has_more) {
after = response.last_id;
} else {
break;
}
} while (has_more);
if (assistants.includes(name)) {
throw new NodeOperationError(
this.getNode(),
`An assistant with the same name '${name}' already exists`,
{ itemIndex: i },
);
}
}
if (file_ids.length > 20) {
throw new NodeOperationError(
this.getNode(),
'The maximum number of files that can be attached to the assistant is 20',
{ itemIndex: i },
);
}
const body: IDataObject = {
model,
name,
description: assistantDescription,
instructions,
};
const tools = [];
if (codeInterpreter) {
tools.push({
type: 'code_interpreter',View on GitHub (pinned to 5ac6606e81)
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
Example fix
// before — file_ids: ['file1', 'file2', ..., 'file25'] // after — file_ids: ['file1', ..., 'file20'] // trim to <= 20
Defensive patterns
Strategy: validation
Validate before calling
const MAX_FILES = 20;
const fileIds = getFileIds(file_ids);
if (fileIds.length > MAX_FILES) {
throw new UserError(`Cannot attach ${fileIds.length} files. Maximum is ${MAX_FILES}.`);
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Attaching a large document set to an assistant; merging multiple file collections into one assistant; not realizing OpenAI caps assistant files at 20.
Related errors
- The maximum number of files that can be attached to the assi
- An assistant with the same name '${name}' already exists
- ${error.message}
- Invalid file_ids type
- The file content is not in JSONL format
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/c7d20f5ef44129ba.
Report an issue: GitHub.