{"record":{"id":"e28171460a22250c","repo":"FlowiseAI/Flowise","slug":"model-is-required","errorCode":null,"errorMessage":"Model is required","messagePattern":"Model is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/agentflow/Agent/Agent.ts","lineNumber":698,"sourceCode":"                    })\n                }\n            }\n            return returnOptions\n        }\n    }\n\n    async run(nodeData: INodeData, input: string | Record<string, any>, options: ICommonObject): Promise<any> {\n        let llmIds: ICommonObject | undefined\n        let analyticHandlers = options.analyticHandlers as AnalyticHandler\n\n        try {\n            const abortController = options.abortController as AbortController\n\n            // Extract input parameters\n            const model = nodeData.inputs?.agentModel as string\n            const modelConfig = nodeData.inputs?.agentModelConfig as ICommonObject\n            if (!model) {\n                throw new Error('Model is required')\n            }\n            const modelName = modelConfig?.model ?? modelConfig?.modelName\n\n            // Extract tools\n            const tools = nodeData.inputs?.agentTools as ITool[]\n\n            const toolsInstance: Tool[] = []\n            for (const tool of tools) {\n                const toolConfig = tool.agentSelectedToolConfig\n                const nodeInstanceFilePath = options.componentNodes[tool.agentSelectedTool].filePath as string\n                const nodeModule = await import(nodeInstanceFilePath)\n                const newToolNodeInstance = new nodeModule.nodeClass()\n                const newNodeData = {\n                    ...nodeData,\n                    credential: toolConfig['FLOWISE_CREDENTIAL_ID'],\n                    inputs: {\n                        ...nodeData.inputs,\n                        ...toolConfig","sourceCodeStart":680,"sourceCodeEnd":716,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/agentflow/Agent/Agent.ts#L680-L716","documentation":"Agent.run requires nodeData.inputs.agentModel to be truthy; it is the key used to locate the LLM component node in options.componentNodes. Thrown at the very start of the try block before any tool or model setup, so the agent cannot run without an explicitly selected model.","triggerScenarios":"An Agent node saved in the canvas with no model selected (agentModel empty/undefined); a flow JSON imported where the agentModel field was stripped; programmatic nodeData construction omitting agentModel; model node deleted from componentNodes after the agent was configured.","commonSituations":"New agent node created but model picker left blank; flow template referencing a model that no longer exists; copy-paste of node config losing the model binding; UI race where the model select hasn't populated before save.","solutions":["Open the Agent node in the editor and pick a model from the Model dropdown, then save the flow.","If building nodeData programmatically, set inputs.agentModel to a valid component node name (e.g. 'chatOpenAI').","Confirm the referenced model component still exists in options.componentNodes at runtime.","Validate the saved flow JSON contains a non-empty agentModel before deployment."],"exampleFix":"// before\nnodeData.inputs = { agentModel: '' }\n\n// after\nnodeData.inputs = { agentModel: 'chatOpenAI', agentModelConfig: { model: 'gpt-4o', modelName: 'gpt-4o' } }","handlingStrategy":"validation","validationCode":"function ensureAgentModel(nodeData, componentNodes) {\n  const model = nodeData.inputs?.agentModel\n  if (!model || !componentNodes?.[model]) {\n    throw new Error(`Agent node requires a valid agentModel present in componentNodes (got '${model}')`)\n  }\n  return model\n}\nensureAgentModel(nodeData, options.componentNodes)","typeGuard":"function hasAgentModel(nodeData, componentNodes) {\n  const m = nodeData?.inputs?.agentModel\n  return typeof m === 'string' && m.length > 0 && !!componentNodes?.[m]\n}","tryCatchPattern":"if (!hasAgentModel(nodeData, options.componentNodes)) {\n  // surface a friendly UI error and skip execution\n} else {\n  await agent.run(nodeData, input, options)\n}","preventionTips":["Block flow save when an Agent node has no model selected.","Validate flow JSON for required fields before deploy.","Warn when a referenced model component is deleted from the project."],"tags":["agent","validation","model-config","configuration"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}