langchain-ai/langgraph · error · RuntimeError
AsyncThreadStream is closed and cannot be re-entered.
Error message
AsyncThreadStream is closed and cannot be re-entered.
What it means
Error "AsyncThreadStream is closed and cannot be re-entered." thrown in langchain-ai/langgraph.
Source
Thrown at libs/sdk-py/langgraph_sdk/_async/stream.py:1245
self.values = _ValuesProjection(self)
self.messages = _MessagesProjection(self, namespace=[])
self.tool_calls = _ToolCallsProjection(self, namespace=[])
self.subgraphs = _SubgraphsProjection(self, scope=())
self.subagents = self.subgraphs
self.extensions = _ExtensionsProjection(self, namespace=[])
@property
def _controller(self) -> AsyncThreadStream:
"""Return self as the subscription controller (duck-type compatible with StreamController).
Exposes `_subscriptions` so tests can verify subscription counts via
`thread._controller._subscriptions` without requiring a separate controller object.
"""
return self
async def __aenter__(self) -> AsyncThreadStream:
if self._closed:
raise RuntimeError("AsyncThreadStream is closed and cannot be re-entered.")
transport_cls = (
ProtocolWebSocketTransport
if self._transport_kind == "websocket"
else ProtocolSseTransport
)
self._transport = transport_cls(
client=self._http.client,
thread_id=self.thread_id,
headers=self._headers,
max_queue_size=self._max_queue_size,
)
# Create the run-done future here (async context guarantees a running loop).
self._run_done = asyncio.get_running_loop().create_future()
# Start the lifecycle watcher immediately so reattach and thread.output
# work without a preceding run.start call.
self._ensure_lifecycle_watcher_running()
return self
View on GitHub (pinned to 38031739e5)
When it happens
Trigger: Thrown at libs/sdk-py/langgraph_sdk/_async/stream.py:1245 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/848263ef993ad4de.
Report an issue: GitHub.