{"record":{"id":"2c5b31153935e428","repo":"FlowiseAI/Flowise","slug":"invalid-json-in-the-agent-s-prompt-input-values","errorCode":null,"errorMessage":"Invalid JSON in the Agent's Prompt Input Values: ${exception}","messagePattern":"Invalid JSON in the Agent's Prompt Input Values: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/sequentialagents/Agent/Agent.ts","lineNumber":490,"sourceCode":"        const agentLabel = nodeData.inputs?.agentName as string\n        const sequentialNodes = nodeData.inputs?.sequentialNode as ISeqAgentNode[]\n        const maxIterations = nodeData.inputs?.maxIterations as string\n        const model = nodeData.inputs?.model as BaseChatModel\n        const promptValuesStr = nodeData.inputs?.promptValues\n        const output = nodeData.outputs?.output as string\n        const approvalPrompt = nodeData.inputs?.approvalPrompt as string\n\n        if (!agentLabel) throw new Error('Agent name is required!')\n        const agentName = agentLabel.toLowerCase().replace(/\\s/g, '_').trim()\n\n        if (!sequentialNodes || !sequentialNodes.length) throw new Error('Agent must have a predecessor!')\n\n        let agentInputVariablesValues: ICommonObject = {}\n        if (promptValuesStr) {\n            try {\n                agentInputVariablesValues = typeof promptValuesStr === 'object' ? promptValuesStr : JSON.parse(promptValuesStr)\n            } catch (exception) {\n                throw new Error(\"Invalid JSON in the Agent's Prompt Input Values: \" + exception)\n            }\n        }\n        agentInputVariablesValues = handleEscapeCharacters(agentInputVariablesValues, true)\n\n        const startLLM = sequentialNodes[0].startLLM\n        const llm = model || startLLM\n        if (nodeData.inputs) nodeData.inputs.model = llm\n\n        const multiModalMessageContent = sequentialNodes[0]?.multiModalMessageContent || (await processImageMessage(llm, nodeData, options))\n        const abortControllerSignal = options.signal as AbortController\n        const agentInputVariables = uniq([...getInputVariables(agentSystemPrompt), ...getInputVariables(agentHumanPrompt)])\n\n        if (!agentInputVariables.every((element) => Object.keys(agentInputVariablesValues).includes(element))) {\n            throw new Error('Agent input variables values are not provided!')\n        }\n\n        const interrupt = nodeData.inputs?.interrupt as boolean\n","sourceCodeStart":472,"sourceCodeEnd":508,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/sequentialagents/Agent/Agent.ts#L472-L508","documentation":"Thrown when the Agent's `promptValues` input is a string that fails `JSON.parse`. The block first short-circuits if promptValues is already an object (typeof === 'object'), so this error specifically means a malformed JSON string was supplied. The original parse exception is appended for diagnostics.","triggerScenarios":"Calling Agent.init with `nodeData.inputs.promptValues` set to a non-empty string that is not valid JSON — e.g. `\"color: blue\"`, `\"'key':'val'\"`, or text containing smart quotes / trailing commas.","commonSituations":"User typed free-form text into the Prompt Input Values field instead of a JSON object; copy-pasted from Word/Slack/Notion which converted straight quotes to curly quotes; left a trailing comma; used single quotes around keys; mixed JSON with Flowise templating syntax.","solutions":["Replace the value with a valid JSON object string, e.g. `{\"customerName\":\"Alice\"}`.","If building the value programmatically, pass the parsed object directly so the `typeof === 'object'` branch skips JSON.parse.","Strip smart quotes and verify the string in a browser console with `JSON.parse(value)` before saving the node.","Ensure keys are double-quoted and there are no trailing commas."],"exampleFix":"// before\nnodeData.inputs.promptValues = \"name: Alice, age: 30\" // throws [281]\n\n// after\nnodeData.inputs.promptValues = '{\"name\":\"Alice\",\"age\":30}'\n// or pass object directly\nnodeData.inputs.promptValues = { name: 'Alice', age: 30 }","handlingStrategy":"validation","validationCode":"function parsePromptValuesSafe(raw) {\n  if (raw == null) return {}\n  if (typeof raw === 'object') return raw\n  try {\n    const parsed = JSON.parse(raw)\n    if (typeof parsed !== 'object' || Array.isArray(parsed) || parsed === null) {\n      throw new Error('Prompt Input Values must be a JSON object, not an array or primitive.')\n    }\n    return parsed\n  } catch (e) {\n    throw new Error(`Prompt Input Values is not valid JSON: ${e.message}`)\n  }\n}\n\nconst agentInputVariablesValues = parsePromptValuesSafe(nodeData.inputs.promptValues)","typeGuard":"function isJsonObjectString(s): s is string {\n  if (typeof s !== 'string') return false\n  try { return typeof JSON.parse(s) === 'object' && !Array.isArray(JSON.parse(s)) }\n  catch { return false }\n}","tryCatchPattern":null,"preventionTips":["Always use double-quoted keys in promptValues JSON.","Paste values through a JSON linter before saving.","Pass parsed objects directly when calling init from code to skip JSON.parse entirely."],"tags":["configuration","json","input-validation","prompts"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}