{"record":{"id":"cfd1d5ade6231a0d","repo":"langchain-ai/langchain","slug":"astream-events-version-v3-is-only-supported-on","errorCode":null,"errorMessage":"astream_events(version='v3') is only supported on Runnable subclasses that implement the v3 streaming protocol (BaseChatModel, CompiledGraph). Got: {type(self).__name__}","messagePattern":"astream_events\\(version='v3'\\) is only supported on Runnable subclasses that implement the v3 streaming protocol \\(BaseChatModel, CompiledGraph\\)\\. Got: (.+?)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"libs/core/langchain_core/runnables/base.py","lineNumber":1601,"sourceCode":"            exclude_types=exclude_types,\n            exclude_tags=exclude_tags,\n            **kwargs,\n        )\n\n    async def _astream_events_v3_unsupported(self) -> Any:\n        \"\"\"Coroutine that raises when v3 isn't implemented on this Runnable.\n\n        Lets the public `astream_events(version=\"v3\")` return an awaitable\n        whose error surfaces on `await`, matching the v3 contract on\n        subclasses that do implement the protocol.\n        \"\"\"\n        msg = (\n            \"astream_events(version='v3') is only supported on Runnable \"\n            \"subclasses that implement the v3 streaming protocol \"\n            \"(BaseChatModel, CompiledGraph). \"\n            f\"Got: {type(self).__name__}\"\n        )\n        raise NotImplementedError(msg)\n\n    async def _astream_events_v1_v2(\n        self,\n        input: Any,\n        config: RunnableConfig | None = None,\n        *,\n        version: Literal[\"v1\", \"v2\"] = \"v2\",\n        include_names: Sequence[str] | None = None,\n        include_types: Sequence[str] | None = None,\n        include_tags: Sequence[str] | None = None,\n        exclude_names: Sequence[str] | None = None,\n        exclude_types: Sequence[str] | None = None,\n        exclude_tags: Sequence[str] | None = None,\n        **kwargs: Any,\n    ) -> AsyncIterator[StreamEvent]:\n        if version == \"v2\":\n            event_stream = _astream_events_implementation_v2(\n                self,","sourceCodeStart":1583,"sourceCodeEnd":1619,"githubUrl":"https://github.com/langchain-ai/langchain/blob/e32fa9a52eab3b61ad7a45399bfde59b3e580fc4/libs/core/langchain_core/runnables/base.py#L1583-L1619","documentation":"Raised by the base `Runnable._astream_events_v3` when `astream_events(..., version=\"v3\")` is called on a Runnable that does not implement the v3 streaming protocol. Only `BaseChatModel` and `CompiledGraph` currently implement v3; the base implementation exists so the error surfaces on `await` (matching the async contract) rather than at call time, and it names the offending class via `type(self).__name__`.","triggerScenarios":"`chain.astream_events(input, version=\"v3\")` where `chain` is a `RunnableSequence`, `RunnableLambda`, a plain prompt, or any custom Runnable whose components are not a BaseChatModel/CompiledGraph. Delegating wrappers eventually hit the base `_astream_events_v3` coroutine and raise `NotImplementedError`.","commonSituations":"Adopting v3 event payloads (richer token metadata) and assuming all Runnables support it; enabling v3 globally in a framework layer (e.g. an agent runtime that streams events from arbitrary chains); testing v3 on toy `RunnableLambda` pipelines.","solutions":["Fall back to `version=\"v2\"` (or `\"v1\"`), which works on all Runnables via `_astream_events_v1_v2`","Ensure the top-level object you stream from is a chat model or a compiled LangGraph, and wrap other chains inside a graph if v3 semantics are required","Check `isinstance(obj, BaseChatModel)` or for a v3 implementation before selecting version='v3'"],"exampleFix":"# before\nasync for ev in my_runnable_lambda.astream_events(inp, version=\"v3\"):\n    ...  # NotImplementedError on first await\n\n# after\nasync for ev in my_runnable_lambda.astream_events(inp, version=\"v2\"):\n    ...  # supported everywhere","handlingStrategy":"validation","validationCode":"SUPPORTED_V3 = (BaseChatModel, CompiledGraph)  # from langchain_core.language_models / langgraph.pregel\n\ndef supports_v3_events(target: object) -> bool:\n    return isinstance(target, SUPPORTED_V3) or getattr(type(target), \"_astream_events_v3\", None) is not Runnable._astream_events_v3","typeGuard":"def implements_v3(runnable: object) -> bool:\n    from langchain_core.runnables.base import Runnable\n    return type(runnable)._astream_events_v3 is not Runnable._astream_events_v3","tryCatchPattern":"try:\n    async for ev in chain.astream_events(inp, version=\"v3\"):\n        handle(ev)\nexcept NotImplementedError:\n    async for ev in chain.astream_events(inp, version=\"v2\"):\n        handle(ev)","preventionTips":["Default to version='v2' for portable code","Gate v3 usage behind a capability check on the target object","Wrap arbitrary chains in a LangGraph graph when v3 events are required"],"tags":["runnables","streaming","astream-events","notimplementederror","versioning"],"backgroundTag":null,"analyzedSha":"e32fa9a52eab3b61ad7a45399bfde59b3e580fc4","analyzedAt":"2026-08-14T18:42:09.092Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}