langchain-ai/langchain · error · NotImplementedError

stream_events(version='v3') is only supported on Runnable su

Error message

stream_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.stream_events` (the synchronous variant) when called with `version="v3"` on a Runnable that does not implement the v3 streaming protocol. As with the async variant, only `BaseChatModel` and `CompiledGraph` implement v3; the base class consumes its arguments (to avoid unused-arg lint) and raises `NotImplementedError`, naming the actual class via `type(self).__name__`.

Source

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

            exclude_tags: Exclude events from `Runnable` objects with matching tags.
            **kwargs: Additional keyword arguments to pass to the `Runnable`.

        Raises:
            NotImplementedError: Always. Subclasses override this method for supported
                versions.

        """
        # Base impl always raises; consume args so they don't trip ARG002.
        del input, config, include_names, include_types, include_tags
        del exclude_names, exclude_types, exclude_tags, kwargs
        if version == "v3":
            msg = (
                "stream_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)
        msg = (
            f"stream_events(version={version!r}) is not supported. "
            "Use astream_events() for v1/v2, or stream_events(version='v3') "
            "on a supported subclass."
        )
        raise NotImplementedError(msg)

    def transform(
        self,
        input: Iterator[Input],
        config: RunnableConfig | None = None,
        **kwargs: Any | None,
    ) -> Iterator[Output]:
        """Transform inputs to outputs.

        Default implementation of transform, which buffers input and calls `astream`.

        Subclasses must override this method if they can start producing output while

View on GitHub (pinned to e32fa9a52e)

Solutions

  1. Use `version="v2"` with `astream_events` (sync `stream_events` does not support v1/v2 at all — see the companion error)
  2. Stream from a `BaseChatModel` instance or a compiled LangGraph (`CompiledGraph`) if v3 semantics are required
  3. Wrap the unsupported chain in a LangGraph node so the top-level object implements the v3 protocol

Example fix

# before
for ev in my_sequence.stream_events(inp, version="v3"):
    ...  # NotImplementedError: only supported on BaseChatModel, CompiledGraph

# after
for ev in compiled_graph.stream_events(inp, version="v3"):
    ...  # supported
Defensive patterns

Strategy: validation

Validate before calling

from langchain_core.language_models import BaseChatModel

def supports_sync_v3(target: object) -> bool:
    try:
        from langgraph.pregel import CompiledGraph
        return isinstance(target, (BaseChatModel, CompiledGraph))
    except ImportError:
        return isinstance(target, BaseChatModel)

Try / catch

try:
    for ev in target.stream_events(inp, version="v3"):
        ...
except NotImplementedError:
    for ev in target.stream(inp):  # degrade to plain token streaming
        ...

Prevention

When it happens

Trigger: `chain.stream_events(inp, version="v3")` on a `RunnableSequence`, `RunnableLambda`, plain prompt, or any custom Runnable outside the two supported families. The `version == "v3"` branch raises immediately (synchronously, not on iteration).

Common situations: Porting async v3 event code to a synchronous entry point; agent frameworks exposing a sync `stream_events` facade over arbitrary user chains; smoke-testing v3 on simple LCEL pipelines before wiring real models.

Related errors


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