Skip to content

bug[core]: fix tool descriptions when BaseModels have no docstring #31606

Open
@ccurme

Description

@ccurme

Privileged issue

  • I am a LangChain maintainer, or was asked directly by a LangChain maintainer to create an issue here.

Issue Content

When Pydantic models are cast to BaseTool and are missing a docstring, we use the docstring for BaseModel itself:

from langchain_core.tools import tool
from pydantic import BaseModel


@tool
class MyTool(BaseModel):
    foo: str


MyTool.description

'!!! abstract "Usage Documentation"\n Models\n\nA base class for creating Pydantic models.\n\nAttributes:\n class_vars: The names of the class variables defined on the model.\n private_attributes: Metadata about...'

We should use an empty string in this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Ɑ: coreRelated to langchain-core🤖:bugRelated to a bug, vulnerability, unexpected error with an existing feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions