[GH-ISSUE #284] Is subagent streaming supported in the JS version of deepagents? If so, what's the correct configuration? The Python docs show this is possible, but I can't find equivalent functionality in the JS implementation. #243

Closed
opened 2026-06-05 17:21:14 -04:00 by yindo · 4 comments
Owner

Originally created by @lkm1developer on GitHub (Mar 7, 2026).
Original GitHub issue: https://github.com/langchain-ai/deepagentsjs/issues/284

Checked other resources

  • This is a bug, not a usage question.
  • I added a clear and descriptive title.
  • I searched existing issues and didn't find this.
  • I can reproduce this with the latest released version.
  • I included a minimal reproducible example and steps to reproduce.

Area (Required)

  • deepagents (SDK)
  • cli

Related Issues / PRs

No response

Reproduction Steps / Example Code (Python)

// StreamProvider.jsx
const streamValue = useStream({
  apiUrl: "http://localhost:5007",
  apiKey: token,
  assistantId: "widget-chat",
  threadId: threadId,
  filterSubagentMessages: true,
  streamSubgraphs: true,
});

// Submit options
stream.submit(
  { messages: [...] },
  { streamSubgraphs: true, streamMode: ["values", "messages"] }
);
backend
import { createDeepAgent } from "deepagents";

const agent = createDeepAgent({
  model: llm,
  tools: [...],
  subagents: [
    {
      name: "CEO Finder",
      description: "Find CEO information",
      systemPrompt: "...",
      tools: [...],
    },
    // ...more subagents
  ],
});

Error Message and Stack Trace (if applicable)


Description

When using deepagents (JS/TypeScript) with @langchain/langgraph-sdk's useStream hook, the stream.subagents Map and stream.activeSubagents array are always empty, even though the task tool is successfully spawning and running subagents.

Environment

  • deepagents: 1.8.1
  • @langchain/langgraph-sdk: 1.6.5
  • @langchain/langgraph-api: 1.1.14
  • Node.js: 20.x
  • Platform: Windows

Frontend Configuration

// StreamProvider.jsx
const streamValue = useStream({
  apiUrl: "http://localhost:5007",
  apiKey: token,
  assistantId: "widget-chat",
  threadId: threadId,
  filterSubagentMessages: true,
  streamSubgraphs: true,
});

// Submit options
stream.submit(
  { messages: [...] },
  { streamSubgraphs: true, streamMode: ["values", "messages"] }
);
import { createDeepAgent } from "deepagents";

const agent = createDeepAgent({
  model: llm,
  tools: [...],
  subagents: [
    {
      name: "CEO Finder",
      description: "Find CEO information",
      systemPrompt: "...",
      tools: [...],
    },
    // ...more subagents
  ],
});
Expected Behavior
When a subagent is spawned via the task tool:
stream.subagents should contain the subagent's streaming data
stream.activeSubagents should list currently running subagents
Subagent internal tool calls should be visible
Actual Behavior
stream.subagents: Map(0) (always empty)
stream.activeSubagents: [] (always empty)
stream.toolProgress shows task tool calls correctly
Subagents execute successfully, but no streaming events are emitted
Root Cause Investigation
I traced the issue to createTaskTool in node_modules/deepagents/dist/index.js (line ~1428):

const result = await subagent.invoke(subagentState, config);
The subagent is invoked with invoke() which doesn't emit streaming events. The Python documentation mentions using stream() with subgraphs=True to get subagent events:

for namespace, chunk in agent.stream(
    {"messages": [...]},
    stream_mode="updates",
    subgraphs=True,
):
    if namespace:  # Subagent event
        print(f"[subagent: {namespace}]")
Attempted Fix
I tried patching invoke() to stream() with subgraphs: true:

let result = null;
const streamConfig = { ...config, subgraphs: true };
for await (const chunk of await subagent.stream(subagentState, streamConfig)) {
  result = chunk;
}
This didn't work because the streaming events are consumed inside the tool closure and not propagated to the parent graph's stream.

### Environment / System Info

_No response_
Originally created by @lkm1developer on GitHub (Mar 7, 2026). Original GitHub issue: https://github.com/langchain-ai/deepagentsjs/issues/284 ### Checked other resources - [x] This is a bug, not a usage question. - [x] I added a clear and descriptive title. - [x] I searched existing issues and didn't find this. - [x] I can reproduce this with the latest released version. - [x] I included a minimal reproducible example and steps to reproduce. ### Area (Required) - [x] deepagents (SDK) - [ ] cli ### Related Issues / PRs _No response_ ### Reproduction Steps / Example Code (Python) ```python // StreamProvider.jsx const streamValue = useStream({ apiUrl: "http://localhost:5007", apiKey: token, assistantId: "widget-chat", threadId: threadId, filterSubagentMessages: true, streamSubgraphs: true, }); // Submit options stream.submit( { messages: [...] }, { streamSubgraphs: true, streamMode: ["values", "messages"] } ); backend import { createDeepAgent } from "deepagents"; const agent = createDeepAgent({ model: llm, tools: [...], subagents: [ { name: "CEO Finder", description: "Find CEO information", systemPrompt: "...", tools: [...], }, // ...more subagents ], }); ``` ### Error Message and Stack Trace (if applicable) ```shell ``` ### Description When using `deepagents` (JS/TypeScript) with `@langchain/langgraph-sdk`'s `useStream` hook, the `stream.subagents` Map and `stream.activeSubagents` array are always empty, even though the `task` tool is successfully spawning and running subagents. ## Environment - `deepagents`: 1.8.1 - `@langchain/langgraph-sdk`: 1.6.5 - `@langchain/langgraph-api`: 1.1.14 - Node.js: 20.x - Platform: Windows ## Frontend Configuration ```javascript // StreamProvider.jsx const streamValue = useStream({ apiUrl: "http://localhost:5007", apiKey: token, assistantId: "widget-chat", threadId: threadId, filterSubagentMessages: true, streamSubgraphs: true, }); // Submit options stream.submit( { messages: [...] }, { streamSubgraphs: true, streamMode: ["values", "messages"] } ); import { createDeepAgent } from "deepagents"; const agent = createDeepAgent({ model: llm, tools: [...], subagents: [ { name: "CEO Finder", description: "Find CEO information", systemPrompt: "...", tools: [...], }, // ...more subagents ], }); Expected Behavior When a subagent is spawned via the task tool: stream.subagents should contain the subagent's streaming data stream.activeSubagents should list currently running subagents Subagent internal tool calls should be visible Actual Behavior stream.subagents: Map(0) (always empty) stream.activeSubagents: [] (always empty) stream.toolProgress shows task tool calls correctly Subagents execute successfully, but no streaming events are emitted Root Cause Investigation I traced the issue to createTaskTool in node_modules/deepagents/dist/index.js (line ~1428): const result = await subagent.invoke(subagentState, config); The subagent is invoked with invoke() which doesn't emit streaming events. The Python documentation mentions using stream() with subgraphs=True to get subagent events: for namespace, chunk in agent.stream( {"messages": [...]}, stream_mode="updates", subgraphs=True, ): if namespace: # Subagent event print(f"[subagent: {namespace}]") Attempted Fix I tried patching invoke() to stream() with subgraphs: true: let result = null; const streamConfig = { ...config, subgraphs: true }; for await (const chunk of await subagent.stream(subagentState, streamConfig)) { result = chunk; } This didn't work because the streaming events are consumed inside the tool closure and not propagated to the parent graph's stream. ### Environment / System Info _No response_
yindo added the bug label 2026-06-05 17:21:14 -04:00
yindo closed this issue 2026-06-05 17:21:14 -04:00
Author
Owner

@eyurtsev commented on GitHub (Mar 7, 2026):

@christian-bromann streaming questions -- i think @lkm1developer is looking for equivalent of: https://docs.langchain.com/oss/python/langchain/streaming/overview#streaming-from-sub-agents

<!-- gh-comment-id:4016680909 --> @eyurtsev commented on GitHub (Mar 7, 2026): @christian-bromann streaming questions -- i think @lkm1developer is looking for equivalent of: https://docs.langchain.com/oss/python/langchain/streaming/overview#streaming-from-sub-agents
Author
Owner

@christian-bromann commented on GitHub (Mar 7, 2026):

Hey @lkm1developer 👋 we are currently working on extensive docs for this but happy to share early developments we plan to roll out next week.

You can find an end to end example here: https://langchain-5e9cc07a-preview-cbfron-1772840960-d2a2597.mintlify.app/oss/python/deepagents/frontend/subagent-streaming

The @langchain/react package is not published yet (at least the current version), so use these versions:

  "dependencies": {
    "@langchain/angular": "https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/angular@746d746",
    "@langchain/react": "https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/react@746d746",
    "@langchain/svelte": "https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/svelte@746d746",
    "@langchain/vue": "https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/vue@746d746"
  },

Again, we are rolling this out sometime next week. Let me know if you have any questions.

<!-- gh-comment-id:4017312428 --> @christian-bromann commented on GitHub (Mar 7, 2026): Hey @lkm1developer 👋 we are currently working on extensive docs for this but happy to share early developments we plan to roll out next week. You can find an end to end example here: https://langchain-5e9cc07a-preview-cbfron-1772840960-d2a2597.mintlify.app/oss/python/deepagents/frontend/subagent-streaming The `@langchain/react` package is not published yet (at least the current version), so use these versions: ```json "dependencies": { "@langchain/angular": "https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/angular@746d746", "@langchain/react": "https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/react@746d746", "@langchain/svelte": "https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/svelte@746d746", "@langchain/vue": "https://pkg.pr.new/langchain-ai/langgraphjs/@langchain/vue@746d746" }, ``` Again, we are rolling this out sometime next week. Let me know if you have any questions.
Author
Owner

@lkm1developer commented on GitHub (Mar 17, 2026):

@christian-bromann , any updates on roll out

<!-- gh-comment-id:4074129548 --> @lkm1developer commented on GitHub (Mar 17, 2026): @christian-bromann , any updates on roll out
Author
Owner

@christian-bromann commented on GitHub (May 18, 2026):

Thanks for checking in. Yes, this has moved forward: the new v3 streaming surface now has a dedicated subagent projection for Deep Agents.

The important change is to use the new event streaming API rather than the legacy @langchain/langgraph-sdk useStream path with streamMode / streamSubgraphs. In-process, you can call agent.streamEvents(..., { version: "v3" }) and iterate run.subagents. Each subagent stream exposes:

  • name
  • taskInput
  • messages
  • toolCalls
  • output

That gives you the same product behavior you were looking for: root-agent messages can stay in the main chat, while subagent messages/tool calls/status can be rendered in a separate panel or filtered out of the user-facing transcript.

The cookbook has runnable TypeScript examples here: streaming subagents examples

The two most relevant files are:

  • in-process.ts for agent.streamEvents(..., { version: "v3" }) and run.subagents
  • remote.ts for the remote/thread equivalent

So the rollout update is: subagent streaming is supported in the new v3 primitives. If your current app is still on the older useStream API from @langchain/langgraph-sdk, the migration path is to move to the new framework streaming packages/projections once available in your setup. See the v1 migration guide for the React-side migration details. The older streamMode: ["values", "messages"] shape does not expose the same subagents projection.

Let me know if this addresses your issue and if there is anything I can help with further.

<!-- gh-comment-id:4477574550 --> @christian-bromann commented on GitHub (May 18, 2026): Thanks for checking in. Yes, this has moved forward: the new v3 streaming surface now has a dedicated subagent projection for Deep Agents. The important change is to use the new event streaming API rather than the legacy `@langchain/langgraph-sdk` `useStream` path with `streamMode` / `streamSubgraphs`. In-process, you can call `agent.streamEvents(..., { version: "v3" })` and iterate `run.subagents`. Each subagent stream exposes: - `name` - `taskInput` - `messages` - `toolCalls` - `output` That gives you the same product behavior you were looking for: root-agent messages can stay in the main chat, while subagent messages/tool calls/status can be rendered in a separate panel or filtered out of the user-facing transcript. The cookbook has runnable TypeScript examples here: [streaming subagents examples](https://github.com/langchain-ai/streaming-cookbook/tree/main/typescript/streaming/src/subagents) The two most relevant files are: - `in-process.ts` for `agent.streamEvents(..., { version: "v3" })` and `run.subagents` - `remote.ts` for the remote/thread equivalent So the rollout update is: subagent streaming is supported in the new v3 primitives. If your current app is still on the older `useStream` API from `@langchain/langgraph-sdk`, the migration path is to move to the new framework streaming packages/projections once available in your setup. See the [v1 migration guide](https://github.com/langchain-ai/langgraphjs/blob/main/libs/sdk-react/docs/v1-migration.md) for the React-side migration details. The older `streamMode: ["values", "messages"]` shape does not expose the same `subagents` projection. Let me know if this addresses your issue and if there is anything I can help with further.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/deepagentsjs#243