FlowiseAI/Flowise · error · Error
Invalid JSON in the Worker's Prompt Input Values: ${exceptio
Error message
Invalid JSON in the Worker's Prompt Input Values: ${exception} What it means
Thrown inside Worker.init's try/catch around `JSON.parse(promptValuesStr)`. The promptValues field accepts either an object or a JSON string of substitution values for the worker prompt template; if the string is malformed JSON, parse throws and is rethrown with this message.
Source
Thrown at packages/components/nodes/multiagents/Worker/Worker.ts:106
tools = flatten(tools)
let workerPrompt = nodeData.inputs?.workerPrompt as string
const workerLabel = nodeData.inputs?.workerName as string
const supervisor = nodeData.inputs?.supervisor as IMultiAgentNode
const maxIterations = nodeData.inputs?.maxIterations as string
const model = nodeData.inputs?.model as BaseChatModel
const promptValuesStr = nodeData.inputs?.promptValues
if (!workerLabel) throw new Error('Worker name is required!')
const workerName = workerLabel.toLowerCase().replace(/\s/g, '_').trim()
if (!workerPrompt) throw new Error('Worker prompt is required!')
let workerInputVariablesValues: ICommonObject = {}
if (promptValuesStr) {
try {
workerInputVariablesValues = typeof promptValuesStr === 'object' ? promptValuesStr : JSON.parse(promptValuesStr)
} catch (exception) {
throw new Error("Invalid JSON in the Worker's Prompt Input Values: " + exception)
}
}
workerInputVariablesValues = handleEscapeCharacters(workerInputVariablesValues, true)
const llm = model || (supervisor.llm as BaseChatModel)
const multiModalMessageContent = supervisor?.multiModalMessageContent || []
const abortControllerSignal = options.signal as AbortController
const workerInputVariables = getInputVariables(workerPrompt)
if (!workerInputVariables.every((element) => Object.keys(workerInputVariablesValues).includes(element))) {
throw new Error('Worker input variables values are not provided!')
}
const agent = await createAgent(
llm,
[...tools],
workerPrompt,View on GitHub (pinned to abe4a8601a)
Solutions
- Provide promptValues as valid JSON: `{"key": "value"}` with double quotes.
- If passing an object from a previous node, leave it as an object — the code path `typeof promptValuesStr === 'object'` skips JSON.parse.
- Run the JSON through a linter/validator before pasting.
- Improve the error message to include the parse position from `exception.message`.
Example fix
// before
workerInputVariablesValues = typeof promptValuesStr === 'object' ? promptValuesStr : JSON.parse(promptValuesStr)
// after
if (typeof promptValuesStr === 'string') {
try { workerInputVariablesValues = JSON.parse(promptValuesStr) }
catch (e) { throw new Error(`promptValues is not valid JSON at offset ${(e as Error).message}: got ${promptValuesStr.slice(0,80)}`) }
} else {
workerInputVariablesValues = promptValuesStr
} Defensive patterns
Strategy: validation
Validate before calling
function parsePromptValues(input: unknown): ICommonObject {
if (input == null) return {}
if (typeof input === 'object') return input as ICommonObject
try { return JSON.parse(input as string) }
catch (e) { throw new Error(`promptValues invalid JSON: ${(e as Error).message}`) }
} Type guard
const isPlainObject = (v: unknown): v is Record<string, unknown> => typeof v === 'object' && v !== null && !Array.isArray(v)
Try / catch
try { workerInputVariablesValues = JSON.parse(promptValuesStr) }
catch (e) { throw new Error(`promptValues JSON parse failed: ${(e as Error).message}`) } Prevention
- Always use double-quoted JSON.
- Pass objects between nodes instead of strings when possible.
- Validate JSON in the UI before submission.
When it happens
Trigger: User types a non-JSON string (e.g. `name=John`), uses single quotes, leaves a trailing comma, or pastes a JS object literal into the promptValues field.
Common situations: Manually editing promptValues in the node UI; passing a templated string that didn't get JSON-encoded upstream; locale-specific quote characters copied from a word processor.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Worker prompt is required!
- Returned message history must be an array
- Invalid JSON in the ChatPromptTemplate's promptValues: ${exc
- Invalid JSON in the FewShotPromptTemplate's examples: ${exce
- Invalid JSON in the PromptTemplate's promptValues: ${excepti
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/3b038ef82aaa6506.
Report an issue: GitHub.