n8n-io/n8n · error · NodeOperationError
${error.message}
Error message
${error.message} What it means
Rejection branch in invokeAgent after executor.invoke returns. If the LangChain agent executor result has status 'rejected', the node casts result.reason to Error and rethrows it as a NodeOperationError. The message is the rejection reason's message — typically a model invocation failure, a tool exception, max-iterations abort, or output-parser failure.
Source
Thrown at packages/@n8n/nodes-langchain/nodes/vendors/Microsoft/langchain-utils.ts:104
memory,
fallbackModel,
);
const system_message = options.systemMessage ?? SYSTEM_MESSAGE;
const invokeParams = {
input,
system_message,
formatting_instructions:
'IMPORTANT: For your response to user, you MUST use the `format_final_json_response` tool with your complete answer formatted according to the required schema. Do not attempt to format the JSON manually - always use this tool. Your response will be rejected if it is not properly formatted through this tool. Only use this tool once you are ready to provide your final answer.',
};
const result = await executor.invoke(invokeParams, invokeOptions);
if (result.status === 'rejected') {
const error = result.reason as Error;
throw new NodeOperationError(nodeContext.getNode(), error);
}
const response = result;
if (memory && outputParser) {
const parsedOutput = jsonParse<{ output: Record<string, unknown> }>(response.output as string);
response.output = parsedOutput?.output ?? parsedOutput;
}
return response.output;
}
async function prepareMessages(options: {
systemMessage?: string;
outputParser?: N8nOutputParser;
}): Promise<BaseMessagePromptTemplateLike[]> {
const messages: BaseMessagePromptTemplateLike[] = [];
if (options.systemMessage) {View on GitHub (pinned to 5ac6606e81)
Solutions
- Read result.reason.message — it identifies whether the failure was the model, a tool, or the parser.
- For model rate limits, enable the Fallback Model (needsFallback) so a secondary model is attempted.
- Raise options.maxIterations (default 10) if the agent runs out of steps before calling format_final_json_response.
- Inspect connected tools/MCP servers for runtime errors; fix the tool's own failure.
- If the parser failed, relax/fix the output schema or add a repair step.
Defensive patterns
Strategy: try-catch
Type guard
interface ExecutorResult { status?: string; reason?: unknown; output?: unknown }
function isRejectedResult(r: ExecutorResult): r is { status: 'rejected'; reason: Error } {
return r?.status === 'rejected';
} Try / catch
try {
const out = await invokeAgent(ctx, input, sys, opts, mcpTools);
} catch (e) {
if (e instanceof NodeOperationError && /rate limit|429|context length|timeout/i.test(e.message)) {
// optionally: enable needsFallback, raise maxIterations, or retry
}
throw e;
} Prevention
- Enable needsFallback and wire a secondary model so model-side failures are absorbed.
- Raise options.maxIterations above the default 10 if the agent often runs out of steps.
- Validate connected tools / MCP servers in isolation so their failures don't surface as agent rejections.
When it happens
Trigger: The underlying chat model throws (rate limit, auth, context-length exceeded), a connected tool throws an unhandled exception, the agent hits maxIterations without resolving, or the structured output parser fails to parse the model's response.
Common situations: Model rate limit / 429 during a long agent run; tool node returns an error that bubbles as rejection; the format_final_json_response tool was never called within max iterations; output parser got malformed JSON.
Related errors
- Please connect a model to the Fallback Model input or disabl
- The selected tools are not supported by "${currentAgentType}
- Static tool name collision — the following tool names resolv
- Deferred tool name collision — the following tool names reso
- MCP tool name collision — the following tool names resolve t
AI-assisted analysis of n8n-io/n8n@5ac6606e81 (2026-08-12).
Data as JSON: /api/errors/9137f9d730981802.
Report an issue: GitHub.