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.