langchain-ai/langgraph · error · RuntimeError

AsyncThreadStream not entered - use `async with`.

Error message

AsyncThreadStream not entered - use `async with`.

What it means

Error "AsyncThreadStream not entered - use `async with`." thrown in langchain-ai/langgraph.

Source

Thrown at libs/sdk-py/langgraph_sdk/_async/stream.py:916

            # Register so future _push_event calls on this handle fan out to the
            # grandchild at push time, preserving arrival order without drain-and-replay.
            self._handle._register_descendant(child_handle)
            yield child_handle


class _SubgraphsProjection:
    """Discover direct child invocations for a namespace scope."""

    def __init__(self, thread: AsyncThreadStream, scope: tuple[str, ...] = ()) -> None:
        self._thread = thread
        self._scope = scope

    def __aiter__(self) -> AsyncIterator[ScopedStreamHandle]:
        return self._subgraphs_iter()

    async def _subgraphs_iter(self) -> AsyncGenerator[ScopedStreamHandle, None]:
        if self._thread._transport is None:
            raise RuntimeError("AsyncThreadStream not entered - use `async with`.")
        params = _subgraph_subscription_params(self._scope)
        sub = self._thread._register_subscription(params)
        decoder = SubgraphsDecoder(
            scope=self._scope,
            handle_factory=lambda *, path, graph_name, trigger_call_id: (
                ScopedStreamHandle(
                    thread=self._thread,
                    path=path,
                    graph_name=graph_name,
                    trigger_call_id=trigger_call_id,
                )
            ),
        )
        root_inbox: asyncio.Queue[Event | None] | None = (
            self._thread._activate_root_messages_inbox() if not self._scope else None
        )
        try:
            await self._thread._reconcile_stream(params)

View on GitHub (pinned to 38031739e5)

When it happens

Trigger: Thrown at libs/sdk-py/langgraph_sdk/_async/stream.py:916 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of langchain-ai/langgraph@38031739e5 (2026-08-26). Data as JSON: /api/errors/7542db41dde1b8f0. Report an issue: GitHub.