{"record":{"id":"0a4db8bb25c8d575","repo":"FlowiseAI/Flowise","slug":"agent-needs-to-have-a-function-calling-capable-mod","errorCode":null,"errorMessage":"Agent needs to have a function calling capable models.","messagePattern":"Agent needs to have a function calling capable models\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/agentflow/Agent/Agent.ts","lineNumber":997,"sourceCode":"\n                    const builtInTool: ICommonObject = {\n                        type: tool,\n                        name: toolName\n                    }\n                    ;(toolsInstance as any).push(builtInTool)\n                    ;(availableTools as any).push({\n                        name: tool,\n                        toolNode: {\n                            label: tool,\n                            name: tool\n                        }\n                    })\n                }\n            }\n\n            if (llmNodeInstance && toolsInstance.length > 0) {\n                if (llmNodeInstance.bindTools === undefined) {\n                    throw new Error(`Agent needs to have a function calling capable models.`)\n                }\n\n                // @ts-ignore\n                llmNodeInstance = llmNodeInstance.bindTools(toolsInstance)\n            }\n\n            // Prepare messages array\n            const messages: BaseMessageLike[] = []\n\n            // Prepend history ONLY if it is the first node\n            if (prependedChatHistory.length > 0 && !runtimeChatHistory.length) {\n                for (const msg of prependedChatHistory) {\n                    const role: string = msg.role === 'apiMessage' ? 'assistant' : 'user'\n                    const content: string = msg.content ?? ''\n                    messages.push({\n                        role,\n                        content\n                    })","sourceCodeStart":979,"sourceCodeEnd":1015,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/agentflow/Agent/Agent.ts#L979-L1015","documentation":"Before invoking the agent, the code binds tools to the LLM via llmNodeInstance.bindTools(toolsInstance). If the resolved LLM instance has no bindTools method (undefined), the model cannot do function/tool calling, so the agent aborts. This is a capability check on the LangChain chat model wrapper.","triggerScenarios":"Selecting a chat model whose LangChain wrapper lacks bindTools (older LLM classes, some non-chat LLMs, certain embeddings-only or legacy completions models); toolsInstance.length > 0 combined with a non-function-calling model; a custom LLM node that did not implement bindTools.","commonSituations":"Switching the agent model from GPT-4/Claude to a smaller or older model that does not support tool calling; using a local LLM wrapper without function-calling support; langchain version downgrade removing bindTools from a model class; mixing an LLM (non-chat) node instead of a ChatModel node.","solutions":["Switch the Agent's model to a function-calling-capable chat model (e.g. gpt-4o, gpt-4-turbo, Claude 3, Gemini 1.5).","Remove the tools from the agent if the model must stay non-function-calling (run it as a plain chat node).","Upgrade langchain/@langchain/core so the model wrapper exposes bindTools.","If using a custom LLM node, implement bindTools(tools) on its class."],"exampleFix":"// before: agentModel points to a legacy LLM\ninputs.agentModel = 'llamaLegacy'\n\n// after: use a function-calling chat model\ninputs.agentModel = 'chatOpenAI'\ninputs.agentModelConfig = { model: 'gpt-4o', modelName: 'gpt-4o' }","handlingStrategy":"type-guard","validationCode":"function isFunctionCallingCapable(llmNodeInstance) {\n  return typeof llmNodeInstance?.bindTools === 'function'\n}\n// after init, before run:\nif (toolsInstance.length > 0 && !isFunctionCallingCapable(llmNodeInstance)) {\n  throw new Error('Selected model does not support function calling; pick a function-calling model or remove tools')\n}","typeGuard":"function supportsBindTools(llm) {\n  return !!llm && typeof llm.bindTools === 'function'\n}","tryCatchPattern":"try {\n  // agent.run(...)\n} catch (e) {\n  if (/function calling capable/.test(e.message)) {\n    // prompt user to switch model or remove tools\n  } else throw e\n}","preventionTips":["Maintain a known list of function-calling-capable models in the UI and filter the model dropdown when tools are attached.","Show a warning at design time when a non-function-calling model is paired with tools.","Pin a langchain version known to expose bindTools on your model wrappers."],"tags":["agent","function-calling","model-capability","tools"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}