n8n-io/n8n · warning · ValidationError
Message exceeds maximum length of ${MAX_AI_BUILDER_PROMPT_LE
Error message
Message exceeds maximum length of ${MAX_AI_BUILDER_PROMPT_LENGTH} characters What it means
ValidationError thrown by validateMessageLength when the user's chat message exceeds MAX_AI_BUILDER_PROMPT_LENGTH (5000 characters, defined in constants.ts). It is a deliberate pre-flight check before the message is sent to the LLM, so the user gets a clear, synchronous error instead of a provider-side rejection.
Source
Thrown at packages/@n8n/ai-workflow-builder.ee/src/workflow-builder-agent.ts:470
externalCallbacks,
);
try {
const stream = await this.createAgentStream(payload, streamConfig, agent, historicalMessages);
yield* this.processAgentStream(stream, agent, threadConfig);
} catch (error: unknown) {
this.handleStreamError(error);
}
}
private validateMessageLength(message: string): void {
if (message.length > MAX_AI_BUILDER_PROMPT_LENGTH) {
this.logger?.warn('Message exceeds maximum length', {
messageLength: message.length,
maxLength: MAX_AI_BUILDER_PROMPT_LENGTH,
});
throw new ValidationError(
`Message exceeds maximum length of ${MAX_AI_BUILDER_PROMPT_LENGTH} characters`,
);
}
}
private setupAgentAndConfigs(
payload: ChatPayload,
userId?: string,
abortSignal?: AbortSignal,
externalCallbacks?: Callbacks,
) {
// Store feature flags from the first call; reuse for all subsequent calls
// to prevent mid-session flag changes from causing inconsistency
if (!this.sessionFeatureFlags && payload.featureFlags) {
this.sessionFeatureFlags = payload.featureFlags;
}
const agent = this.createWorkflow(this.sessionFeatureFlags ?? payload.featureFlags);
const workflowId = payload.workflowContext?.currentWorkflow?.id;View on GitHub (pinned to 5ac6606e81)
Solutions
- Shorten the message to under 5000 characters.
- Split the request into multiple smaller turns, letting the assistant build incrementally.
- Remove pasted binary/base64/large JSON and describe it instead.
- If a higher cap is genuinely needed, change MAX_AI_BUILDER_PROMPT_LENGTH in constants.ts and rerun tests.
Example fix
// before sendMessage(hugeSpec); // 12000 chars -> ValidationError // after const chunk = hugeSpec.slice(0, 4800); await sendMessage(chunk);
Defensive patterns
Strategy: validation
Validate before calling
const MAX = 5000;
function fitMessage(message: string): string {
return message.length > MAX ? message.slice(0, MAX - 1) : message;
} Type guard
const withinPromptLimit = (message: string) => message.length <= 5000;
Try / catch
try {
await builder.chat({ message });
} catch (e) {
if (e instanceof ValidationError && /maximum length/.test(e.message)) {
// truncate or ask user to shorten, then retry
}
throw e;
} Prevention
- Truncate user input client-side before sending to the AI assistant.
- Strip base64 / large JSON blobs from prompts.
- Surface a live character counter in the chat UI tied to the 5000 limit.
When it happens
Trigger: Any call to the AI workflow builder whose payload.message string is longer than 5000 chars. The check runs in validateMessageLength before setupAgentAndConfigs, so very large pasted prompts, base64 blobs, or concatenated instruction text trip it.
Common situations: User pastes a huge spec, log dump, or JSON workflow into the AI assistant chat; an integration builds the prompt programmatically and forgets to truncate; a user attaches a long error trace expecting the AI to fix it.
Related errors
- The current conversation and workflow state is too large to
- Tool "${this.name}" requires a description
- VectorStore "${this.name}" requires a description — set it v
- Rate limit exceeded. Please wait a moment and try again.
- Invalid output format
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/0413e28425ce577f.
Report an issue: GitHub.