langchain.js
    Preparing search index...

    Interface BaseStream<StateType, ToolCall, Bag>

    Base stream interface shared by all stream types.

    Contains core properties for state management, messaging, and stream control that are common to CompiledStateGraph, ReactAgent, and DeepAgent streams.

    This interface provides the foundation that all stream types build upon:

    • State management (values, isLoading, error)
    • Message handling (messages)
    • Interrupt handling (interrupt)
    • Stream lifecycle (submit, stop)
    • Branching and history (branch, history)
    // BaseStream is not used directly - use one of the specialized interfaces:
    // - UseGraphStream for CompiledStateGraph
    // - UseAgentStream for ReactAgent (createAgent)
    // - UseDeepAgentStream for DeepAgent (createDeepAgent)
    interface BaseStream<
        StateType extends Record<string, unknown> = Record<string, unknown>,
        ToolCall = DefaultToolCall,
        Bag extends BagTemplate = BagTemplate,
    > {
        assistantId: string;
        branch: string;
        client: Client;
        error: unknown;
        experimental_branchTree: Sequence<StateType>;
        getMessagesMetadata: (
            message: Message<ToolCall>,
            index?: number,
        ) => undefined | MessageMetadata<StateType>;
        history: ThreadState<StateType>[];
        interrupt: undefined | Interrupt<GetInterruptType<Bag>>;
        interrupts: Interrupt<GetInterruptType<Bag>>[];
        isLoading: boolean;
        isThreadLoading: boolean;
        joinStream: (
            runId: string,
            lastEventId?: string,
            options?: {
                filter?: (
                    event: { data: unknown; event: StreamEvent; id?: string },
                ) => boolean;
                streamMode?: StreamMode | StreamMode[];
            },
        ) => Promise<void>;
        messages: Message<ToolCall>[];
        setBranch: (branch: string) => void;
        stop: () => Promise<void>;
        submit: (
            values: undefined | null | GetUpdateType<Bag, StateType>,
            options?: SubmitOptions<StateType, GetConfigurableType<Bag>>,
        ) => Promise<void>;
        values: StateType;
    }

    Type Parameters

    • StateType extends Record<string, unknown> = Record<string, unknown>

      The state type of the stream

    • ToolCall = DefaultToolCall

      The tool call type for messages (inferred from agent tools)

    • Bag extends BagTemplate = BagTemplate

      Type configuration bag for interrupts, configurable, updates, etc.

    Hierarchy (View Summary)

    Index

    Properties

    assistantId: string

    The ID of the assistant to use.

    branch: string

    The current branch of the thread. Used for navigating between different conversation branches.

    client: Client

    LangGraph SDK client used to send requests and receive responses.

    error: unknown

    Last seen error from the stream, if any. Reset to undefined when a new stream starts.

    experimental_branchTree: Sequence<StateType>

    Tree of all branches for the thread. This API is experimental and subject to change.

    getMessagesMetadata: (
        message: Message<ToolCall>,
        index?: number,
    ) => undefined | MessageMetadata<StateType>

    Get the metadata for a message, such as first thread state the message was seen in and branch information.

    Type Declaration

    Flattened history of thread states of a thread. Contains all states in the current branch's history.

    interrupt: undefined | Interrupt<GetInterruptType<Bag>>

    Current interrupt, if the stream is interrupted. Convenience alias for interrupts[0]. For workflows with multiple concurrent interrupts, use interrupts instead.

    interrupts: Interrupt<GetInterruptType<Bag>>[]

    All current interrupts from the stream. When using Send() fan-out with per-task interrupt() calls, multiple interrupts may be pending simultaneously.

    isLoading: boolean

    Whether the stream is currently running. true while streaming, false when idle or completed.

    isThreadLoading: boolean

    Whether the thread is currently being loaded. true during initial thread data fetch.

    joinStream: (
        runId: string,
        lastEventId?: string,
        options?: {
            filter?: (
                event: { data: unknown; event: StreamEvent; id?: string },
            ) => boolean;
            streamMode?: StreamMode | StreamMode[];
        },
    ) => Promise<void>

    Join an active stream that's already running.

    Type Declaration

      • (
            runId: string,
            lastEventId?: string,
            options?: {
                filter?: (
                    event: { data: unknown; event: StreamEvent; id?: string },
                ) => boolean;
                streamMode?: StreamMode | StreamMode[];
            },
        ): Promise<void>
      • Parameters

        • runId: string

          The ID of the run to join

        • OptionallastEventId: string

          Optional last event ID for resuming from a specific point

        • Optionaloptions: {
              filter?: (
                  event: { data: unknown; event: StreamEvent; id?: string },
              ) => boolean;
              streamMode?: StreamMode | StreamMode[];
          }

          Optional configuration for the stream

        Returns Promise<void>

    messages: Message<ToolCall>[]

    Messages accumulated during the stream. Includes both human and AI messages. AI messages include typed tool calls based on the agent's tools.

    setBranch: (branch: string) => void

    Set the branch of the thread.

    Type Declaration

      • (branch: string): void
      • Parameters

        • branch: string

          The branch identifier to switch to

        Returns void

    stop: () => Promise<void>

    Stops the currently running stream.

    Type Declaration

      • (): Promise<void>
      • Returns Promise<void>

        A promise that resolves when the stream is stopped.

    submit: (
        values: undefined | null | GetUpdateType<Bag, StateType>,
        options?: SubmitOptions<StateType, GetConfigurableType<Bag>>,
    ) => Promise<void>

    Create and stream a run to the thread.

    Type Declaration

      • (
            values: undefined | null | GetUpdateType<Bag, StateType>,
            options?: SubmitOptions<StateType, GetConfigurableType<Bag>>,
        ): Promise<void>
      • Parameters

        • values: undefined | null | GetUpdateType<Bag, StateType>

          The input values to send, or null/undefined for empty input

        • Optionaloptions: SubmitOptions<StateType, GetConfigurableType<Bag>>

          Optional configuration for the submission

        Returns Promise<void>

        A promise that resolves when the stream completes

    values: StateType

    The current state values of the stream. Updated as streaming events are received.