{"record":{"id":"2d20380b86f39b76","repo":"FlowiseAI/Flowise","slug":"condition-agent-must-have-a-predecessor","errorCode":null,"errorMessage":"Condition Agent must have a predecessor!","messagePattern":"Condition Agent must have a predecessor!","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/sequentialagents/ConditionAgent/ConditionAgent.ts","lineNumber":405,"sourceCode":"                isAnchor: true\n            }\n        ]\n    }\n\n    async init(nodeData: INodeData, input: string, options: ICommonObject): Promise<any> {\n        const conditionLabel = nodeData.inputs?.conditionAgentName as string\n        const conditionName = conditionLabel.toLowerCase().replace(/\\s/g, '_').trim()\n        const output = nodeData.outputs?.output as string\n        const sequentialNodes = nodeData.inputs?.sequentialNode as ISeqAgentNode[]\n        let agentPrompt = nodeData.inputs?.systemMessagePrompt as string\n        agentPrompt = transformBracesWithColon(agentPrompt)\n        let humanPrompt = nodeData.inputs?.humanMessagePrompt as string\n        humanPrompt = transformBracesWithColon(humanPrompt)\n        const promptValuesStr = nodeData.inputs?.promptValues\n        const conditionAgentStructuredOutput = nodeData.inputs?.conditionAgentStructuredOutput\n        const model = nodeData.inputs?.model as BaseChatModel\n\n        if (!sequentialNodes || !sequentialNodes.length) throw new Error('Condition Agent must have a predecessor!')\n\n        const startLLM = sequentialNodes[0].startLLM\n        const llm = model || startLLM\n        if (nodeData.inputs) nodeData.inputs.model = llm\n\n        let conditionAgentInputVariablesValues: ICommonObject = {}\n        if (promptValuesStr) {\n            try {\n                conditionAgentInputVariablesValues = typeof promptValuesStr === 'object' ? promptValuesStr : JSON.parse(promptValuesStr)\n            } catch (exception) {\n                throw new Error(\"Invalid JSON in the Condition Agent's Prompt Input Values: \" + exception)\n            }\n        }\n        conditionAgentInputVariablesValues = handleEscapeCharacters(conditionAgentInputVariablesValues, true)\n\n        const conditionAgentInputVariables = uniq([...getInputVariables(agentPrompt), ...getInputVariables(humanPrompt)])\n\n        if (!conditionAgentInputVariables.every((element) => Object.keys(conditionAgentInputVariablesValues).includes(element))) {","sourceCodeStart":387,"sourceCodeEnd":423,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/sequentialagents/ConditionAgent/ConditionAgent.ts#L387-L423","documentation":"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.","triggerScenarios":"Calling ConditionAgent.init with no upstream sequential edge — `nodeData.inputs.sequentialNode` is missing or an empty array.","commonSituations":"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.","solutions":["Wire a sequential edge from a Start node (or another Agent/Condition) into this ConditionAgent's `sequentialNode` anchor.","Ensure the first node in the graph is a Sequential Agents Start node.","Programmatically, verify `sequentialNode` is a non-empty array before calling init."],"exampleFix":"// before\nnodeData.inputs.sequentialNode = [] // throws [295]\n\n// after\nnodeData.inputs.sequentialNode = [{ id: 'start', startLLM, predecessorAgents: [] }]","handlingStrategy":"validation","validationCode":"function validateConditionAgentPredecessor(nodeData) {\n  const seq = nodeData?.inputs?.sequentialNode\n  if (!Array.isArray(seq) || seq.length === 0) {\n    return { ok: false, message: 'ConditionAgent must have a predecessor! Wire a sequential edge from a Start/Agent node.' }\n  }\n  if (!seq[0]?.startLLM) {\n    return { ok: false, message: 'Predecessor is missing startLLM — ensure the upstream node is a Start node.' }\n  }\n  return { ok: true }\n}\n\nconst check = validateConditionAgentPredecessor(nodeData)\nif (!check.ok) throw new Error(check.message)","typeGuard":"function isNonEmptySeqAgentNodeArray(v): v is ISeqAgentNode[] {\n  return Array.isArray(v) && v.length > 0 && typeof v[0]?.startLLM !== 'undefined'\n}","tryCatchPattern":null,"preventionTips":["Place a Start node first in the canvas so ConditionAgent inherits startLLM.","Verify predecessor init succeeded so its ISeqAgentNode is passed downstream.","Validate `sequentialNode` programmatically before init."],"tags":["sequential-agents","graph-wiring","validation","condition"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}