{"record":{"id":"032ec4dd0a98c886","repo":"n8n-io/n8n","slug":"agent-node-agentnodename-not-found-in-workflo-032ec4","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-tool-refs.service.ts","lineNumber":60,"sourceCode":"\t}\n\treturn reached;\n}\n\n/**\n * Detects named cross-node references inside the AI agent's sub-components\n * (tools, memory, output parsers — anything wired in via `ai_*`). Filters\n * out refs that:\n *   - point to nodes not present in the workflow,\n *   - point to the agent itself,\n *   - point to nodes downstream of the agent (those execute during eval).\n *\n * Each remaining ref names a node whose data must be supplied via `pinData`\n * for eval runs to see realistic context.\n */\nexport function detectToolRefs(workflow: WorkflowJSON, agentNodeName: string): ToolRef[] {\n\tconst agent = (workflow.nodes ?? []).find((n) => nodeHasName(n) && n.name === agentNodeName);\n\tif (!agent) {\n\t\tthrow new Error(`Agent node \"${agentNodeName}\" not found in workflow`);\n\t}\n\n\tconst subComponents = findAgentSubComponents(workflow, agentNodeName);\n\tif (subComponents.length === 0) return [];\n\n\tconst nodesByName = new Map(\n\t\t(workflow.nodes ?? []).filter(nodeHasName).map((n) => [n.name, n] as const),\n\t);\n\tconst downstream = reachableDownstreamMain(workflow, agentNodeName);\n\n\tconst seen = new Set<string>();\n\tconst result: ToolRef[] = [];\n\tfor (const toolNodeName of subComponents) {\n\t\tconst toolNode = nodesByName.get(toolNodeName);\n\t\tif (!toolNode) continue;\n\t\tconst matches = collectStrings(toolNode.parameters).flatMap((text) =>\n\t\t\textractNamedRefMatches(text),\n\t\t);","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/src/tools/evals/detect-tool-refs.service.ts#L42-L78","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-tool-refs.service.ts:60 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-12T13:17:24.610Z"}