{"record":{"id":"0438ddffa58c07bc","repo":"FlowiseAI/Flowise","slug":"this-agent-requires-that-the-bindtools-method","errorCode":null,"errorMessage":"This agent requires that the \"bindTools()\" method be implemented on the input model.","messagePattern":"This agent requires that the \"bindTools\\(\\)\" method be implemented on the input model\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/components/nodes/agents/ConversationalRetrievalToolAgent/ConversationalRetrievalToolAgent.ts","lineNumber":297,"sourceCode":"                const lastMessage = prompt.promptMessages.pop() as HumanMessagePromptTemplate\n                const template = (lastMessage.prompt as PromptTemplate).template as string\n                const msg = HumanMessagePromptTemplate.fromTemplate([\n                    ...messageContent,\n                    {\n                        text: template\n                    }\n                ])\n                msg.inputVariables = lastMessage.inputVariables\n                prompt.promptMessages.push(msg)\n            }\n\n            // Add the `agent_scratchpad` MessagePlaceHolder back\n            prompt.promptMessages.push(messagePlaceholder)\n        }\n    }\n\n    if (model.bindTools === undefined) {\n        throw new Error(`This agent requires that the \"bindTools()\" method be implemented on the input model.`)\n    }\n\n    const modelWithTools = model.bindTools(tools)\n\n    // Function to get standalone question (either rephrased or original)\n    const getStandaloneQuestion = async (input: string): Promise<string> => {\n        // If no rephrase prompt, return the original input\n        if (!rephrasePrompt) {\n            return input\n        }\n\n        // Get chat history (use empty string if none)\n        const messages = (await memory.getChatMessages(flowObj?.sessionId, true)) as BaseMessage[]\n        const iMessages = convertBaseMessagetoIMessage(messages)\n        const chatHistoryString = convertChatHistoryToText(iMessages)\n\n        // Always rephrase to normalize/expand user queries for better retrieval\n        try {","sourceCodeStart":279,"sourceCodeEnd":315,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/agents/ConversationalRetrievalToolAgent/ConversationalRetrievalToolAgent.ts#L279-L315","documentation":"ConversationalRetrievalToolAgent constructs a tool-calling agent and requires the LangChain chat model to expose `bindTools()` (the function-calling interface). If `model.bindTools === undefined` the agent cannot attach tools, so it throws before building the runnable. This is a model-capability/version mismatch, not a network error.","triggerScenarios":"The selected model class does not implement function/tool calling (e.g. older LangChain chat models, some local/Ollama wrappers, base ChatModel without tool support), or the installed @langchain/core version predates bindTools.","commonSituations":"Switched from an OpenAI tool-calling model to a model that lacks bindTools; downgraded LangChain; using a custom model wrapper that didn't subclass the tool-capable base; pointing at a legacy chat-model component.","solutions":["Select a chat model known to support tool calling (OpenAI gpt-4/gpt-3.5-turbo, Anthropic Claude 3, etc.).","Upgrade @langchain/core and the provider package to versions that ship bindTools.","If using a custom model class, implement `bindTools(tools)` on it.","Verify the model component wired into the agent is the tool-capable variant (not the plain ChatOpenAI legacy node)."],"exampleFix":"// before\n    if (model.bindTools === undefined) {\n        throw new Error(`This agent requires that the \"bindTools()\" method be implemented on the input model.`)\n    }\n// after\n    if (typeof model.bindTools !== 'function') {\n        throw new Error(`Model \"${model.constructor?.name ?? 'unknown'}\" does not implement bindTools(). Use a tool-calling-capable chat model (e.g. ChatOpenAI gpt-4, ChatAnthropic).`)\n    }","handlingStrategy":"type-guard","validationCode":"if (typeof (model as any).bindTools !== 'function') {\n  throw new Error('Selected model does not support tool calling; pick a tool-capable chat model.')\n}","typeGuard":"const hasBindTools = (m: unknown): m is { bindTools: (tools: unknown[]) => unknown } =>\n  typeof (m as any)?.bindTools === 'function'","tryCatchPattern":"try {\n  const agent = await buildConversationalRetrievalToolAgent(model, tools, ...)\n} catch (e) {\n  if ((e as Error).message.includes('bindTools()')) swapToToolCapableModel()\n  throw e\n}","preventionTips":["Whitelist only tool-capable models in the agent's model picker.","Pin @langchain/core and provider versions that ship bindTools.","For custom models, implement and unit-test bindTools before use.","Gate agent creation on a capability check, not on failure."],"tags":["agent","langchain","tool-calling","bindtools","model-capability","version-mismatch"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}