From c55294ecb01ac23658cf6accc842e7f2d6e2250a Mon Sep 17 00:00:00 2001 From: ccurme Date: Mon, 28 Jul 2025 14:27:24 -0300 Subject: [PATCH] chore(core): add test for nested pydantic fields in schemas (#32285) --- libs/core/tests/unit_tests/test_tools.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libs/core/tests/unit_tests/test_tools.py b/libs/core/tests/unit_tests/test_tools.py index 748523e5ef9..57b4573d70d 100644 --- a/libs/core/tests/unit_tests/test_tools.py +++ b/libs/core/tests/unit_tests/test_tools.py @@ -2586,6 +2586,18 @@ def test_title_property_preserved() -> None: } +def test_nested_pydantic_fields() -> None: + class Address(BaseModel): + street: str + + class Person(BaseModel): + name: str + address: Address = Field(description="Home address") + + result = convert_to_openai_tool(Person) + assert len(result["function"]["parameters"]["properties"]) == 2 + + async def test_tool_ainvoke_does_not_mutate_inputs() -> None: """Verify that the inputs are not mutated when invoking a tool asynchronously."""