{"record":{"id":"3877d34b95325550","repo":"FlowiseAI/Flowise","slug":"this-agent-requires-that-the-bindtools-method-3877d3","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/ToolAgent/ToolAgent.ts","lineNumber":333,"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    const runnableAgent = RunnableSequence.from([\n        {\n            [inputKey]: (i: { input: string; steps: ToolsAgentStep[] }) => i.input,\n            agent_scratchpad: (i: { input: string; steps: ToolsAgentStep[] }) => formatToOpenAIToolMessages(i.steps),\n            [memoryKey]: async (_: { input: string; steps: ToolsAgentStep[] }) => {\n                const messages = (await memory.getChatMessages(flowObj?.sessionId, true, prependMessages)) as BaseMessage[]\n                return messages ?? []\n            },\n            ...promptVariables\n        },\n        prompt,\n        modelWithTools,\n        new ToolCallingAgentOutputParser()\n    ])","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/FlowiseAI/Flowise/blob/abe4a8601a058047b350c260676826e21dd14101/packages/components/nodes/agents/ToolAgent/ToolAgent.ts#L315-L351","documentation":"ToolAgent (the non-conversational variant) builds a tool-calling agent and requires the chat model to implement `bindTools()`. If `model.bindTools === undefined` it throws before constructing the RunnableSequence. Identical precondition to error 29, just in ToolAgent.","triggerScenarios":"Selected model lacks tool-calling support, or the installed LangChain version predates the bindTools interface. Common when reusing a plain/legacy chat model node.","commonSituations":"Switched models to one without function calling; downgraded @langchain/core; custom model class without bindTools; using an older Flowise chat-model component.","solutions":["Wire a tool-calling-capable chat model (ChatOpenAI gpt-4/3.5-turbo, ChatAnthropic, etc.).","Upgrade @langchain/core and the provider package.","Implement bindTools on custom model classes.","Confirm the model component is the tool-capable variant."],"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.`)\n    }","handlingStrategy":"type-guard","validationCode":"if (typeof (model as any).bindTools !== 'function') {\n  throw new Error('ToolAgent needs a tool-calling-capable 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 buildToolAgent(model, tools, ...)\n} catch (e) {\n  if ((e as Error).message.includes('bindTools()')) swapToToolCapableModel()\n  throw e\n}","preventionTips":["Restrict the agent's model picker to tool-capable models.","Pin LangChain versions that provide bindTools.","Implement bindTools on custom model classes and test it.","Capability-check the model before constructing the agent."],"tags":["agent","tool-agent","langchain","tool-calling","bindtools","model-capability"],"backgroundTag":null,"analyzedSha":"abe4a8601a058047b350c260676826e21dd14101","analyzedAt":"2026-08-12T16:04:40.823Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}