Browser compatibility issue: createAgent fails due to node:async_hooks dependency

Problem

I need to build a browser-based AI agent with frontend tool registration (opening modals, filling forms, DOM manipulation). However, createAgent from langchain fails in browser builds due to Node.js dependencies (node:async_hooks).

Current Workaround

Working example: GitHub - HEKEH/langchain-browser-template: LangChain.js browser agent template with frontend tool registration and Next.js API proxy

The next.config.js requires complex webpack configuration (custom plugins, stubs, polyfills) just to make LangChain.js work in browsers - this shouldn’t be necessary.

Request

Provide better browser compatibility:

  • Browser-specific exports that avoid Node.js dependencies
  • Conditional loading of Node.js modules
  • Or clearer documentation on required workarounds

Browser-based agents with frontend tool registration is a common use case that should work out-of-the-box.

hi @HEKEH

have you seen that issue and its answer Issue: error occurred when building langgraph as the browser target using webpack · Issue #869 · langchain-ai/langgraphjs · GitHub ?

But I need to use langchain, not langgraph. Does langchainjs have similar web version?