{"record":{"id":"7dbb6b6441d7c78f","repo":"n8n-io/n8n","slug":"the-current-conversation-and-workflow-state-is-too","errorCode":null,"errorMessage":"The current conversation and workflow state is too large to process. Try to simplify your workflow by breaking it into smaller parts.","messagePattern":"The current conversation and workflow state is too large to process\\. Try to simplify your workflow by breaking it into smaller parts\\.","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"warning","filePath":"packages/@n8n/ai-workflow-builder.ee/src/workflow-builder-agent.ts","lineNumber":590,"sourceCode":"\t\t\t\t\t\tworkflowJSON,\n\t\t\t\t\t\tworkflowOperations: [],\n\t\t\t\t\t\tworkflowContext,\n\t\t\t\t\t\tmode,\n\t\t\t\t\t},\n\t\t\t\t\tstreamConfig,\n\t\t\t\t);\n\t\t// LangGraph's stream has a complex type that doesn't match our StreamEvent definition,\n\t\t// but at runtime it produces the correct shape based on streamMode configuration.\n\t\t// With streamMode: ['updates', 'custom'] and subgraphs enabled, events are:\n\t\t// - Subgraph events: [namespace[], streamMode, data]\n\t\t// - Parent events: [streamMode, data]\n\t\treturn stream as AsyncIterable<StreamEvent>;\n\t}\n\n\tprivate handleStreamError(error: unknown): never {\n\t\tconst invalidRequestErrorMessage = this.getInvalidRequestError(error);\n\t\tif (invalidRequestErrorMessage) {\n\t\t\tthrow new ValidationError(invalidRequestErrorMessage);\n\t\t}\n\n\t\tif (this.isLlmQuotaOrRateLimitError(error)) {\n\t\t\tthrow new OperationalError(sanitizeLlmErrorMessage(error), {\n\t\t\t\tcause: error instanceof Error ? error : undefined,\n\t\t\t});\n\t\t}\n\n\t\tthrow error;\n\t}\n\n\tprivate async *processAgentStream(\n\t\tstream: Awaited<ReturnType<typeof this.createAgentStream>>,\n\t\tagent: ReturnType<typeof this.createWorkflow>,\n\t\tthreadConfig: RunnableConfig,\n\t) {\n\t\ttry {\n\t\t\tconst streamProcessor = createStreamProcessor(stream);","sourceCodeStart":572,"sourceCodeEnd":608,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/ai-workflow-builder.ee/src/workflow-builder-agent.ts#L572-L608","documentation":"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].","triggerScenarios":"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.","commonSituations":"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.","solutions":["Start a new AI assistant thread to drop accumulated history.","Simplify the workflow (remove unused nodes, reduce parameter sizes) before continuing.","Move to a model variant with a larger context window if the deployment allows.","Avoid pasting large external content into the chat mid-session."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"// Estimate token load before sending — rough heuristic\nconst estimatedTokens = JSON.stringify(workflowContext).length / 4;\nif (estimatedTokens > 60000) {\n  // prune history or simplify workflow before continuing\n}","typeGuard":"const isPromptTooLargeError = (e: unknown) =>\n  e instanceof Error && /too large to process/.test(e.message);","tryCatchPattern":"try {\n  yield* builder.chat(payload);\n} catch (e) {\n  if (e instanceof ValidationError && /too large to process/.test(e.message)) {\n    // start a fresh thread or prune workflow state, then retry\n  }\n  throw e;\n}","preventionTips":["Start a new AI assistant thread when the conversation grows long.","Avoid attaching large external payloads mid-session.","Pick a model variant with a context window that fits typical workflow JSON."],"tags":["ai-workflow-builder","llm","context-window","validation"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}