FlowiseAI/Flowise · error · Error
Could not find JSON block in the output.
Error message
Could not find JSON block in the output.
What it means
ConditionAgent.parseJsonMarkdown throws 'Could not find JSON block in the output.' when it cannot find any recognized start/end delimiters (```json, ```, backticks, or { } ) with a valid ordering in the LLM response. This means the model returned plain prose or a format the extractor does not recognize — no JSON region to even attempt parsing.
Source
Thrown at packages/components/nodes/agentflow/ConditionAgent/ConditionAgent.ts:246
if (endIndex !== -1) {
if (jsonString[endIndex] === '}') {
endIndex += 1
}
break
}
}
}
if (startIndex !== -1 && endIndex !== -1 && startIndex < endIndex) {
const extractedContent = jsonString.slice(startIndex, endIndex).trim()
try {
return JSON.parse(extractedContent)
} catch (error) {
throw new Error(`Invalid JSON object. Error: ${error}`)
}
}
throw new Error('Could not find JSON block in the output.')
}
async run(nodeData: INodeData, question: string, options: ICommonObject): Promise<any> {
let llmIds: ICommonObject | undefined
let analyticHandlers = options.analyticHandlers as AnalyticHandler
try {
const abortController = options.abortController as AbortController
// Extract input parameters
const model = nodeData.inputs?.conditionAgentModel as string
const modelConfig = nodeData.inputs?.conditionAgentModelConfig as ICommonObject
if (!model) {
throw new Error('Model is required')
}
const modelName = modelConfig?.model ?? modelConfig?.modelName
const conditionAgentInput = nodeData.inputs?.conditionAgentInput as stringView on GitHub (pinned to abe4a8601a)
Solutions
- Reinforce JSON output in the system prompt and keep the few-shot example intact.
- Switch to a model that reliably follows formatting instructions.
- Reduce injected chat history / input size so the instruction is not crowded out.
- If overriding the system prompt, ensure it still mandates a fenced JSON object with an 'output' key.
Defensive patterns
Strategy: validation
Validate before calling
function hasJsonRegion(s) {
return /\{[\s\S]*\}|```json/i.test(s ?? '')
}
if (!hasJsonRegion(responseContent)) {
// retry the LLM call with a stronger JSON instruction instead of throwing
} Type guard
function containsJsonBlock(s) {
return /```json|```|`|\{/.test(s ?? '')
} Try / catch
try { parsed = parseJsonMarkdown(responseContent) }
catch (e) {
if (/Could not find JSON block/.test(e.message)) {
// re-prompt with explicit 'respond ONLY with fenced JSON'
} else throw e
} Prevention
- Make the JSON requirement the last instruction in the prompt.
- Always include the few-shot JSON example.
- Avoid overriding the system prompt in ways that drop the format mandate.
When it happens
Trigger: LLM returns a pure natural-language answer with no JSON; model returns only the scenario name as text without braces/fences; empty response; response using a delimiter the parser doesn't look for (e.g. indented YAML, XML tags).
Common situations: Model ignores the structured-output instruction entirely; system prompt overridden in a way that drops the JSON requirement; very small model that can't follow formatting; context window dominated by history leaving no room for the instruction.
Related errors
- Invalid JSON object. Error: ${error}
- LLM response is missing the "output" key or it is not a stri
- 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/ae8a8d549f473cc6.
Report an issue: GitHub.