langchain-ai/langgraph · error · ValueError
tee() requires n >= 1
Error message
tee() requires n >= 1
What it means
Raised by StreamChannel.tee() when n is less than 1. Creating zero or negative branches is meaningless — tee must return at least one iterator — so the argument is validated with a ValueError. Pass n >= 1.
Solutions
- Pass n >= 1 to tee()
- Skip tee entirely if no fan-out is needed
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at libs/langgraph/langgraph/stream/stream_channel.py:265 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/bf79cb591bf9da3c.
Report an issue: GitHub.
Appendix: source
Thrown at libs/langgraph/langgraph/stream/stream_channel.py:265
Each branch has its own buffer; items pulled from the
underlying cursor are copied into every branch. Branches are
naturally bounded by caller pace since the sync pump is
caller-driven.
Args:
n: Number of branches to create. Must be >= 1.
Returns:
A tuple of `n` iterators over the same underlying stream.
Raises:
TypeError: If the channel is unbound or bound to async mode.
RuntimeError: If the channel already has a subscriber.
ValueError: If `n` < 1.
"""
if n < 1:
raise ValueError("tee() requires n >= 1")
source = self.__iter__()
buffers: list[deque[T]] = [deque() for _ in range(n)]
exhausted = [False]
def branch(i: int) -> Iterator[T]:
buf = buffers[i]
while True:
if buf:
yield buf.popleft()
elif exhausted[0]:
return
else:
try:
item = next(source)
except StopIteration:
exhausted[0] = True
return
for b in buffers:View on GitHub (pinned to 38031739e5)