langchain-ai/langchain · error · ValueError

Unsupported tool call schema: {tool.tool_call_schema}. Tool

Error message

Unsupported tool call schema: {tool.tool_call_schema}. Tool call schema must be a JSON schema dict or a Pydantic model.

What it means

Error "Unsupported tool call schema: {tool.tool_call_schema}. Tool call schema must be a JSON schema dict or a Pydantic model." thrown in langchain-ai/langchain.

Source

Thrown at libs/core/langchain_core/utils/function_calling.py:354

        The function description.
    """
    is_simple_oai_tool = (
        isinstance(tool, langchain_core.tools.simple.Tool) and not tool.args_schema
    )
    if tool.tool_call_schema and not is_simple_oai_tool:
        if isinstance(tool.tool_call_schema, dict):
            return _convert_json_schema_to_openai_function(
                tool.tool_call_schema, name=tool.name, description=tool.description
            )
        if issubclass(tool.tool_call_schema, (BaseModel, BaseModelV1)):
            return _convert_pydantic_to_openai_function(
                tool.tool_call_schema, name=tool.name, description=tool.description
            )
        error_msg = (  # type: ignore[unreachable]
            f"Unsupported tool call schema: {tool.tool_call_schema}. "
            "Tool call schema must be a JSON schema dict or a Pydantic model."
        )
        raise ValueError(error_msg)
    return {
        "name": tool.name,
        "description": tool.description,
        "parameters": {
            # This is a hack to get around the fact that some tools
            # do not expose an args_schema, and expect an argument
            # which is a string.
            # And Open AI does not support an array type for the
            # parameters.
            "properties": {
                "__arg1": {"title": "__arg1", "type": "string"},
            },
            "required": ["__arg1"],
            "type": "object",
        },
    }

View on GitHub (pinned to e32fa9a52e)

Solutions

  1. Provide tool_call_schema as a JSON schema dict or a pydantic.BaseModel subclass.
  2. If the schema is another type (e.g. a dataclass or TypedDict), convert it to a Pydantic model first.

Example fix

tool.tool_call_schema = MyPydanticArgs  # or a JSON schema dict

When it happens

Trigger: Raised when a tool's tool_call_schema is neither a JSON schema dict nor a Pydantic model (e.g. a plain class, TypedDict, or function) during conversion to an OpenAI tool.

Common situations: See trigger scenarios.


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