n8n-io/n8n · warning · ValidationError

The current conversation and workflow state is too large to

Error message

The current conversation and workflow state is too large to process. Try to simplify your workflow by breaking it into smaller parts.

What it means

ValidationError mapped from a provider invalid_request_error whose message contains 'prompt is too long'. getInvalidRequestError unwraps error.error.error and, on detecting the too-long hint, substitutes PROMPT_IS_TOO_LARGE_ERROR. It means the combined conversation + workflow state exceeded the LLM's context window, not the 5000-char input cap from [243].

Source

Thrown at packages/@n8n/ai-workflow-builder.ee/src/workflow-builder-agent.ts:590

						workflowJSON,
						workflowOperations: [],
						workflowContext,
						mode,
					},
					streamConfig,
				);
		// LangGraph's stream has a complex type that doesn't match our StreamEvent definition,
		// but at runtime it produces the correct shape based on streamMode configuration.
		// With streamMode: ['updates', 'custom'] and subgraphs enabled, events are:
		// - Subgraph events: [namespace[], streamMode, data]
		// - Parent events: [streamMode, data]
		return stream as AsyncIterable<StreamEvent>;
	}

	private handleStreamError(error: unknown): never {
		const invalidRequestErrorMessage = this.getInvalidRequestError(error);
		if (invalidRequestErrorMessage) {
			throw new ValidationError(invalidRequestErrorMessage);
		}

		if (this.isLlmQuotaOrRateLimitError(error)) {
			throw new OperationalError(sanitizeLlmErrorMessage(error), {
				cause: error instanceof Error ? error : undefined,
			});
		}

		throw error;
	}

	private async *processAgentStream(
		stream: Awaited<ReturnType<typeof this.createAgentStream>>,
		agent: ReturnType<typeof this.createWorkflow>,
		threadConfig: RunnableConfig,
	) {
		try {
			const streamProcessor = createStreamProcessor(stream);

View on GitHub (pinned to 5ac6606e81)

Solutions

  1. Start a new AI assistant thread to drop accumulated history.
  2. Simplify the workflow (remove unused nodes, reduce parameter sizes) before continuing.
  3. Move to a model variant with a larger context window if the deployment allows.
  4. Avoid pasting large external content into the chat mid-session.
Defensive patterns

Strategy: fallback

Validate before calling

// Estimate token load before sending — rough heuristic
const estimatedTokens = JSON.stringify(workflowContext).length / 4;
if (estimatedTokens > 60000) {
  // prune history or simplify workflow before continuing
}

Type guard

const isPromptTooLargeError = (e: unknown) =>
  e instanceof Error && /too large to process/.test(e.message);

Try / catch

try {
  yield* builder.chat(payload);
} catch (e) {
  if (e instanceof ValidationError && /too large to process/.test(e.message)) {
    // start a fresh thread or prune workflow state, then retry
  }
  throw e;
}

Prevention

When it happens

Trigger: The agent stream raises an OpenAI-style invalid_request_error with type 'invalid_request_error' and a message containing 'prompt is too long'. handleStreamError routes it through getInvalidRequestError and rethrows as ValidationError. Typically hit on long multi-turn sessions with large accumulated workflow JSON.

Common situations: A long AI-assistant session whose message history plus the current workflow JSON grows past the model's context window; a workflow with hundreds of nodes whose serialized state dominates the prompt; switching to a model with a smaller context window.

Related errors


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