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 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).

Source

Thrown at packages/@n8n/nodes-langchain/nodes/vendors/OpenAi/v1/actions/assistant/update.operation.ts:155

		modelId,
		name,
		instructions,
		codeInterpreter,
		knowledgeRetrieval,
		file_ids,
		removeCustomTools,
		temperature,
		topP,
	} = options;

	const assistantDescription = options.description as string;

	const body: IDataObject = {};

	if (file_ids) {
		const files = getFileIds(file_ids);
		if (files.length > 20) {
			throw new NodeOperationError(
				this.getNode(),
				'The maximum number of files that can be attached to the assistant is 20',
				{ itemIndex: i },
			);
		}

		body.tool_resources = {
			...((body.tool_resources as object) ?? {}),
			code_interpreter: {
				file_ids: files,
			},
			// updating file_ids for file_search directly is not supported by OpenAI API
			// only updating vector_store_ids for file_search is supported
			// support for this to be added as part of ADO-2968
			// https://platform.openai.com/docs/api-reference/assistants/modifyAssistant
		};
	}

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Trim the file_ids list to 20 or fewer entries
  2. Remove unused files from the assistant before adding new ones
  3. Use vector stores (file_search) for larger document sets which have higher limits

Example fix

// before — file_ids: 'file1,file2,...,file25'
// after  — file_ids: 'file1,...,file20'
Defensive patterns

Strategy: validation

Validate before calling

const MAX_FILES = 20;
const files = typeof file_ids === 'string'
  ? file_ids.split(',').map(s => s.trim())
  : Array.isArray(file_ids) ? file_ids : [];
if (files.length > MAX_FILES) {
  throw new UserError(`Cannot attach ${files.length} files. Maximum is ${MAX_FILES}.`);
}

Prevention

When it happens

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

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

Related errors


AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12). Data as JSON: /api/errors/d1d66f95b6567904. Report an issue: GitHub.