mirror of
https://github.com/hwchase17/langchain.git
synced 2026-02-21 06:33:41 +00:00
fix(core): prevent recursion error when args_schema is dict (#35260)
This commit is contained in:
@@ -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():
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user