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:358

class _ValuesProjection:
    """Typed projection for `thread.values` — yields state snapshots as they arrive.

    Supports both `async for` (live stream of state snapshots) and `await`
    (delegates to `thread.output` for the terminal state value).
    """

    def __init__(self, thread: AsyncThreadStream) -> None:
        self._thread = thread

    def __await__(self) -> Generator[Any, None, Any]:
        return self._thread.output.__await__()

    def __aiter__(self) -> AsyncIterator[Any]:
        return self._values_iter()

    async def _values_iter(self) -> AsyncGenerator[Any, None]:
        if self._thread._transport is None:
            raise RuntimeError("AsyncThreadStream not entered — use `async with`.")
        params: SubscribeParams = {"channels": ["values"]}
        sub = self._thread._register_subscription(params)
        decoder = DataDecoder("values")
        try:
            await self._thread._reconcile_stream(params)
            self._thread._ensure_fanout_running()
            state = await self._thread._fetch_state()
            yield state["values"]
            while True:
                item = await sub.queue.get()
                if item is None:
                    return
                for out in decoder.feed(item):
                    yield out
        finally:
            self._thread._unregister_subscription(sub.id)

View on GitHub (pinned to 38031739e5)

When it happens

Trigger: Thrown at libs/sdk-py/langgraph_sdk/_async/stream.py:358 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/5b569569c9c95eee. Report an issue: GitHub.