[GH-ISSUE #543] deepAgents do not have browser support #271

Closed
opened 2026-06-05 17:21:23 -04:00 by yindo · 1 comment
Owner

Originally created by @meet13803 on GitHub (May 18, 2026).
Original GitHub issue: https://github.com/langchain-ai/deepagentsjs/issues/543

Checked other resources

  • This is a bug, not a usage question.
  • I added a very descriptive title to this issue.
  • I searched the Deep Agents JS documentation with the integrated search.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in deepagents rather than my code.
  • The bug is not resolved by updating to the latest stable version of deepagents.

Example Code

import {
  createDeepAgent,
  todoListMiddleware,
  createFilesystemMiddleware,
  createSubAgentMiddleware,
  StateBackend,
} from "deepagents";
import { ChatOpenAI } from "@langchain/openai";

const agent = createDeepAgent({
  model: new ChatOpenAI({ model: "gpt-5", temperature: 0 }),
  tools: [myTool],
  systemPrompt: "You are a research assistant.",
  middleware: [
    todoListMiddleware({
      systemPrompt: "Use write_todos to track progress.",
    }),
  ],
});

const result = await agent.invoke({
  messages: [{ role: "user", content: "Research LangGraph and write a summary" }],
});

Error Message and Stack Trace (if applicable)

Primary (build): Could not resolve "path" and Could not resolve "node:fs/promises" from deepagents/dist/index.js during Vite browser build.
Secondary (runtime): require is not defined / Can't resolve 'fs' when deepagents backends are touched in browser bundle.

Description

We are building a browser-based AI assistant and wanted to use deepagents for its deep agent architecture — specifically createDeepAgent() with todoListMiddleware for planning, and createSubAgentMiddleware for context-isolated subagent delegation.

The deepagents npm package does not provide a browser entry point (no "browser" field in package.json, and no "browser" condition in the "exports" map). The core createDeepAgent function and all built-in middleware transitively import Node.js built-ins (fs, path, child_process) through the FilesystemBackend and LocalShellBackend modules, even when those backends are not being used by the consumer.

Workaround: We've built our own planning and subagent orchestration on top of @langchain/langgraph/web and createAgent from langchain (which does have a browser entry point per [langchain-ai/langchainjs#10527](https://github.com/langchain-ai/langchainjs/pull/10527)). However, we'd prefer to use the official deep agent APIs.

Suggested fix:

Separate the Node.js-only backends (FilesystemBackend, LocalShellBackend, sandbox code) from the environment-agnostic core (createDeepAgent, todoListMiddleware, createSubAgentMiddleware). Then either:

  1. Add a "browser" condition to the package's "exports" map that excludes Node-only modules:
{
  "exports": {
    ".": {
      "browser": "./dist/browser.js",
      "import": "./dist/index.js",
      "require": "./dist/index.cjs"
    }
  }
}
  1. Or provide a dedicated browser-safe subpath export:
import { createDeepAgent, todoListMiddleware, createSubAgentMiddleware } from "deepagents/web";

This mirrors the pattern already established by @langchain/langgraph/web.

System Info

Platform: macOS
Node version: v24.13.1
pnpm version: 10.32.1

deepagents: 1.8.3
@langchain/core: 1.1.34
@langchain/langgraph: 1.2.5
@langchain/openai: 1.3.0
Originally created by @meet13803 on GitHub (May 18, 2026). Original GitHub issue: https://github.com/langchain-ai/deepagentsjs/issues/543 ### Checked other resources - [x] This is a bug, not a usage question. - [x] I added a very descriptive title to this issue. - [x] I searched the Deep Agents JS documentation with the integrated search. - [x] I used the GitHub search to find a similar question and didn't find it. - [x] I am sure that this is a bug in `deepagents` rather than my code. - [x] The bug is not resolved by updating to the latest stable version of `deepagents`. ### Example Code ```ts import { createDeepAgent, todoListMiddleware, createFilesystemMiddleware, createSubAgentMiddleware, StateBackend, } from "deepagents"; import { ChatOpenAI } from "@langchain/openai"; const agent = createDeepAgent({ model: new ChatOpenAI({ model: "gpt-5", temperature: 0 }), tools: [myTool], systemPrompt: "You are a research assistant.", middleware: [ todoListMiddleware({ systemPrompt: "Use write_todos to track progress.", }), ], }); const result = await agent.invoke({ messages: [{ role: "user", content: "Research LangGraph and write a summary" }], }); ``` ### Error Message and Stack Trace (if applicable) Primary (build): Could not resolve "path" and Could not resolve "node:fs/promises" from deepagents/dist/index.js during Vite browser build. Secondary (runtime): require is not defined / Can't resolve 'fs' when deepagents backends are touched in browser bundle. ### Description We are building a browser-based AI assistant and wanted to use `deepagents` for its deep agent architecture — specifically `createDeepAgent()` with `todoListMiddleware` for planning, and `createSubAgentMiddleware` for context-isolated subagent delegation. The `deepagents` npm package does not provide a browser entry point (no `"browser"` field in `package.json`, and no `"browser"` condition in the `"exports"` map). The core `createDeepAgent` function and all built-in middleware transitively import Node.js built-ins (`fs`, `path`, `child_process`) through the `FilesystemBackend` and `LocalShellBackend` modules, even when those backends are not being used by the consumer. **Workaround:** We've built our own planning and subagent orchestration on top of `@langchain/langgraph/web` and `createAgent` from `langchain` (which does have a browser entry point per [[langchain-ai/langchainjs#10527](https://github.com/langchain-ai/langchainjs/pull/10527)](https://github.com/langchain-ai/langchainjs/pull/10527)). However, we'd prefer to use the official deep agent APIs. **Suggested fix:** Separate the Node.js-only backends (`FilesystemBackend`, `LocalShellBackend`, sandbox code) from the environment-agnostic core (`createDeepAgent`, `todoListMiddleware`, `createSubAgentMiddleware`). Then either: 1. Add a `"browser"` condition to the package's `"exports"` map that excludes Node-only modules: ```json { "exports": { ".": { "browser": "./dist/browser.js", "import": "./dist/index.js", "require": "./dist/index.cjs" } } } ``` 2. Or provide a dedicated browser-safe subpath export: ```ts import { createDeepAgent, todoListMiddleware, createSubAgentMiddleware } from "deepagents/web"; ``` This mirrors the pattern already established by `@langchain/langgraph/web`. ### System Info Platform: macOS Node version: v24.13.1 pnpm version: 10.32.1 ``` deepagents: 1.8.3 @langchain/core: 1.1.34 @langchain/langgraph: 1.2.5 @langchain/openai: 1.3.0 ```
yindo closed this issue 2026-06-05 17:21:23 -04:00
Author
Owner

@hntrl commented on GitHub (Jun 2, 2026):

Thanks for the report!

This is the same root packaging issue tracked in #292 (Node-only modules being pulled into browser builds). We’ve now opened a fix in PR #574

Our guidance for browser targets going forward is going to be importing in deepagents/browser when this lands. This removes the exports from the barrel file that are dependent explicitly on

<!-- gh-comment-id:4605051250 --> @hntrl commented on GitHub (Jun 2, 2026): Thanks for the report! This is the same root packaging issue tracked in #292 (Node-only modules being pulled into browser builds). We’ve now opened a fix in PR #574 Our guidance for browser targets going forward is going to be importing in `deepagents/browser` when this lands. This removes the exports from the barrel file that are dependent explicitly on
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#271