-
Notifications
You must be signed in to change notification settings - Fork 360
Description
Description
When attempting to run the supervisor example from LangGraph documentation using a ChatOpenAI instance, the following error occurs:
Error: llm [object Object] must define bindTools method.
at getModelRunnable (/node_modules/@langchain/langgraph/src/prebuilt/react_agent_executor.ts:510:15)
at async RunnableCallable.callModel (/node_modules/@langchain/langgraph/src/prebuilt/react_agent_executor.ts:591:27) {
pregelTaskId: '51ba37fb-7cb6-5322-b038-755f006e0347'
}
Reproduction Steps
- Use the Quickstart example provided in Langgraph repository
const model = new ChatOpenAI({
model: "gpt-3.5-turbo",
});
const add = tool(async (args) => args.a + args.b, {
name: "add",
description: "Add two numbers.",
schema: z.object({
a: z.number(),
b: z.number(),
}),
});
const multiply = tool(async (args) => args.a * args.b, {
name: "multiply",
description: "Multiply two numbers.",
schema: z.object({
a: z.number(),
b: z.number(),
}),
});
const webSearch = tool(
async (args) => {
return (
"Here are the headcounts for each of the FAANG companies in 2024:\n" +
"1. **Facebook (Meta)**: 67,317 employees.\n" +
"2. **Apple**: 164,000 employees.\n" +
"3. **Amazon**: 1,551,000 employees.\n" +
"4. **Netflix**: 14,000 employees.\n" +
"5. **Google (Alphabet)**: 181,269 employees."
);
},
{
name: "web_search",
description: "Search the web for information.",
schema: z.object({
query: z.string(),
}),
}
);
const mathAgent = createReactAgent({
llm: model,
tools: [add, multiply],
name: "math_expert",
prompt: "You are a math expert. Always use one tool at a time.",
});
const researchAgent = createReactAgent({
llm: model,
tools: [webSearch],
name: "research_expert",
prompt:
"You are a world class researcher with access to web search. Do not do any math.",
});
// Create supervisor workflow
const workflow = createSupervisor({
agents: [researchAgent, mathAgent],
llm: model,
prompt:
"You are a team supervisor managing a research expert and a math expert. " +
"For current events, use research_agent. " +
"For math problems, use math_agent.",
});
// Compile and run
const app = workflow.compile();
const result = await app.invoke({
messages: [
{
role: "user",
content: "what's the combined headcount of the FAANG companies in 2024??",
},
],
});Expected Behavior
The supervisor example should work with any LLM that implements the required interface, including ChatOpenAI instances. The supervisor should be able to coordinate between the specialized agents (math and research) to answer complex questions.
Actual Behavior
The code throws an error indicating that the LLM object must define a bindTools method, which appears to be missing from the ChatOpenAI implementation. This prevents the supervisor from properly initializing and coordinating the agents.
Environment
- Node.js version: v23.11.0
- @langchain/langgraph version: 0.2.73
- @langchain/openai version: 0.5.11
- @langchain/core version: 0.3.57
- @langchain/langgraph-supervisor version: 0.0.12
Additional Context
This issue appears to be related to the integration between LangGraph's supervisor implementation and the ChatOpenAI class. The error suggests that there might be a missing interface implementation or a version mismatch between the packages. This is particularly problematic as it affects the core functionality of the supervisor pattern, which is a key feature of LangGraph.