{"record":{"id":"7542db41dde1b8f0","repo":"langchain-ai/langgraph","slug":"asyncthreadstream-not-entered-use-async-with-7542db","errorCode":null,"errorMessage":"AsyncThreadStream not entered - use `async with`.","messagePattern":"AsyncThreadStream not entered - use `async with`\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"libs/sdk-py/langgraph_sdk/_async/stream.py","lineNumber":916,"sourceCode":"            # Register so future _push_event calls on this handle fan out to the\n            # grandchild at push time, preserving arrival order without drain-and-replay.\n            self._handle._register_descendant(child_handle)\n            yield child_handle\n\n\nclass _SubgraphsProjection:\n    \"\"\"Discover direct child invocations for a namespace scope.\"\"\"\n\n    def __init__(self, thread: AsyncThreadStream, scope: tuple[str, ...] = ()) -> None:\n        self._thread = thread\n        self._scope = scope\n\n    def __aiter__(self) -> AsyncIterator[ScopedStreamHandle]:\n        return self._subgraphs_iter()\n\n    async def _subgraphs_iter(self) -> AsyncGenerator[ScopedStreamHandle, None]:\n        if self._thread._transport is None:\n            raise RuntimeError(\"AsyncThreadStream not entered - use `async with`.\")\n        params = _subgraph_subscription_params(self._scope)\n        sub = self._thread._register_subscription(params)\n        decoder = SubgraphsDecoder(\n            scope=self._scope,\n            handle_factory=lambda *, path, graph_name, trigger_call_id: (\n                ScopedStreamHandle(\n                    thread=self._thread,\n                    path=path,\n                    graph_name=graph_name,\n                    trigger_call_id=trigger_call_id,\n                )\n            ),\n        )\n        root_inbox: asyncio.Queue[Event | None] | None = (\n            self._thread._activate_root_messages_inbox() if not self._scope else None\n        )\n        try:\n            await self._thread._reconcile_stream(params)","sourceCodeStart":898,"sourceCodeEnd":934,"githubUrl":"https://github.com/langchain-ai/langgraph/blob/38031739e551638e373fb553453256c23feeb41f/libs/sdk-py/langgraph_sdk/_async/stream.py#L898-L934","documentation":"Context-manager guard (hyphen variant) on AsyncThreadStream: an operation needs the active transport but the stream has not been entered with `async with`. The transport is None outside the session, so any command-sending or event-subscription path fails here.","triggerScenarios":"Thrown at libs/sdk-py/langgraph_sdk/_async/stream.py:916 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Wrap usage in `async with thread:` / enter the stream context before issuing commands","Acquire the stream via the proper context manager (e.g. `async with client.streams...`) rather than constructing it ad hoc"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"38031739e551638e373fb553453256c23feeb41f","analyzedAt":"2026-08-26T18:02:49.312Z","contentChangedAt":"2026-08-26T18:02:49.312Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}