AzureChatOpenAI not support by createReactAgent #37

Closed
opened 2026-02-15 17:05:59 -05:00 by yindo · 8 comments
Owner

Originally created by @wulucxy on GitHub (Jun 19, 2024).

from this tutorial:https://github.com/langchain-ai/langgraphjs/blob/7d9cc1427623931d66938dd0eb41fd0f668ee61b/examples/quickstart.ipynb#L83

I change ChatOpenAI to AzureChatOpenAI GPT3.5 version,then createReactAgent throw error:

 throw new Error(`llm ${llm} must define bindTools method.`);
              ^
Error: llm [object Object] must define bindTools method.
    at createReactAgent (/Users/qingtong/work/learn/langchain2/node_modules/.pnpm/@langchain+langgraph@0.0.23_langchain@0.2.5/node_modules/@langchain/langgraph/dist/prebuilt/react_agent_executor.cjs:36:15)
    at Object.<anonymous> (/Users/qingtong/work/learn/langchain2/src/langgraph.ts:26:31)

why did this happen?

Originally created by @wulucxy on GitHub (Jun 19, 2024). from this tutorial:https://github.com/langchain-ai/langgraphjs/blob/7d9cc1427623931d66938dd0eb41fd0f668ee61b/examples/quickstart.ipynb#L83 I change `ChatOpenAI` to `AzureChatOpenAI` GPT3.5 version,then `createReactAgent` throw error: ``` throw new Error(`llm ${llm} must define bindTools method.`); ^ Error: llm [object Object] must define bindTools method. at createReactAgent (/Users/qingtong/work/learn/langchain2/node_modules/.pnpm/@langchain+langgraph@0.0.23_langchain@0.2.5/node_modules/@langchain/langgraph/dist/prebuilt/react_agent_executor.cjs:36:15) at Object.<anonymous> (/Users/qingtong/work/learn/langchain2/src/langgraph.ts:26:31) ``` why did this happen?
yindo closed this issue 2026-02-15 17:05:59 -05:00
Author
Owner

@wulucxy commented on GitHub (Jun 20, 2024):

actually we can use

 llm.bind({
   tools: ...
 })

what's the difference between bindTools and bind?

@wulucxy commented on GitHub (Jun 20, 2024): actually we can use ``` llm.bind({ tools: ... }) ``` what's the difference between `bindTools` and `bind`?
Author
Owner

@jacoblee93 commented on GitHub (Jun 26, 2024):

Which package are you importing from?

@jacoblee93 commented on GitHub (Jun 26, 2024): Which package are you importing from?
Author
Owner

@wulucxy commented on GitHub (Jun 28, 2024):

@jacoblee93

import { AzureChatOpenAI } from '@langchain/azure-openai';
import { createReactAgent } from '@langchain/langgraph/prebuilt';

export const llm = new AzureChatOpenAI({
  temperature: 0,
});

const tools = [new TavilySearchResults({ maxResults: 1 })];


const agent = await createReactAgent({
    llm,
    tools,
  });

  const result = await agent.invoke({ messages: 'what is "Node" in Langgraph?' });

RUN this code show me the error bellow:

Error: llm [object Object] must define bindTools method.
    at createReactAgent (/Users/qingtong/work/zhejiang/reactor/workspace/tars/tool-agent/node_modules/.pnpm/@langchain+langgraph@0.0.25_langchain@0.2.8/node_modules/@langchain/langgraph/dist/prebuilt/react_agent_executor.cjs:36:15)
    at RunnableLambda.executor [as func] (/Users/qingtong/work/zhejiang/reactor/workspace/tars/tool-agent/src/plan-resolve/tools/executor.ts:72:39)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async /Users/qingtong/work/zhejiang/reactor/workspace/tars/tool-agent/node_modules/.pnpm/@langchain+core@0.2.10_langchain@0.2.8/node_modules/@langchain/core/dist/runnables/base.cjs:1498:34
@wulucxy commented on GitHub (Jun 28, 2024): @jacoblee93 ``` import { AzureChatOpenAI } from '@langchain/azure-openai'; import { createReactAgent } from '@langchain/langgraph/prebuilt'; export const llm = new AzureChatOpenAI({ temperature: 0, }); const tools = [new TavilySearchResults({ maxResults: 1 })]; const agent = await createReactAgent({ llm, tools, }); const result = await agent.invoke({ messages: 'what is "Node" in Langgraph?' }); ``` RUN this code show me the error bellow: ``` Error: llm [object Object] must define bindTools method. at createReactAgent (/Users/qingtong/work/zhejiang/reactor/workspace/tars/tool-agent/node_modules/.pnpm/@langchain+langgraph@0.0.25_langchain@0.2.8/node_modules/@langchain/langgraph/dist/prebuilt/react_agent_executor.cjs:36:15) at RunnableLambda.executor [as func] (/Users/qingtong/work/zhejiang/reactor/workspace/tars/tool-agent/src/plan-resolve/tools/executor.ts:72:39) at processTicksAndRejections (node:internal/process/task_queues:95:5) at async /Users/qingtong/work/zhejiang/reactor/workspace/tars/tool-agent/node_modules/.pnpm/@langchain+core@0.2.10_langchain@0.2.8/node_modules/@langchain/core/dist/runnables/base.cjs:1498:34 ```
Author
Owner

@jacoblee93 commented on GitHub (Jun 28, 2024):

Ah, the Azure team has deprecated that package:

https://www.npmjs.com/package/@langchain/azure-openai

Can you install and use the normal OpenAI package?

https://js.langchain.com/v0.2/docs/integrations/chat/azure

@jacoblee93 commented on GitHub (Jun 28, 2024): Ah, the Azure team has deprecated that package: https://www.npmjs.com/package/@langchain/azure-openai Can you install and use the normal OpenAI package? https://js.langchain.com/v0.2/docs/integrations/chat/azure
Author
Owner

@wulucxy commented on GitHub (Jun 28, 2024):

migrate from azureOpenAI is very annoying...

before

AZURE_OPENAI_API_KEY = "xxx"
OEPNAI_API_TYPE = "azure"
AZURE_OPENAI_API_VERSION = "2023-11-06-preview"
AZURE_OPENAI_BASE_PATH = "https://xxx.openai.azure.com/"
OPENAI_API_MODEL = "gpt-35-turbo"
AZURE_OPENAI_API_DEPLOYMENT_NAME = "xxx"

export const llm = new AzureChatOpenAI({
  azureOpenAIApiKey: getEnv('AZURE_OPENAI_API_KEY'),
  azureOpenAIApiDeploymentName: getEnv('AZURE_OPENAI_API_DEPLOYMENT_NAME'), 
  azureOpenAIApiVersion: getEnv('AZURE_OPENAI_API_VERSION'),
  azureOpenAIEndpoint: getEnv('AZURE_OPENAI_BASE_PATH'),
  temperature: 0,
});

everything works~

but if I migrate to @langchain/openai@0.2.1, things become messy.

import { AzureChatOpenAI } from '@langchain/openai';

export const llm = new AzureChatOpenAI({
  azureOpenAIApiKey: getEnv('AZURE_OPENAI_API_KEY'),
  azureOpenAIApiDeploymentName: getEnv('AZURE_OPENAI_API_DEPLOYMENT_NAME'), 
  azureOpenAIApiVersion: getEnv('AZURE_OPENAI_API_VERSION'),
  azureOpenAIApiInstanceName: getEnv('AZURE_OPENAI_API_INSTANCE_NAME'),
  temperature: 0,
});

the error shows:

error: { code: '404', message: 'Resource not found' }

I don't know why

@wulucxy commented on GitHub (Jun 28, 2024): migrate from `azureOpenAI` is very annoying... ## before ``` AZURE_OPENAI_API_KEY = "xxx" OEPNAI_API_TYPE = "azure" AZURE_OPENAI_API_VERSION = "2023-11-06-preview" AZURE_OPENAI_BASE_PATH = "https://xxx.openai.azure.com/" OPENAI_API_MODEL = "gpt-35-turbo" AZURE_OPENAI_API_DEPLOYMENT_NAME = "xxx" export const llm = new AzureChatOpenAI({ azureOpenAIApiKey: getEnv('AZURE_OPENAI_API_KEY'), azureOpenAIApiDeploymentName: getEnv('AZURE_OPENAI_API_DEPLOYMENT_NAME'), azureOpenAIApiVersion: getEnv('AZURE_OPENAI_API_VERSION'), azureOpenAIEndpoint: getEnv('AZURE_OPENAI_BASE_PATH'), temperature: 0, }); ``` everything works~ but if I migrate to `@langchain/openai@0.2.1`, things become messy. ``` import { AzureChatOpenAI } from '@langchain/openai'; export const llm = new AzureChatOpenAI({ azureOpenAIApiKey: getEnv('AZURE_OPENAI_API_KEY'), azureOpenAIApiDeploymentName: getEnv('AZURE_OPENAI_API_DEPLOYMENT_NAME'), azureOpenAIApiVersion: getEnv('AZURE_OPENAI_API_VERSION'), azureOpenAIApiInstanceName: getEnv('AZURE_OPENAI_API_INSTANCE_NAME'), temperature: 0, }); ``` the error shows: ``` error: { code: '404', message: 'Resource not found' } ``` I don't know why
Author
Owner

@jacoblee93 commented on GitHub (Jun 28, 2024):

Could be related to this?

https://github.com/langchain-ai/langchainjs/issues/5663#issuecomment-2148775572

@jacoblee93 commented on GitHub (Jun 28, 2024): Could be related to this? https://github.com/langchain-ai/langchainjs/issues/5663#issuecomment-2148775572
Author
Owner

@Ayush170-Future commented on GitHub (May 4, 2025):

I'm experiencing a similar issue. When I run CreatReactAgent with ChatOpenAI, it works fine. However, when I run it with AzureChatOpenAI, it fails silently, and I can't determine the cause—there doesn't seem to be any execution happening inside the debugger either.

LangGraph has so many silent failures.

@Ayush170-Future commented on GitHub (May 4, 2025): I'm experiencing a similar issue. When I run CreatReactAgent with ChatOpenAI, it works fine. However, when I run it with AzureChatOpenAI, it fails silently, and I can't determine the cause—there doesn't seem to be any execution happening inside the debugger either. LangGraph has so many silent failures.
Author
Owner

@Ayush170-Future commented on GitHub (May 4, 2025):

@jacoblee93 ^^

@Ayush170-Future commented on GitHub (May 4, 2025): @jacoblee93 ^^
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#37