{"record":{"id":"57e47950be1346ce","repo":"FlowiseAI/Flowise","slug":"cannot-call-the-same-agentflow-57e479","errorCode":null,"errorMessage":"Cannot call the same agentflow!","messagePattern":"Cannot call the same agentflow!","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/tools/AgentAsTool/AgentAsTool.ts","lineNumber":183,"sourceCode":"\n        const startNewSession = nodeData.inputs?.startNewSession as boolean\n\n        const baseURL = (nodeData.inputs?.baseURL as string) || (options.baseURL as string)\n\n        // Validate agentflowid is a valid UUID\n        if (!selectedAgentflowId || !isValidUUID(selectedAgentflowId)) {\n            throw new Error('Invalid agentflow ID: must be a valid UUID')\n        }\n\n        // Validate baseURL is a valid URL\n        if (!baseURL || !isValidURL(baseURL)) {\n            throw new Error('Invalid base URL: must be a valid URL')\n        }\n\n        const credentialData = await getCredentialData(nodeData.credential ?? '', options)\n        const agentflowApiKey = getCredentialParam('agentflowApiKey', credentialData, nodeData)\n\n        if (selectedAgentflowId === options.chatflowid) throw new Error('Cannot call the same agentflow!')\n\n        let headers = {}\n        if (agentflowApiKey) headers = { Authorization: `Bearer ${agentflowApiKey}` }\n\n        let toolInput = ''\n        if (useQuestionFromChat) {\n            toolInput = input\n        } else if (customInput) {\n            toolInput = customInput\n        }\n\n        let name = _name || 'agentflow_tool'\n\n        return new AgentflowTool({\n            name,\n            baseURL,\n            description,\n            returnDirect,","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/tools/AgentAsTool/AgentAsTool.ts#L165-L201","documentation":"Thrown when selectedAgentflowId equals options.chatflowid — i.e. the AgentAsTool is configured to invoke the very agentflow that is currently running. This is an explicit recursion guard: without it the flow would call itself over HTTP, creating an infinite request loop that drains resources until the stack/timeout collapses.","triggerScenarios":"A flow that contains an AgentAsTool node pointed at its own id (typical when duplicating a flow as a template); a dynamic config where selectedAgentflowId is computed and accidentally resolves to the host id.","commonSituations":"Building a 'meta' agent that orchestrates sub-agents and mistakenly listing itself in the selectable set; copy-pasting a tool config across flows without updating the target id.","solutions":["Select a different agentflow as the tool target — one that is not the currently executing flow.","If you genuinely need self-invocation, refactor to call the internal logic directly rather than via the HTTP tool.","Filter the agentflow dropdown so the host flow's own id is excluded from choices."],"exampleFix":"// before\nif (selectedAgentflowId === options.chatflowid) throw new Error('Cannot call the same agentflow!')\n// after: also guide the user to the fix\nif (selectedAgentflowId === options.chatflowid) {\n  throw new Error(\n    `Cannot call the same agentflow (id=${selectedAgentflowId}). ` +\n    `Pick a different target agentflow.`\n  )\n}","handlingStrategy":"validation","validationCode":"function assertNotSelfCall(targetId: string, hostId: string | undefined) {\n  if (targetId === hostId) {\n    throw new Error(`Cannot call the same agentflow (id=${targetId}). Pick a different target.`)\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Filter the dropdown listing so the host agentflow's own id is excluded.","When duplicating a flow, immediately re-target any self-referential tool nodes.","For orchestrator patterns, keep a denylist of 'self' ids at the config layer."],"tags":["recursion","validation","runtime","agentflow","guard"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}