FlowiseAI/Flowise · error · Error

Scenarios are required

Error message

Scenarios are required

What it means

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.

Source

Thrown at packages/components/nodes/agentflow/ConditionAgent/ConditionAgent.ts:302

            // Initialize the LLM model instance
            const nodeInstanceFilePath = options.componentNodes[model].filePath as string
            const nodeModule = await import(nodeInstanceFilePath)
            const newLLMNodeInstance = new nodeModule.nodeClass()
            const newNodeData = {
                ...nodeData,
                credential: modelConfig['FLOWISE_CREDENTIAL_ID'],
                inputs: {
                    ...nodeData.inputs,
                    ...modelConfig
                }
            }
            let llmNodeInstance = (await newLLMNodeInstance.init(newNodeData, '', options)) as BaseChatModel

            const isStructuredOutput =
                _conditionAgentScenarios && Array.isArray(_conditionAgentScenarios) && _conditionAgentScenarios.length > 0
            if (!isStructuredOutput) {
                throw new Error('Scenarios are required')
            }

            // Prepare prefix messages (system prompt + few-shot examples) - needed for model invocation only
            const prefixMessages: BaseMessageLike[] = [
                {
                    role: 'system',
                    content: systemPrompt
                },
                {
                    role: 'user',
                    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."}`
                },
                {
                    role: 'assistant',
                    content: `\`\`\`json\n{"output": "user is not asking about AI"}\n\`\`\``
                }
            ]

View on GitHub (pinned to abe4a8601a)

Solutions

  1. 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' }]).
  2. If setting nodeData programmatically, assign inputs.conditionAgentScenarios = [{ scenario: '...' }, ...].
  3. Ensure the value is an array, not a comma-separated string.
  4. Re-save the node after adding scenarios and redeploy.

Example fix

// before
inputs.conditionAgentScenarios = []

// after
inputs.conditionAgentScenarios = [
  { scenario: 'user is asking about AI' },
  { scenario: 'user is not asking about AI' }
]
Defensive patterns

Strategy: validation

Validate before calling

function ensureScenarios(scenarios) {
  if (!Array.isArray(scenarios) || scenarios.length === 0 || !scenarios.every(s => s && typeof s.scenario === 'string')) {
    throw new Error('conditionAgentScenarios must be a non-empty array of { scenario: string }')
  }
}
ensureScenarios(nodeData.inputs?.conditionAgentScenarios)

Type guard

function isScenarioArray(v) {
  return Array.isArray(v) && v.length > 0 && v.every(s => !!s && typeof s.scenario === 'string')
}

Try / catch

try { await conditionAgent.run(nodeData, question, options) }
catch (e) {
  if (e.message === 'Scenarios are required') {
    // prompt user to add scenarios, then retry
  } else throw e
}

Prevention

When it happens

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

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

Related errors


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