langchain-ai/langchain · error · TypeError

Runnable {self.get_name()} doesn't have an inferable OutputT

Error message

Runnable {self.get_name()} doesn't have an inferable OutputType. Override the OutputType property to specify the output type.

What it means

Raised by the `OutputType` property on `Runnable` when the output type cannot be inferred: the pydantic-model metadata scan finds no annotated args and no `__orig_bases__` entry is a parameterized `Runnable[Input, Output]` from which `type_args[1]` could be taken. Mirrors the `InputType` error but for the output side; the message names the Runnable and tells you to override `OutputType`.

Source

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

        for base in self.__class__.mro():
            if hasattr(base, "__pydantic_generic_metadata__"):
                metadata = base.__pydantic_generic_metadata__
                if (
                    "args" in metadata
                    and len(metadata["args"]) == _RUNNABLE_GENERIC_NUM_ARGS
                ):
                    return cast("type[Output]", metadata["args"][1])

        for cls in self.__class__.__orig_bases__:  # type: ignore[attr-defined]
            type_args = get_args(cls)
            if type_args and len(type_args) == _RUNNABLE_GENERIC_NUM_ARGS:
                return cast("type[Output]", type_args[1])

        msg = (
            f"Runnable {self.get_name()} doesn't have an inferable OutputType. "
            "Override the OutputType property to specify the output type."
        )
        raise TypeError(msg)

    @property
    def input_schema(self) -> TypeBaseModel:
        """The type of input this `Runnable` accepts specified as a Pydantic model."""
        return self.get_input_schema()

    def get_input_schema(
        self,
        config: RunnableConfig | None = None,
    ) -> TypeBaseModel:
        """Get a Pydantic model that can be used to validate input to the `Runnable`.

        `Runnable` objects that leverage the `configurable_fields` and
        `configurable_alternatives` methods will have a dynamic input schema that
        depends on which configuration the `Runnable` is invoked with.

        This method allows to get an input schema for a specific configuration.

View on GitHub (pinned to e32fa9a52e)

Solutions

  1. Parameterize the base: `class MyRunnable(Runnable[str, dict])`
  2. Or override: `@property def OutputType(self): return dict`
  3. Keep the parameterization even when it looks redundant — schema inference depends on it at runtime, not just for static checkers

Example fix

# before
class Extract(Runnable):
    def invoke(self, text, config=None):
        return {"entities": []}
Extract().OutputType  # TypeError

# after
class Extract(Runnable[str, dict]):
    def invoke(self, text, config=None):
        return {"entities": []}
Defensive patterns

Strategy: type-guard

Validate before calling

def has_inferable_output_type(runnable: Runnable) -> bool:
    try:
        _ = runnable.OutputType
        return True
    except TypeError:
        return False

Try / catch

try:
    schema = runnable.get_output_schema()
except TypeError as e:
    if "inferable OutputType" in str(e):
        raise TypeError(f"{type(runnable).__name__} must be Runnable[I, O] or override OutputType") from e
    raise

Prevention

When it happens

Trigger: `class MyRunnable(Runnable):` with only `invoke` implemented, then accessing `.OutputType`, `.get_output_schema()`, or passing it to code that renders graphs / validates stream payloads. Also triggered when `Runnable[OneGeneric]` is used with fewer type args than required.

Common situations: Custom Runnables written without generic parameters being plugged into LangGraph nodes, LangSmith tracing, or `RunnableSequence` schema checks; third-party examples copied with the generics stripped for brevity.

Related errors


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