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

    LangChain Assistant

    Ask a question to get started

    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-sdkstreamsubscription
    Module●Since v0.3

    subscription

    Functions

    View source on GitHub
    function
    normalize_segment

    Strip the dynamic suffix after : from a namespace segment.

    function
    is_prefix_match

    Whether event_namespace starts with prefix.

    Segments compare literally first; if the prefix segment contains no :, the candidate is also compared after its dynamic suffix is stripped. Mirrors is_prefix_match in api/langgraph_api/protocol/namespace.py.

    function
    namespace_matches

    Whether event_namespace matches any of prefixes within depth.

    function
    infer_channel

    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.

    function
    matches_subscription

    Whether event should be delivered for definition.

    function
    compute_union_filter

    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.
    function
    filter_covers

    Whether coverer is a superset of target.

    Direct port of client/stream/index.ts:filterCovers. Depth coverage accounts for namespace-prefix offset: a scoped coverer needs enough depth to absorb the extra levels of any deeper target namespace prefix.

    Subscription matching: channel inference + namespace prefix filtering.

    Direct port of libs/sdk/src/client/stream/subscription.ts from the JS SDK.