fix(core): prevent recursion error when args_schema is dict (#35260)

This commit is contained in:
KarthikRed2000
2026-02-17 16:47:17 -06:00
committed by GitHub
parent 0d13463e7f
commit a565cf85eb
2 changed files with 7 additions and 2 deletions

View File

@@ -819,7 +819,8 @@ class ChildTool(BaseTool):
filtered_keys.update(self._injected_args_keys)
# If we have an args_schema, use it to identify injected args
if self.args_schema is not None:
# Skip if args_schema is a dict (JSON Schema) as it's not a Pydantic model
if self.args_schema is not None and not isinstance(self.args_schema, dict):
try:
annotations = get_all_basemodel_annotations(self.args_schema)
for field_name, field_type in annotations.items():

View File

@@ -2,6 +2,7 @@
import inspect
import json
import logging
import sys
import textwrap
import threading
@@ -2632,7 +2633,8 @@ def test_tool_mutate_input() -> None:
assert my_input == {"x": "hi"}
def test_structured_tool_args_schema_dict() -> None:
def test_structured_tool_args_schema_dict(caplog: pytest.LogCaptureFixture) -> None:
caplog.set_level(logging.DEBUG)
args_schema = {
"properties": {
"a": {"title": "A", "type": "integer"},
@@ -2666,6 +2668,8 @@ def test_structured_tool_args_schema_dict() -> None:
"a": {"title": "A", "type": "integer"},
"b": {"title": "B", "type": "integer"},
}
# test that we didn't log an error about failing to get args_schema annotations
assert "Failed to get args_schema annotations for filtering" not in caplog.text
def test_simple_tool_args_schema_dict() -> None: