langchain-ai/langgraph · error · RuntimeError

SyncThreadStream not entered — use `with`.

Error message

SyncThreadStream not entered — use `with`.

What it means

Error "SyncThreadStream not entered — use `with`." thrown in langchain-ai/langgraph.

Source

Thrown at libs/sdk-py/langgraph_sdk/_sync/stream.py:305

    Supports `for snapshot in thread.values` (REST snapshot then live stream
    events) and `thread.values.get()` (delegates to `thread.output`).
    """

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

    def __iter__(self) -> Iterator[Any]:
        """Iterate over state snapshots: REST state first, then live values events."""
        return self._values_iter()

    def get(self) -> Any:
        """Return terminal state values; equivalent to `thread.output`."""
        return self._thread.output

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


class _SyncMessagesProjection:

View on GitHub (pinned to 38031739e5)

When it happens

Trigger: Thrown at libs/sdk-py/langgraph_sdk/_sync/stream.py:305 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/dc81a7aa86ef7106. Report an issue: GitHub.