FlowiseAI/Flowise · error · Error
Chat model component not found
Error message
Chat model component not found
What it means
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 }`.
Source
Thrown at packages/components/src/agentflowv2Generator.ts:304
selectedTools.push(...tools)
node.data.inputs.toolAgentflowSelectedTool = tools[0]
node.data.inputs.toolInputArgs = []
node.data.inputs.toolAgentflowSelectedToolConfig = {
toolAgentflowSelectedTool: tools[0]
}
}
}
}
return nodes
}
const _generateSelectedTools = async (config: Record<string, any>, question: string, options: ICommonObject) => {
try {
const chatModelComponent = config.componentNodes[config.selectedChatModel?.name]
if (!chatModelComponent) {
throw new Error('Chat model component not found')
}
const nodeInstanceFilePath = chatModelComponent.filePath as string
const nodeModule = await import(nodeInstanceFilePath)
const newToolNodeInstance = new nodeModule.nodeClass()
const model = (await newToolNodeInstance.init(config.selectedChatModel, '', options)) as BaseChatModel
// Create a parser to validate the output
const parser = StructuredOutputParser.fromZodSchema(ToolType as any)
// Generate JSON schema from our Zod schema
const formatInstructions = parser.getFormatInstructions()
// Full conversation with system prompt and instructions
const messages = [
{
role: 'system',
content: `${config.prompt}\n\n${formatInstructions}\n\nMake sure to follow the exact JSON schema structure.`
},View on GitHub (pinned to abe4a8601a)
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.
Example fix
// before
const config = { componentNodes, selectedChatModel: undefined }
_generateSelectedTools(config, q, opts) // throws
// after
if (!config.selectedChatModel || !config.componentNodes[config.selectedChatModel.name]) {
return { error: 'A connected Chat Model node is required' }
} Defensive patterns
Strategy: validation
Validate before calling
// Validate config shape before calling _generateSelectedTools
function assertChatModelSelected(config) {
const name = config.selectedChatModel?.name
if (!name || !config.componentNodes?.[name]) {
throw new Error(`selectedChatModel '${name ?? '<none>'}' is not in componentNodes`)
}
} Type guard
function hasChatModelComponent(config) {
const name = config.selectedChatModel?.name
return typeof name === 'string' && Boolean(config.componentNodes?.[name])
} Try / catch
// _generateSelectedTools already returns { error } on throw — surface it to the UI
const result = await _generateSelectedTools(config, question, options)
if (result?.error) {
// prompt the user to connect a Chat Model node
return
} Prevention
- 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.
When it happens
Trigger: agentflowv2 generation invoked with config.selectedChatModel missing, or with a .name that is not registered in config.componentNodes (deleted, renamed, or never connected).
Common situations: 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.
Related errors
- Model is required
- Model is required
- Scenarios are required
- Invalid JSON in executeFlowOverrideConfig: ${parseError.mess
- Invalid base URL: must be a valid URL
AI-assisted analysis of FlowiseAI/Flowise@abe4a8601a (2026-08-12).
Data as JSON: /api/errors/94013fd158f00ef3.
Report an issue: GitHub.