FlowiseAI/Flowise · error · Error
LLM response is missing the "output" key or it is not a stri
Error message
LLM response is missing the "output" key or it is not a string.
What it means
After the LLM responds, ConditionAgent.parseJsonMarkdown parses the content and requires parsedResponse.output to be a truthy string — the matched scenario name. If output is missing, null, a number, or an object, the agent cannot pick a scenario and throws this. It is then caught locally and re-thrown as the 'Failed to parse a valid scenario' message (error 14).
Source
Thrown at packages/components/nodes/agentflow/ConditionAgent/ConditionAgent.ts:415
if (analyticHandlers && llmIds) {
const analyticsOutput: any = {
content: responseContent
}
// Include usage metadata if available
if (response.usage_metadata) {
analyticsOutput.usageMetadata = response.usage_metadata
}
// Include response metadata (contains model name) if available
if (response.response_metadata) {
analyticsOutput.responseMetadata = response.response_metadata
}
await analyticHandlers.onLLMEnd(llmIds, analyticsOutput, { model: modelName, provider: model })
}
let calledOutputName: string
try {
const parsedResponse = this.parseJsonMarkdown(responseContent)
if (!parsedResponse.output || typeof parsedResponse.output !== 'string') {
throw new Error('LLM response is missing the "output" key or it is not a string.')
}
calledOutputName = parsedResponse.output
} catch (error) {
throw new Error(
`Failed to parse a valid scenario from the LLM's response. Please check if the model is capable of following JSON output instructions. Raw LLM Response: "${responseContent}"`
)
}
// Clean up empty inputs
for (const key in nodeData.inputs) {
if (nodeData.inputs[key] === '') {
delete nodeData.inputs[key]
}
}
const matchedScenarioIndex = findBestScenarioIndex(_conditionAgentScenarios, calledOutputName)
const conditions = _conditionAgentScenarios.map((scenario, index) => {View on GitHub (pinned to abe4a8601a)
Solutions
- Reinforce in the system prompt that the JSON must contain an 'output' string key holding exactly one scenario name.
- Keep the provided few-shot example (which shows {"output": "..."}).
- Switch to a model with stronger instruction-following or native JSON mode.
- If you control the LLM tool/structured schema, enforce an 'output' string property.
Defensive patterns
Strategy: validation
Validate before calling
function extractScenarioOutput(parsed) {
if (!parsed || typeof parsed.output !== 'string' || parsed.output.length === 0) {
throw new Error('LLM JSON must contain a non-empty string "output" key')
}
return parsed.output
} Type guard
function hasStringOutput(parsed) {
return !!parsed && typeof parsed.output === 'string' && parsed.output.length > 0
} Try / catch
try { calledOutputName = extractScenarioOutput(parsedResponse) }
catch { /* re-prompt the model with stricter instructions */ } Prevention
- Keep the few-shot example showing {"output": "..."}.
- Use structured-output / tool-calling to enforce the output schema.
- Do not override the system prompt in a way that drops the 'output' key.
When it happens
Trigger: LLM returns valid JSON but with a different key (e.g. 'result', 'answer', 'scenario' instead of 'output'); output is a number/boolean; output is an empty string; output is an array of names instead of a single name.
Common situations: Model deviating from the few-shot schema; prompt override dropping the 'output' key requirement; model returning the scenario text under a key it guessed; structured-output schema drift.
Related errors
- Invalid JSON object. Error: ${error}
- Could not find JSON block in the output.
- Failed to parse a valid scenario from the LLM's response. Pl
- Model is required
- Scenarios are required
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/1512eda9d8aed6d8.
Report an issue: GitHub.