FlowiseAI/Flowise · error · Error

Cannot call the same agentflow!

Error message

Cannot call the same agentflow!

What it means

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.

Source

Thrown at packages/components/nodes/tools/AgentAsTool/AgentAsTool.ts:183

        const startNewSession = nodeData.inputs?.startNewSession as boolean

        const baseURL = (nodeData.inputs?.baseURL as string) || (options.baseURL as string)

        // Validate agentflowid is a valid UUID
        if (!selectedAgentflowId || !isValidUUID(selectedAgentflowId)) {
            throw new Error('Invalid agentflow ID: must be a valid UUID')
        }

        // Validate baseURL is a valid URL
        if (!baseURL || !isValidURL(baseURL)) {
            throw new Error('Invalid base URL: must be a valid URL')
        }

        const credentialData = await getCredentialData(nodeData.credential ?? '', options)
        const agentflowApiKey = getCredentialParam('agentflowApiKey', credentialData, nodeData)

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

        let headers = {}
        if (agentflowApiKey) headers = { Authorization: `Bearer ${agentflowApiKey}` }

        let toolInput = ''
        if (useQuestionFromChat) {
            toolInput = input
        } else if (customInput) {
            toolInput = customInput
        }

        let name = _name || 'agentflow_tool'

        return new AgentflowTool({
            name,
            baseURL,
            description,
            returnDirect,

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Select a different agentflow as the tool target — one that is not the currently executing flow.
  2. If you genuinely need self-invocation, refactor to call the internal logic directly rather than via the HTTP tool.
  3. Filter the agentflow dropdown so the host flow's own id is excluded from choices.

Example fix

// before
if (selectedAgentflowId === options.chatflowid) throw new Error('Cannot call the same agentflow!')
// after: also guide the user to the fix
if (selectedAgentflowId === options.chatflowid) {
  throw new Error(
    `Cannot call the same agentflow (id=${selectedAgentflowId}). ` +
    `Pick a different target agentflow.`
  )
}
Defensive patterns

Strategy: validation

Validate before calling

function assertNotSelfCall(targetId: string, hostId: string | undefined) {
  if (targetId === hostId) {
    throw new Error(`Cannot call the same agentflow (id=${targetId}). Pick a different target.`)
  }
}

Prevention

When it happens

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

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

Related errors


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