langchain-ai/langgraph · error · TypeError
stream_events(version='v3') transformers must be…
Error message
stream_events(version='v3') transformers must be scope-aware callables, got {type(spec).__name__}. What it means
Raised while normalizing v3 stream transformer specs when a spec is not a scope-aware callable (it is a pre-built StreamTransformer instance or another non-callable). v3 requires factories that accept a scope tuple and return a fresh transformer per subgraph.
Solutions
- Pass the transformer class itself or a lambda scope: MyTransformer(scope)
- Ensure each spec is callable with one positional scope argument
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at libs/langgraph/langgraph/pregel/main.py:438 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of langchain-ai/langgraph@38031739e5 (2026-08-26).
Data as JSON: /api/errors/9aba2355e39a1e55.
Report an issue: GitHub.
Appendix: source
Thrown at libs/langgraph/langgraph/pregel/main.py:438
"""Normalize stream transformer specs to scoped factories.
A stream transformer spec is a callable that accepts
`scope: tuple[str, ...]` and returns a fresh `StreamTransformer`.
Transformer classes work when their constructor follows the same
shape. Pre-built instances are rejected because they cannot be
cloned into subgraph scopes.
"""
factories: list[Callable[[tuple[str, ...]], Any]] = []
for spec in specs or ():
if isinstance(spec, StreamTransformer):
raise TypeError(
"stream_events(version='v3') transformers must be scope-aware callables, "
f"got pre-built instance {type(spec).__name__}. Pass the "
"transformer class or a factory like "
"`lambda scope: MyTransformer(scope, ...)`."
)
if not callable(spec):
raise TypeError(
"stream_events(version='v3') transformers must be scope-aware callables, "
f"got {type(spec).__name__}."
)
def factory(scope: tuple[str, ...], _spec: Callable[..., Any] = spec) -> Any:
return _spec(scope)
factories.append(factory)
return factories
class Pregel(
PregelProtocol[StateT, ContextT, InputT, OutputT],
Generic[StateT, ContextT, InputT, OutputT],
):
"""Pregel manages the runtime behavior for LangGraph applications.
## OverviewView on GitHub (pinned to 38031739e5)