langchain-ai/langgraph · error · ValueError

Unsupported input to ValidationNode. Expected BaseModel…

Error message

Unsupported input to ValidationNode. Expected BaseModel, tool or function. Got: {type(schema)}.

What it means

ValidationNode constructor guard: an element of `schemas` is not a pydantic BaseModel, a BaseTool, or a callable. Anything else (a string, instance, or arbitrary object) falls through all the isinstance/callable branches and is rejected as an unsupported schema input.

Solutions

  1. Pass only BaseModel classes, BaseTool instances, or plain functions in the schemas list
  2. Pass tool instances themselves rather than their names or schemas-by-string
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at libs/prebuilt/langgraph/prebuilt/tool_validator.py:164 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/7c89d04c0282e013. Report an issue: GitHub.

Appendix: source

Thrown at libs/prebuilt/langgraph/prebuilt/tool_validator.py:164

                        f"Tool {schema.name} does not have an args_schema defined."
                    )
                elif not isinstance(
                    schema.args_schema, type
                ) or not is_basemodel_subclass(schema.args_schema):
                    raise ValueError(
                        "Validation node only works with tools that have a pydantic BaseModel args_schema. "
                        f"Got {schema.name} with args_schema: {schema.args_schema}."
                    )
                self.schemas_by_name[schema.name] = schema.args_schema
            elif isinstance(schema, type) and issubclass(
                schema, (BaseModel, BaseModelV1)
            ):
                self.schemas_by_name[schema.__name__] = cast(type[BaseModel], schema)
            elif callable(schema):
                base_model = create_schema_from_function("Validation", schema)
                self.schemas_by_name[schema.__name__] = base_model
            else:
                raise ValueError(
                    f"Unsupported input to ValidationNode. Expected BaseModel, tool or function. Got: {type(schema)}."
                )

    def _get_message(
        self, input: list[AnyMessage] | dict[str, Any]
    ) -> tuple[str, AIMessage]:
        """Extract the last AIMessage from the input."""
        if isinstance(input, list):
            output_type = "list"
            messages: list = input
        elif messages := input.get("messages", []):
            output_type = "dict"
        else:
            raise ValueError("No message found in input")
        message: AnyMessage = messages[-1]
        if not isinstance(message, AIMessage):
            raise ValueError("Last message is not an AIMessage")
        return output_type, message

View on GitHub (pinned to 38031739e5)