From fb5da8384e636db91b0313cab3cc21b661889684 Mon Sep 17 00:00:00 2001 From: jmaillefaud Date: Thu, 24 Jul 2025 02:28:27 +0200 Subject: [PATCH] fix(core): Dereference Refs for pydantic schema fails in tool schema generation (#32203) The `_dereference_refs_helper` in `langchain_core.utils.json_schema` incorrectly handled objects with a reference and other fields. **Issue**: #32170 # Description We change the check so that it accepts other keys in the object. --- libs/core/langchain_core/utils/json_schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/core/langchain_core/utils/json_schema.py b/libs/core/langchain_core/utils/json_schema.py index 0b738e04a0c..70cea60d094 100644 --- a/libs/core/langchain_core/utils/json_schema.py +++ b/libs/core/langchain_core/utils/json_schema.py @@ -55,7 +55,7 @@ def _dereference_refs_helper( processed_refs = set() # 1) Pure $ref node? - if isinstance(obj, dict) and set(obj.keys()) == {"$ref"}: + if isinstance(obj, dict) and "$ref" in set(obj.keys()): ref_path = obj["$ref"] # cycle? if ref_path in processed_refs: