{"record":{"id":"c4b0e5b24c090b7c","repo":"n8n-io/n8n","slug":"agent-node-agentnodename-not-found-in-workflo-c4b0e5","errorCode":null,"errorMessage":"Agent node \"${agentNodeName}\" not found in workflow","messagePattern":"Agent node \"(.+?)\" not found in workflow","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/@n8n/instance-ai/src/tools/evals/detect-agent-named-refs.service.ts","lineNumber":37,"sourceCode":"\tcolumn: string;\n\t/** Which node has the parameter that references nodeName. Either the agent itself or a sub-component (memory, tool, ...). */\n\ttargetNodeName: string;\n}\n\nfunction slug(name: string): string {\n\tconst result = name\n\t\t.toLowerCase()\n\t\t.replace(/[^a-z0-9]+/g, '_')\n\t\t.replace(/^_+|_+$/g, '');\n\treturn result.length > 0 ? result : 'node';\n}\n\ntype RawMatch = NamedRefMatch;\n\nexport function detectAgentNamedRefs(workflow: WorkflowJSON, agentNodeName: string): NamedRef[] {\n\tconst node = (workflow.nodes ?? []).find((n) => nodeHasName(n) && n.name === agentNodeName);\n\tif (!node) {\n\t\tthrow new Error(`Agent node \"${agentNodeName}\" not found in workflow`);\n\t}\n\n\tconst targets = [agentNodeName, ...findAgentSubComponents(workflow, agentNodeName)];\n\tconst nodesByName = new Map(\n\t\t(workflow.nodes ?? []).filter(nodeHasName).map((n) => [n.name, n] as const),\n\t);\n\n\t// First pass: collect, per target, the de-duplicated set of (source, field) raw matches.\n\tconst targetMatches = new Map<string, RawMatch[]>();\n\tfor (const target of targets) {\n\t\tconst tNode = nodesByName.get(target);\n\t\tif (!tNode) continue;\n\t\tconst matches = collectStrings(tNode.parameters).flatMap((text) =>\n\t\t\textractNamedRefMatches(text),\n\t\t);\n\t\tconst dedup = new Map<string, RawMatch>();\n\t\tfor (const m of matches) {\n\t\t\tconst key = `${m.nodeName}\\x00${m.field}`;","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/src/tools/evals/detect-agent-named-refs.service.ts#L19-L55","documentation":"Error \"Agent node \"${agentNodeName}\" not found in workflow\" thrown in n8n-io/n8n.","triggerScenarios":"Thrown at packages/@n8n/instance-ai/src/tools/evals/detect-agent-named-refs.service.ts:37 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}