{"record":{"id":"9137f9d730981802","repo":"n8n-io/n8n","slug":"error-message-9137f9","errorCode":null,"errorMessage":"${error.message}","messagePattern":"\\$\\{error\\.message\\}","errorType":"exception","errorClass":"NodeOperationError","httpStatus":null,"severity":"error","filePath":"packages/@n8n/nodes-langchain/nodes/vendors/Microsoft/langchain-utils.ts","lineNumber":104,"sourceCode":"\t\tmemory,\n\t\tfallbackModel,\n\t);\n\n\tconst system_message = options.systemMessage ?? SYSTEM_MESSAGE;\n\n\tconst invokeParams = {\n\t\tinput,\n\t\tsystem_message,\n\t\tformatting_instructions:\n\t\t\t'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.',\n\t};\n\n\tconst result = await executor.invoke(invokeParams, invokeOptions);\n\n\tif (result.status === 'rejected') {\n\t\tconst error = result.reason as Error;\n\n\t\tthrow new NodeOperationError(nodeContext.getNode(), error);\n\t}\n\tconst response = result;\n\n\tif (memory && outputParser) {\n\t\tconst parsedOutput = jsonParse<{ output: Record<string, unknown> }>(response.output as string);\n\t\tresponse.output = parsedOutput?.output ?? parsedOutput;\n\t}\n\n\treturn response.output;\n}\n\nasync function prepareMessages(options: {\n\tsystemMessage?: string;\n\toutputParser?: N8nOutputParser;\n}): Promise<BaseMessagePromptTemplateLike[]> {\n\tconst messages: BaseMessagePromptTemplateLike[] = [];\n\n\tif (options.systemMessage) {","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/nodes-langchain/nodes/vendors/Microsoft/langchain-utils.ts#L86-L122","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"interface ExecutorResult { status?: string; reason?: unknown; output?: unknown }\nfunction isRejectedResult(r: ExecutorResult): r is { status: 'rejected'; reason: Error } {\n  return r?.status === 'rejected';\n}","tryCatchPattern":"try {\n  const out = await invokeAgent(ctx, input, sys, opts, mcpTools);\n} catch (e) {\n  if (e instanceof NodeOperationError && /rate limit|429|context length|timeout/i.test(e.message)) {\n    // optionally: enable needsFallback, raise maxIterations, or retry\n  }\n  throw e;\n}","preventionTips":["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."],"tags":["microsoft","langchain","agent","executor","rejection","ai-model","tools","node-operation-error"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}