createReactAgent with llm.withConfig() fails with LLM object must define bindTools method #295

Closed
opened 2026-02-15 18:15:35 -05:00 by yindo · 0 comments
Owner

Originally created by @dqbd on GitHub (Jul 7, 2025).

Similar issue to #1217

I'm not using createSupervisor, I have a plain const llm = new ChatOpenAI(...) instance, and if I chain it with withConfig, if I pass this llm instance to createReactAgent, I get the same error, without the withConfig, everything is fine.

I initially thought this might have been langgraph being funky, but this exception / guard clause:

if (!("bindTools" in llm) || typeof llm.bindTools !== "function") {
  throw new Error(`llm ${llm} must define bindTools method.`);
}

If I do instead use .withConfig just before the .invoke, things seem fine, but then (in my specific context) streaming broke, not sure if it was because of the feature I was using or using .withConfig in the way I was doing it

Just brain dumping my day for others maybe to pull from

Originally posted by @jackharrhy in #1217

Originally created by @dqbd on GitHub (Jul 7, 2025). Similar issue to #1217 > I'm not using createSupervisor, I have a plain `const llm = new ChatOpenAI(...)` instance, and if I chain it with `withConfig`, if I pass this `llm` instance to `createReactAgent`, I get the same error, without the `withConfig`, everything is fine. > > I initially thought this might have been langgraph being funky, but this exception / guard clause: > > ```ts > if (!("bindTools" in llm) || typeof llm.bindTools !== "function") { > throw new Error(`llm ${llm} must define bindTools method.`); > } > ``` > > If I do instead use `.withConfig` just before the `.invoke`, things seem fine, but then (in my specific context) streaming broke, not sure if it was because of the feature I was using or using `.withConfig` in the way I was doing it > > Just brain dumping my day for others maybe to pull from _Originally posted by @jackharrhy in [#1217](https://github.com/langchain-ai/langgraphjs/issues/1217#issuecomment-2957105704)_
yindo added the bug label 2026-02-15 18:15:35 -05:00
yindo closed this issue 2026-02-15 18:15:35 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#295