n8n-io/n8n · error · Error

Invalid workflow state: workflow or messages missing

Error message

Invalid workflow state: workflow or messages missing

What it means

Post-run invariant error in createWorkflowGenerator. It fires when the agent state fetched after the chat run either has no values or its values fail the isWorkflowStateValues type guard — the run finished but did not yield a recognizable workflow state. Distinguishes an invalid/empty run result from a transport failure.

Solutions

  1. Re-run the evaluation; the agent state read after the run was empty or malformed, often a transient failure.
  2. Check the agent/backend logs for an earlier failure that aborted the run before any workflow was produced.
  3. Verify the prompt produces a workflow at all (not an immediate refusal or error reply).
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/@n8n/ai-workflow-builder.ee/evaluations/cli/index.ts:167 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at packages/@n8n/ai-workflow-builder.ee/evaluations/cli/index.ts:167

				getChatPayload({
					evalType: EVAL_TYPES.LANGSMITH,
					message: prompt,
					workflowId: runId,
					featureFlags,
					workflowContext: datasetInputContext?.workflowContext,
					mode: datasetInputContext?.mode,
				}),
				EVAL_USERS.LANGSMITH,
				undefined, // abortSignal
				tokenTracker ? [tokenTracker] : undefined, // externalCallbacks
				datasetInputContext?.historicalMessages,
			),
		);

		const state = await agent.getState(runId, EVAL_USERS.LANGSMITH);

		if (!state.values || !isWorkflowStateValues(state.values)) {
			throw new Error('Invalid workflow state: workflow or messages missing');
		}

		const workflow = state.values.workflowJSON;

		// Report accumulated token usage from all agents
		if (collectors?.tokenUsage && tokenTracker) {
			const usage = tokenTracker.getUsage();
			if (usage.inputTokens > 0 || usage.outputTokens > 0) {
				collectors.tokenUsage(usage);
			}
		}

		// Extract and report subgraph metrics from coordination log
		if (collectors?.subgraphMetrics) {
			reportSubgraphMetrics(collectors.subgraphMetrics, state.values, workflow);
		}

		// Report introspection events

View on GitHub (pinned to 5ac6606e81)