{"record":{"id":"dc81a7aa86ef7106","repo":"langchain-ai/langgraph","slug":"syncthreadstream-not-entered-use-with","errorCode":null,"errorMessage":"SyncThreadStream not entered — use `with`.","messagePattern":"SyncThreadStream not entered — use `with`\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"libs/sdk-py/langgraph_sdk/_sync/stream.py","lineNumber":305,"sourceCode":"\n    Supports `for snapshot in thread.values` (REST snapshot then live stream\n    events) and `thread.values.get()` (delegates to `thread.output`).\n    \"\"\"\n\n    def __init__(self, thread: SyncThreadStream) -> None:\n        self._thread = thread\n\n    def __iter__(self) -> Iterator[Any]:\n        \"\"\"Iterate over state snapshots: REST state first, then live values events.\"\"\"\n        return self._values_iter()\n\n    def get(self) -> Any:\n        \"\"\"Return terminal state values; equivalent to `thread.output`.\"\"\"\n        return self._thread.output\n\n    def _values_iter(self) -> Iterator[Any]:\n        if self._thread._transport is None:\n            raise RuntimeError(\"SyncThreadStream not entered — use `with`.\")\n        params: SubscribeParams = {\"channels\": [\"values\"]}\n        sub = self._thread._register_subscription(params)\n        decoder = DataDecoder(\"values\")\n        try:\n            self._thread._reconcile_stream(params)\n            self._thread._ensure_fanout_running()\n            state = self._thread._fetch_state()\n            yield state[\"values\"]\n            while True:\n                item = sub.queue.get()\n                if item is None:\n                    return\n                yield from decoder.feed(cast(dict[str, Any], item))\n        finally:\n            self._thread._unregister_subscription(sub.id)\n\n\nclass _SyncMessagesProjection:","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/langchain-ai/langgraph/blob/38031739e551638e373fb553453256c23feeb41f/libs/sdk-py/langgraph_sdk/_sync/stream.py#L287-L323","documentation":"Error \"SyncThreadStream not entered — use `with`.\" thrown in langchain-ai/langgraph.","triggerScenarios":"Thrown at libs/sdk-py/langgraph_sdk/_sync/stream.py:305 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"38031739e551638e373fb553453256c23feeb41f","analyzedAt":"2026-08-26T18:02:49.312Z","schemaVersion":2},"datasetVersion":"2026-08-26T21:11:00.512Z"}