The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
fix: fixing missing Docstring Bug if no Docstring is provided in BaseModel class (#31608)
Mohammad Mohtashim96bf8262e2ac
diff --git a/libs/core/langchain_core/tools/structured.py b/libs/core/langchain_core/tools/structured.pyindex 4e202dfea3..b3856ea484 100644--- a/libs/core/langchain_core/tools/structured.py+++ b/libs/core/langchain_core/tools/structured.py@@ -197,7 +197,14 @@ class StructuredTool(BaseTool):description_ = source_function.__doc__ or Noneif description_ is None and args_schema:if isinstance(args_schema, type) and is_basemodel_subclass(args_schema):- description_ = args_schema.__doc__ or None+ description_ = args_schema.__doc__+ if (+ description_+ and "A base class for creating Pydantic models" in description_+ ):+ description_ = ""+ elif not description_:+ description_ = Noneelif isinstance(args_schema, dict):description_ = args_schema.get("description")else:diff --git a/libs/core/tests/unit_tests/test_tools.py b/libs/core/tests/unit_tests/test_tools.pyindex f5cc42e1b4..748523e5ef 100644--- a/libs/core/tests/unit_tests/test_tools.py+++ b/libs/core/tests/unit_tests/test_tools.py@@ -701,6 +701,12 @@ def test_missing_docstring() -> None:def search_api(query: str) -> str:return "API result"+ @tool+ class MyTool(BaseModel):+ foo: str++ assert MyTool.description == "" # type: ignore[attr-defined]+def test_create_tool_positional_args() -> None:"""Test that positional arguments are allowed."""