{"record":{"id":"cc427db3a20d0e7f","repo":"FlowiseAI/Flowise","slug":"scenarios-are-required","errorCode":null,"errorMessage":"Scenarios are required","messagePattern":"Scenarios are required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/agentflow/ConditionAgent/ConditionAgent.ts","lineNumber":302,"sourceCode":"\n            // Initialize the LLM model instance\n            const nodeInstanceFilePath = options.componentNodes[model].filePath as string\n            const nodeModule = await import(nodeInstanceFilePath)\n            const newLLMNodeInstance = new nodeModule.nodeClass()\n            const newNodeData = {\n                ...nodeData,\n                credential: modelConfig['FLOWISE_CREDENTIAL_ID'],\n                inputs: {\n                    ...nodeData.inputs,\n                    ...modelConfig\n                }\n            }\n            let llmNodeInstance = (await newLLMNodeInstance.init(newNodeData, '', options)) as BaseChatModel\n\n            const isStructuredOutput =\n                _conditionAgentScenarios && Array.isArray(_conditionAgentScenarios) && _conditionAgentScenarios.length > 0\n            if (!isStructuredOutput) {\n                throw new Error('Scenarios are required')\n            }\n\n            // Prepare prefix messages (system prompt + few-shot examples) - needed for model invocation only\n            const prefixMessages: BaseMessageLike[] = [\n                {\n                    role: 'system',\n                    content: systemPrompt\n                },\n                {\n                    role: 'user',\n                    content: `{\"input\": \"Hello\", \"scenarios\": [\"user is asking about AI\", \"user is not asking about AI\"], \"instruction\": \"Your task is to check if the user is asking about AI.\"}`\n                },\n                {\n                    role: 'assistant',\n                    content: `\\`\\`\\`json\\n{\"output\": \"user is not asking about AI\"}\\n\\`\\`\\``\n                }\n            ]\n","sourceCodeStart":284,"sourceCodeEnd":320,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/agentflow/ConditionAgent/ConditionAgent.ts#L284-L320","documentation":"ConditionAgent.run treats scenarios as the set of branches it must classify into, and structured output is only enabled when _conditionAgentScenarios is a non-empty array. If that condition fails, it throws 'Scenarios are required' before building messages, because there is nothing to match the LLM output against.","triggerScenarios":"conditionAgentScenarios missing, null, an empty array, or a non-array (e.g. a comma-separated string); node saved before any scenarios were added; programmatic nodeData omitting the field.","commonSituations":"New Condition Agent created with no scenario rows; UI bug dropping scenarios on save; flow import where scenarios didn't serialize; user expecting default scenarios that don't exist.","solutions":["Add at least one scenario in the Condition Agent editor (e.g. [{ scenario: 'user is asking about AI' }, { scenario: 'user is not asking about AI' }]).","If setting nodeData programmatically, assign inputs.conditionAgentScenarios = [{ scenario: '...' }, ...].","Ensure the value is an array, not a comma-separated string.","Re-save the node after adding scenarios and redeploy."],"exampleFix":"// before\ninputs.conditionAgentScenarios = []\n\n// after\ninputs.conditionAgentScenarios = [\n  { scenario: 'user is asking about AI' },\n  { scenario: 'user is not asking about AI' }\n]","handlingStrategy":"validation","validationCode":"function ensureScenarios(scenarios) {\n  if (!Array.isArray(scenarios) || scenarios.length === 0 || !scenarios.every(s => s && typeof s.scenario === 'string')) {\n    throw new Error('conditionAgentScenarios must be a non-empty array of { scenario: string }')\n  }\n}\nensureScenarios(nodeData.inputs?.conditionAgentScenarios)","typeGuard":"function isScenarioArray(v) {\n  return Array.isArray(v) && v.length > 0 && v.every(s => !!s && typeof s.scenario === 'string')\n}","tryCatchPattern":"try { await conditionAgent.run(nodeData, question, options) }\ncatch (e) {\n  if (e.message === 'Scenarios are required') {\n    // prompt user to add scenarios, then retry\n  } else throw e\n}","preventionTips":["Require at least one scenario in the UI before save.","Validate the scenarios array shape on flow import.","Document that scenarios are mandatory for this node."],"tags":["condition-agent","validation","scenarios","configuration"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}