import { ... } from "@langchain/langgraph-sdk/react";Calculates the depth of a subagent based on its namespace. Counts the number of "tools:" segments in the namespace.
Extracts the parent tool call ID from a namespace.
For nested subagents, the namespace looks like: ["tools:parent_id", "tools:child_id", ...]
Extracts the tool call ID from a namespace path.
Namespaces follow the pattern: ["tools:call_abc123", "model_request:xyz", ...] This function extracts "call_abc123" from the first "tools:" segment.
Checks if a namespace indicates a subagent/subgraph message.
Subagent namespaces contain a "tools:" segment indicating they originate from a tool call that spawned a subgraph.
A React hook that provides seamless integration with LangGraph streaming capabilities.
The useStream hook handles all the complexities of streaming, state management, and branching logic,
letting you focus on building great chat experiences. It provides automatic state management for
messages, interrupts, loading states, subagent streams, and errors.
When using createAgent from @langchain/langgraph, you can pass typeof agent as the
type parameter to automatically infer tool call types:
Transport used to stream the thread.
Only applicable for custom endpoints using toLangGraphEventStream or toLangGraphEventStreamResponse.
Manages subagent execution state.
Tracks subagents from the moment they are invoked (AI message with tool calls) through streaming to completion (tool message result).
Infer the state type from an agent, graph, or direct state type.
Detection order:
~agentTypes) → InferAgentState~RunOutput) → Extract RunOutput~OutputType) → Extract OutputType