FlowiseAI/Flowise · error · Error

Condition Agent must have a predecessor!

Error message

Condition Agent must have a predecessor!

What it means

Thrown by ConditionAgent_SeqAgents.init when `sequentialNode` is undefined/null/empty. A ConditionAgent inherits `startLLM` from an upstream node (it falls back to `model || startLLM`) and needs `predecessorAgents` to participate in the graph. Without a predecessor the node cannot construct its conditional edge.

Source

Thrown at packages/components/nodes/sequentialagents/ConditionAgent/ConditionAgent.ts:405

                isAnchor: true
            }
        ]
    }

    async init(nodeData: INodeData, input: string, options: ICommonObject): Promise<any> {
        const conditionLabel = nodeData.inputs?.conditionAgentName as string
        const conditionName = conditionLabel.toLowerCase().replace(/\s/g, '_').trim()
        const output = nodeData.outputs?.output as string
        const sequentialNodes = nodeData.inputs?.sequentialNode as ISeqAgentNode[]
        let agentPrompt = nodeData.inputs?.systemMessagePrompt as string
        agentPrompt = transformBracesWithColon(agentPrompt)
        let humanPrompt = nodeData.inputs?.humanMessagePrompt as string
        humanPrompt = transformBracesWithColon(humanPrompt)
        const promptValuesStr = nodeData.inputs?.promptValues
        const conditionAgentStructuredOutput = nodeData.inputs?.conditionAgentStructuredOutput
        const model = nodeData.inputs?.model as BaseChatModel

        if (!sequentialNodes || !sequentialNodes.length) throw new Error('Condition Agent must have a predecessor!')

        const startLLM = sequentialNodes[0].startLLM
        const llm = model || startLLM
        if (nodeData.inputs) nodeData.inputs.model = llm

        let conditionAgentInputVariablesValues: ICommonObject = {}
        if (promptValuesStr) {
            try {
                conditionAgentInputVariablesValues = typeof promptValuesStr === 'object' ? promptValuesStr : JSON.parse(promptValuesStr)
            } catch (exception) {
                throw new Error("Invalid JSON in the Condition Agent's Prompt Input Values: " + exception)
            }
        }
        conditionAgentInputVariablesValues = handleEscapeCharacters(conditionAgentInputVariablesValues, true)

        const conditionAgentInputVariables = uniq([...getInputVariables(agentPrompt), ...getInputVariables(humanPrompt)])

        if (!conditionAgentInputVariables.every((element) => Object.keys(conditionAgentInputVariablesValues).includes(element))) {

View on GitHub (pinned to abe4a8601a)

Solutions

  1. Wire a sequential edge from a Start node (or another Agent/Condition) into this ConditionAgent's `sequentialNode` anchor.
  2. Ensure the first node in the graph is a Sequential Agents Start node.
  3. Programmatically, verify `sequentialNode` is a non-empty array before calling init.

Example fix

// before
nodeData.inputs.sequentialNode = [] // throws [295]

// after
nodeData.inputs.sequentialNode = [{ id: 'start', startLLM, predecessorAgents: [] }]
Defensive patterns

Strategy: validation

Validate before calling

function validateConditionAgentPredecessor(nodeData) {
  const seq = nodeData?.inputs?.sequentialNode
  if (!Array.isArray(seq) || seq.length === 0) {
    return { ok: false, message: 'ConditionAgent must have a predecessor! Wire a sequential edge from a Start/Agent node.' }
  }
  if (!seq[0]?.startLLM) {
    return { ok: false, message: 'Predecessor is missing startLLM — ensure the upstream node is a Start node.' }
  }
  return { ok: true }
}

const check = validateConditionAgentPredecessor(nodeData)
if (!check.ok) throw new Error(check.message)

Type guard

function isNonEmptySeqAgentNodeArray(v): v is ISeqAgentNode[] {
  return Array.isArray(v) && v.length > 0 && typeof v[0]?.startLLM !== 'undefined'
}

Prevention

When it happens

Trigger: Calling ConditionAgent.init with no upstream sequential edge — `nodeData.inputs.sequentialNode` is missing or an empty array.

Common situations: ConditionAgent dropped on the canvas without being connected from a Start/Agent node; predecessor init errored so no `ISeqAgentNode` was passed downstream; the first node is a ConditionAgent instead of Start.

Related errors


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