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.
This commit is contained in:
jmaillefaud
2025-07-24 02:28:27 +02:00
committed by GitHub
parent a7d0e42f3f
commit fb5da8384e

View File

@@ -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: