langchain-ai/langchain · error · NotImplementedError

astream_events(version='v3') is only supported on Runnable s

Error message

astream_events(version='v3') is only supported on Runnable subclasses that implement the v3 streaming protocol (BaseChatModel, CompiledGraph). Got: {type(self).__name__}

What it means

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__`.

Source

Thrown at libs/core/langchain_core/runnables/base.py:1601

            exclude_types=exclude_types,
            exclude_tags=exclude_tags,
            **kwargs,
        )

    async def _astream_events_v3_unsupported(self) -> Any:
        """Coroutine that raises when v3 isn't implemented on this Runnable.

        Lets the public `astream_events(version="v3")` return an awaitable
        whose error surfaces on `await`, matching the v3 contract on
        subclasses that do implement the protocol.
        """
        msg = (
            "astream_events(version='v3') is only supported on Runnable "
            "subclasses that implement the v3 streaming protocol "
            "(BaseChatModel, CompiledGraph). "
            f"Got: {type(self).__name__}"
        )
        raise NotImplementedError(msg)

    async def _astream_events_v1_v2(
        self,
        input: Any,
        config: RunnableConfig | None = None,
        *,
        version: Literal["v1", "v2"] = "v2",
        include_names: Sequence[str] | None = None,
        include_types: Sequence[str] | None = None,
        include_tags: Sequence[str] | None = None,
        exclude_names: Sequence[str] | None = None,
        exclude_types: Sequence[str] | None = None,
        exclude_tags: Sequence[str] | None = None,
        **kwargs: Any,
    ) -> AsyncIterator[StreamEvent]:
        if version == "v2":
            event_stream = _astream_events_implementation_v2(
                self,

View on GitHub (pinned to e32fa9a52e)

Solutions

  1. Fall back to `version="v2"` (or `"v1"`), which works on all Runnables via `_astream_events_v1_v2`
  2. 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
  3. Check `isinstance(obj, BaseChatModel)` or for a v3 implementation before selecting version='v3'

Example fix

# before
async for ev in my_runnable_lambda.astream_events(inp, version="v3"):
    ...  # NotImplementedError on first await

# after
async for ev in my_runnable_lambda.astream_events(inp, version="v2"):
    ...  # supported everywhere
Defensive patterns

Strategy: validation

Validate before calling

SUPPORTED_V3 = (BaseChatModel, CompiledGraph)  # from langchain_core.language_models / langgraph.pregel

def supports_v3_events(target: object) -> bool:
    return isinstance(target, SUPPORTED_V3) or getattr(type(target), "_astream_events_v3", None) is not Runnable._astream_events_v3

Type guard

def implements_v3(runnable: object) -> bool:
    from langchain_core.runnables.base import Runnable
    return type(runnable)._astream_events_v3 is not Runnable._astream_events_v3

Try / catch

try:
    async for ev in chain.astream_events(inp, version="v3"):
        handle(ev)
except NotImplementedError:
    async for ev in chain.astream_events(inp, version="v2"):
        handle(ev)

Prevention

When it happens

Trigger: `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`.

Common situations: 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.

Related errors


AI-assisted analysis of langchain-ai/langchain@e32fa9a52e (2026-08-14). Data as JSON: /api/errors/cfd1d5ade6231a0d. Report an issue: GitHub.