langchain-ai/langgraph · error · ValueError

RunnableSeq must have at least 2 steps, got

Error message

RunnableSeq must have at least 2 steps, got {len(steps_flat)}

What it means

RunnableSeq exists to sequence multiple steps; after flattening nested RunnableSequence/RunnableSeq steps, fewer than 2 remain, which a sequence cannot represent, so ValueError is raised (callers should use the single runnable directly).

Solutions

  1. Use the single step Runnable directly instead of wrapping it in RunnableSeq.
  2. Check callers constructing RunnableSeq with one or zero steps.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at libs/langgraph/langgraph/_internal/_runnable.py:616 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/09cb03fd38db84c2. Report an issue: GitHub.

Appendix: source

Thrown at libs/langgraph/langgraph/_internal/_runnable.py:616

        """Create a new RunnableSeq.

        Args:
            steps: The steps to include in the sequence.
            name: The name of the `Runnable`.

        Raises:
            ValueError: If the sequence has less than 2 steps.
        """
        steps_flat: list[Runnable] = []
        for step in steps:
            if isinstance(step, RunnableSequence):
                steps_flat.extend(step.steps)
            elif isinstance(step, RunnableSeq):
                steps_flat.extend(step.steps)
            else:
                steps_flat.append(coerce_to_runnable(step, name=None, trace=True))
        if len(steps_flat) < 2:
            raise ValueError(
                f"RunnableSeq must have at least 2 steps, got {len(steps_flat)}"
            )
        self.steps = steps_flat
        self.name = name
        self.trace_inputs = trace_inputs
        self.trace_outputs = trace_outputs

    def __or__(
        self,
        other: Any,
    ) -> Runnable:
        if isinstance(other, RunnableSequence):
            return RunnableSeq(
                *self.steps,
                other.first,
                *other.middle,
                other.last,
                name=self.name or other.name,

View on GitHub (pinned to 38031739e5)