FlowiseAI/Flowise · error · Error

Cannot call the same agentflow!

Error message

Cannot call the same agentflow!

What it means

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.

Source

Thrown at packages/components/nodes/agentflow/ExecuteFlow/ExecuteFlow.ts:189

            try {
                overrideConfig = parseJsonBody(overrideConfig)
            } catch (parseError) {
                throw new Error(`Invalid JSON in executeFlowOverrideConfig: ${parseError.message}`)
            }
        }

        const state = options.agentflowRuntime?.state as ICommonObject
        const runtimeChatHistory = (options.agentflowRuntime?.chatHistory as BaseMessageLike[]) ?? []
        const isLastNode = options.isLastNode as boolean
        const sseStreamer: IServerSideEventStreamer | undefined = options.sseStreamer

        try {
            const credentialData = await getCredentialData(nodeData.credential ?? '', options)
            const chatflowApiKey = getCredentialParam('chatflowApiKey', credentialData, nodeData)

            if (!baseURL || !isValidURL(baseURL)) throw new Error('Invalid base URL: must be a valid URL')

            if (selectedFlowId === options.chatflowid) throw new Error('Cannot call the same agentflow!')

            let headers: Record<string, string> = {
                'Content-Type': 'application/json',
                'flowise-tool': 'true'
            }
            if (chatflowApiKey) headers = { ...headers, Authorization: `Bearer ${chatflowApiKey}` }

            const finalUrl = `${baseURL}/api/v1/prediction/${selectedFlowId}`
            const requestConfig: AxiosRequestConfig = {
                method: 'POST',
                url: finalUrl,
                headers,
                data: {
                    question: flowInput,
                    chatId: options.chatId,
                    overrideConfig
                }
            }

View on GitHub (pinned to abe4a8601a)

Solutions

  1. In the Execute Flow node, select a different target flow (not the current one).
  2. If the target is templated, ensure the template resolves to a different flow id at runtime.
  3. Refactor to break the cycle: move the shared logic into a separate flow that both can call.
  4. If you genuinely need iteration, model it inside one flow rather than recursively calling the flow itself.

Example fix

// before
executeFlowSelectedFlow = options.chatflowid // self-reference

// after
executeFlowSelectedFlow = 'a-different-flow-id'
Defensive patterns

Strategy: validation

Validate before calling

function assertNotSelfCall(selectedFlowId, currentChatflowId) {
  if (selectedFlowId && selectedFlowId === currentChatflowId) {
    throw new Error('Execute Flow target must differ from the current agentflow id')
  }
}
assertNotSelfCall(nodeData.inputs?.executeFlowSelectedFlow, options.chatflowid)

Type guard

function isDifferentFlow(selectedId, currentId) {
  return typeof selectedId === 'string' && selectedId.length > 0 && selectedId !== currentId
}

Try / catch

try { await executeFlow.run(nodeData, '', options) }
catch (e) {
  if (e.message === 'Cannot call the same agentflow!') {
    // pick a different target flow id and retry
  } else throw e
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12). Data as JSON: /api/errors/ad847602525cc48a. Report an issue: GitHub.