langchain-ai/langgraph · error · RuntimeError

SyncThreadStream is closed and cannot be re-entered.

Error message

SyncThreadStream is closed and cannot be re-entered.

What it means

Error "SyncThreadStream is closed and cannot be re-entered." thrown in langchain-ai/langgraph.

Source

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

        self._lifecycle_cursor: int | None = None
        self._lifecycle_max_reconnect_attempts = 5
        self._run_seen: bool = False
        self._run_done: _BlockingResult | None = None
        self._active_message_streams: set[ChatModelStream] = set()
        self._active_tool_calls: set[SyncToolCallHandle] = set()
        self._root_messages_inbox: queue.Queue[Event | None] | None = None
        self.run = SyncRunModule(self)
        self.agent = _SyncAgentModule(self)
        self.values = _SyncValuesProjection(self)
        self.messages = _SyncMessagesProjection(self, namespace=[])
        self.tool_calls = _SyncToolCallsProjection(self, namespace=[])
        self.subgraphs = _SyncSubgraphsProjection(self, scope=())
        self.subagents = self.subgraphs
        self.extensions = _SyncExtensionsProjection(self, namespace=[])

    def __enter__(self) -> SyncThreadStream:
        if self._closed:
            raise RuntimeError("SyncThreadStream is closed and cannot be re-entered.")
        transport_cls = (
            SyncProtocolWebSocketTransport
            if self._transport_kind == "websocket"
            else SyncProtocolSseTransport
        )
        self._transport = transport_cls(
            client=self._http.client,
            thread_id=self.thread_id,
            headers=self._headers,
        )
        # Gate is unset; SyncRunModule.start (or an explicit set) clears it so
        # that subscriptions opening before run.start block until the server
        # has accepted the run command.
        run_start_gate = threading.Event()
        self._controller = SyncStreamController(
            self._transport, run_start_gate=run_start_gate
        )
        self._run_done = _BlockingResult()

View on GitHub (pinned to 38031739e5)

When it happens

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