LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • LangGraph Checkpoint
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    ⌘I

    Chat LangChain

    What can I help with?

    Enter to send·Shift+Enter new line

    Menu

    LangGraph Checkpoint
    LangGraph Store
    Checkpoint Postgres
    Store Postgres
    Checkpoint SQLite
    LangGraph Prebuilt
    LangGraph CLI
    LangGraph SDK
    LangGraph Supervisor
    LangGraph Swarm
    Language
    Theme
    Pythonlanggraph-sdk_asyncstream
    Module●Since v0.4

    stream

    Attributes

    Functions

    Classes

    Type Aliases

    View source on GitHub
    attribute
    logger
    attribute
    SubgraphStatus: Literal['started', 'completed', 'failed', 'interrupted']
    function
    validate_interleave_channels
    function
    is_non_retryable_stream_error
    function
    protocol_error
    function
    stream_error_frame
    function
    compute_union_filter
    function
    infer_channel
    class
    HttpClient
    class
    LangSmithTracing
    class
    DataDecoder
    class
    Decoder
    class
    ExtensionsDecoder
    class
    MessagesDecoder
    class
    SubgraphsDecoder
    class
    ToolCallsDecoder
    class
    AsyncProtocolTransport
    class
    EventStreamHandle
    class
    ProtocolSseTransport
    class
    ProtocolWebSocketTransport
    class
    InterruptPayload
    class
    RunModule
    class
    ScopedStreamHandle
    class
    ToolCallHandle
    class
    AsyncThreadStream
    typeAlias
    QueryParamTypes: Mapping[str, PrimitiveData | Sequence[PrimitiveData]] | list[tuple[str, PrimitiveData]] | tuple[tuple[str, PrimitiveData], ...] | str | bytes

    Async thread-centric streaming surface for the v3 protocol.

    AsyncThreadStream is an async context manager that owns a ProtocolSseTransport for one thread, dispatches commands (run.start, run.respond), exposes typed subscriptions over a single shared SSE (subscribe, events), surfaces lifecycle state (interrupted, interrupts) via an always-on lifecycle watcher SSE, and provides typed projections (thread.values, thread.messages, thread.tool_calls, thread.extensions).

    Direct port of libs/sdk/src/client/stream/index.ts.

    Reject reserved protocol channel names before they hit the fallback.

    Genuine extension names pass through untouched; only names that infer_channel treats as built-in methods without an interleave decoder are rejected, so a typo'd or unsupported protocol channel surfaces an error instead of an empty stream.

    Whether reopening the stream would fail the same way.

    True for a 4xx other than 408 and 429: the status of a refused stream request or WebSocket upgrade, or a WebSocket close code of 4000 plus that status. A server that rejects a WebSocket after accepting it closes with such a code, because a browser can't read the status of a refused upgrade.

    Build the error for a protocol {"type": "error"} envelope.

    Return the error in an unsolicited {"type": "error", "id": null} frame.

    The server sends one just before it closes a thread stream whose read failed.

    Aggregate a set of subscription filters into one covering filter.

    Direct port of client/stream/index.ts:#computeUnionFilter.

    • Channels are unioned.
    • Namespaces: if any subscription omits namespaces (wildcard), the union is unscoped (omits the key). Otherwise, deduplicated union.
    • Depth: if any subscription omits depth (unbounded), the union is unbounded (omits the key). Otherwise, take the max. depth=0 is a valid bounded value — never omit when all subscriptions provide it.

    Map a protocol event's method to its subscription channel.

    Returns None for unrecognized methods so new server-side channels (e.g. from extension transformers) don't break existing clients.

    Handle async requests to the LangGraph API.

    Adds additional error messaging & content handling above the provided httpx client.

    Configuration for LangSmith tracing.

    Yields params.data from events of a single method.

    Covers the channels whose projection is just "emit the payload": values, updates, checkpoints, tasks — the SDK analog of local's Values/Updates/Checkpoints/TasksTransformer, all of which push params["data"] unchanged. The REST-state seeding for values stays at the projection layer; it is a one-shot pre-stream fetch, not part of the event state machine.

    Yields params.data from one named custom channel.

    Mirrors _ExtensionProjection._iter (_async/stream.py:1278-1299), with an added name filter so it can share one subscription in interleave.

    Yields one chat-model stream per message-start event.

    Subsequent events route to the matching stream via stream.dispatch(data). Mirrors the per-event body of _MessagesProjection._messages_iter (_async/stream.py:404-458). The subscription open/close and the _root_messages_inbox drain branch stay at the projection layer.

    Discovers child subgraph handles and fans out events to active ones.

    Mirrors the per-event body of _SubgraphsProjection._subgraphs_iter (_async/stream.py:963-1041) plus _apply_tasks_result. Root-inbox forwarding and terminal-status-on-close stay at the projection / wrapper layer.

    Yields one tool-call handle per tool-started event.

    Mirrors the per-event body of _ToolCallsProjection._tool_calls_iter (_async/stream.py:1168-1217). The thread register/unregister and the terminal-error-on-close finally stay at the projection / wrapper layer.

    Protocol implemented by async SSE and WebSocket transports.

    Handle for one async filtered event stream.

    v3 protocol transport bound to a single thread_id.

    Commands go to POST /threads/{thread_id}/commands (JSON in, JSON out). open_event_stream opens filtered SSE streams against POST /threads/{thread_id}/stream/events.

    v3 protocol transport using HTTP commands and WebSocket events.

    Payload surfaced when the server requests human input for a thread.

    Command dispatcher for run.start.

    Bound to one AsyncThreadStream; accesses its transport and id allocator.

    Scoped streaming handle for one discovered child invocation.

    Async handle for one root-scope tool call.

    Async context manager for one thread's v3 streaming session.

    Construct via client.threads.stream(thread_id=None, *, assistant_id, ...) rather than instantiating directly.