{"record":{"id":"94013fd158f00ef3","repo":"FlowiseAI/Flowise","slug":"chat-model-component-not-found","errorCode":null,"errorMessage":"Chat model component not found","messagePattern":"Chat model component not found","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/src/agentflowv2Generator.ts","lineNumber":304,"sourceCode":"                selectedTools.push(...tools)\n\n                node.data.inputs.toolAgentflowSelectedTool = tools[0]\n                node.data.inputs.toolInputArgs = []\n                node.data.inputs.toolAgentflowSelectedToolConfig = {\n                    toolAgentflowSelectedTool: tools[0]\n                }\n            }\n        }\n    }\n\n    return nodes\n}\n\nconst _generateSelectedTools = async (config: Record<string, any>, question: string, options: ICommonObject) => {\n    try {\n        const chatModelComponent = config.componentNodes[config.selectedChatModel?.name]\n        if (!chatModelComponent) {\n            throw new Error('Chat model component not found')\n        }\n        const nodeInstanceFilePath = chatModelComponent.filePath as string\n        const nodeModule = await import(nodeInstanceFilePath)\n        const newToolNodeInstance = new nodeModule.nodeClass()\n        const model = (await newToolNodeInstance.init(config.selectedChatModel, '', options)) as BaseChatModel\n\n        // Create a parser to validate the output\n        const parser = StructuredOutputParser.fromZodSchema(ToolType as any)\n\n        // Generate JSON schema from our Zod schema\n        const formatInstructions = parser.getFormatInstructions()\n\n        // Full conversation with system prompt and instructions\n        const messages = [\n            {\n                role: 'system',\n                content: `${config.prompt}\\n\\n${formatInstructions}\\n\\nMake sure to follow the exact JSON schema structure.`\n            },","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/src/agentflowv2Generator.ts#L286-L322","documentation":"In _generateSelectedTools, the chat model component is looked up by `config.componentNodes[config.selectedChatModel?.name]`. If selectedChatModel is undefined/null or its .name does not match any key in componentNodes, the lookup returns undefined and the guard throws. The thrown error is itself caught by the surrounding try and returned as `{ error }`.","triggerScenarios":"agentflowv2 generation invoked with config.selectedChatModel missing, or with a .name that is not registered in config.componentNodes (deleted, renamed, or never connected).","commonSituations":"Agentflowv2 canvas has no Chat Model node connected; the Chat Model node was deleted or renamed after the agentflow was saved; component registry not fully loaded when generation runs; selectedChatModel.name typo.","solutions":["Ensure a Chat Model node is present and connected in the agentflowv2 canvas.","Re-select the Chat Model in the agentflow config so selectedChatModel.name matches a registered component.","Re-open and re-save the agentflow to refresh the config snapshot.","Verify config.componentNodes is populated (all node modules loaded) before calling the generator."],"exampleFix":"// before\nconst config = { componentNodes, selectedChatModel: undefined }\n_generateSelectedTools(config, q, opts) // throws\n\n// after\nif (!config.selectedChatModel || !config.componentNodes[config.selectedChatModel.name]) {\n    return { error: 'A connected Chat Model node is required' }\n}","handlingStrategy":"validation","validationCode":"// Validate config shape before calling _generateSelectedTools\nfunction assertChatModelSelected(config) {\n    const name = config.selectedChatModel?.name\n    if (!name || !config.componentNodes?.[name]) {\n        throw new Error(`selectedChatModel '${name ?? '<none>'}' is not in componentNodes`)\n    }\n}","typeGuard":"function hasChatModelComponent(config) {\n    const name = config.selectedChatModel?.name\n    return typeof name === 'string' && Boolean(config.componentNodes?.[name])\n}","tryCatchPattern":"// _generateSelectedTools already returns { error } on throw — surface it to the UI\nconst result = await _generateSelectedTools(config, question, options)\nif (result?.error) {\n    // prompt the user to connect a Chat Model node\n    return\n}","preventionTips":["Ensure the agentflowv2 canvas has a connected Chat Model node before generation.","Re-select the Chat Model after renaming/deleting to refresh selectedChatModel.name.","Populate config.componentNodes fully before invoking the generator."],"tags":["agentflow","configuration","chat-model","missing-dependency"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}