{"record":{"id":"ad847602525cc48a","repo":"FlowiseAI/Flowise","slug":"cannot-call-the-same-agentflow","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/agentflow/ExecuteFlow/ExecuteFlow.ts","lineNumber":189,"sourceCode":"            try {\n                overrideConfig = parseJsonBody(overrideConfig)\n            } catch (parseError) {\n                throw new Error(`Invalid JSON in executeFlowOverrideConfig: ${parseError.message}`)\n            }\n        }\n\n        const state = options.agentflowRuntime?.state as ICommonObject\n        const runtimeChatHistory = (options.agentflowRuntime?.chatHistory as BaseMessageLike[]) ?? []\n        const isLastNode = options.isLastNode as boolean\n        const sseStreamer: IServerSideEventStreamer | undefined = options.sseStreamer\n\n        try {\n            const credentialData = await getCredentialData(nodeData.credential ?? '', options)\n            const chatflowApiKey = getCredentialParam('chatflowApiKey', credentialData, nodeData)\n\n            if (!baseURL || !isValidURL(baseURL)) throw new Error('Invalid base URL: must be a valid URL')\n\n            if (selectedFlowId === options.chatflowid) throw new Error('Cannot call the same agentflow!')\n\n            let headers: Record<string, string> = {\n                'Content-Type': 'application/json',\n                'flowise-tool': 'true'\n            }\n            if (chatflowApiKey) headers = { ...headers, Authorization: `Bearer ${chatflowApiKey}` }\n\n            const finalUrl = `${baseURL}/api/v1/prediction/${selectedFlowId}`\n            const requestConfig: AxiosRequestConfig = {\n                method: 'POST',\n                url: finalUrl,\n                headers,\n                data: {\n                    question: flowInput,\n                    chatId: options.chatId,\n                    overrideConfig\n                }\n            }","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/agentflow/ExecuteFlow/ExecuteFlow.ts#L171-L207","documentation":"ExecuteFlow.run prevents an agentflow from invoking itself as a tool: if the selected target flow id equals the currently running chatflow id (options.chatflowid), it throws 'Cannot call the same agentflow!'. This is an infinite-recursion guard, raised right after the URL check and before the outbound request.","triggerScenarios":"An Execute Flow node configured to call the very agentflow it lives in; selectedFlowId copied from the current flow's id by mistake; a flow that dynamically resolves its own id as the target; templating that defaults selectedFlowId to the current chatflow.","commonSituations":"Operator picked the current flow in the target dropdown by accident; template/default value falling back to the current chatflowid; cloned flow where the Execute Flow target wasn't updated; self-referential tool wiring intended to loop.","solutions":["In the Execute Flow node, select a different target flow (not the current one).","If the target is templated, ensure the template resolves to a different flow id at runtime.","Refactor to break the cycle: move the shared logic into a separate flow that both can call.","If you genuinely need iteration, model it inside one flow rather than recursively calling the flow itself."],"exampleFix":"// before\nexecuteFlowSelectedFlow = options.chatflowid // self-reference\n\n// after\nexecuteFlowSelectedFlow = 'a-different-flow-id'","handlingStrategy":"validation","validationCode":"function assertNotSelfCall(selectedFlowId, currentChatflowId) {\n  if (selectedFlowId && selectedFlowId === currentChatflowId) {\n    throw new Error('Execute Flow target must differ from the current agentflow id')\n  }\n}\nassertNotSelfCall(nodeData.inputs?.executeFlowSelectedFlow, options.chatflowid)","typeGuard":"function isDifferentFlow(selectedId, currentId) {\n  return typeof selectedId === 'string' && selectedId.length > 0 && selectedId !== currentId\n}","tryCatchPattern":"try { await executeFlow.run(nodeData, '', options) }\ncatch (e) {\n  if (e.message === 'Cannot call the same agentflow!') {\n    // pick a different target flow id and retry\n  } else throw e\n}","preventionTips":["Exclude the current flow id from the target-flow dropdown in the UI.","If the target is templated, ensure it cannot resolve to the current chatflowid.","Extract shared logic into a separate flow to avoid self-invocation patterns."],"tags":["execute-flow","validation","recursion-guard","configuration"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}