You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Feature Request: Add Subgraph Streaming Support to React useStream Hook
Summary
Add support for subgraph streaming in the useStream React hook from @langchain/langgraph-sdk/react to enable streaming events from both main graphs and nested subgraphs.
Current Behavior
The React useStream hook currently only streams events from the main graph. While the underlying SDK supports subgraph streaming via the streamSubgraphs parameter in the client API, this functionality is not exposed through the React hook interface.
// Current useStream hook - no subgraph streaming supportconststream=useStream({apiUrl: "http://localhost:2024",assistantId: "agent",// No way to enable subgraph streaming});// Must use underlying client for subgraph streamingconstclient=newClient({ apiUrl, apiKey });conststream=client.runs.stream(threadId,assistantId,{input: data,streamMode: ["values"],streamSubgraphs: true,// Only available at client level});
Desired Behavior
Enable subgraph streaming directly through the useStream hook configuration:
conststream=useStream({apiUrl: "http://localhost:2024",assistantId: "agent",subgraphs: true,// Enable subgraph streaming// ORstreamSubgraphs: true,// Alternative naming});// And/or support in submit optionsstream.submit(data,{streamMode: ["values"],streamSubgraphs: true,});
Use Case
When working with complex multi-agent systems that use nested subgraphs, developers need visibility into streaming events from all graph levels. This is particularly important for:
Multi-agent workflows where agents delegate tasks to specialized subgraphs
Hierarchical decision making with supervisor and worker agent patterns
Real-time debugging and monitoring of complex graph executions
UI components that need to display progress from nested graph operations
Current Workaround
Developers must abandon the convenient React hook and implement custom streaming logic using the underlying client API, which loses the benefits of:
Automatic state management
Built-in error handling
React lifecycle integration
Type safety from the hook interface
Technical Implementation Suggestions
Option 1: Add to UseStreamOptions interface
exportinterfaceUseStreamOptions<StateType,Bag>{// ... existing options/** * Enable streaming from subgraphs. * When true, events will include namespaced events from nested subgraphs. * @default false */subgraphs?: boolean;}
Option 2: Add to SubmitOptions interface
interfaceSubmitOptions<StateType,ConfigurableType>{// ... existing options/** * Enable streaming from subgraphs for this submission. * @default false */streamSubgraphs?: boolean;}
Option 3: Support both approaches
Allow configuration at both the hook level (default behavior) and submit level (per-request override).
Event Handling
When subgraph streaming is enabled, events should follow the existing pattern with namespaced event names:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Feature Request: Add Subgraph Streaming Support to React useStream Hook
Summary
Add support for subgraph streaming in the
useStream
React hook from@langchain/langgraph-sdk/react
to enable streaming events from both main graphs and nested subgraphs.Current Behavior
The React
useStream
hook currently only streams events from the main graph. While the underlying SDK supports subgraph streaming via thestreamSubgraphs
parameter in the client API, this functionality is not exposed through the React hook interface.Desired Behavior
Enable subgraph streaming directly through the
useStream
hook configuration:Use Case
When working with complex multi-agent systems that use nested subgraphs, developers need visibility into streaming events from all graph levels. This is particularly important for:
Current Workaround
Developers must abandon the convenient React hook and implement custom streaming logic using the underlying client API, which loses the benefits of:
Technical Implementation Suggestions
Option 1: Add to UseStreamOptions interface
Option 2: Add to SubmitOptions interface
Option 3: Support both approaches
Allow configuration at both the hook level (default behavior) and submit level (per-request override).
Event Handling
When subgraph streaming is enabled, events should follow the existing pattern with namespaced event names:
Related Documentation
Environment
@langchain/langgraph-sdk
Additional Context
The underlying infrastructure already supports subgraph streaming as evidenced by:
TypedAsyncGenerator<TStreamMode, TSubgraphs>
type parameterSubgraphValuesStreamEvent
,SubgraphUpdatesStreamEvent
typesAsSubgraph<TEvent>
event transformation utilitiesstreamSubgraphs
parameter supportThis feature request is to expose this existing functionality through the React hook interface for better developer experience and consistency.
Acceptance Criteria
useStream
hook accepts asubgraphs
orstreamSubgraphs
boolean optionBeta Was this translation helpful? Give feedback.
All reactions