JetBrainsTypeHierarchyTool: Return supertypes/subtypes keys even if empty,

because LLM otherwise thinks the retrieval failed and retries
  (with different parameters)
This commit is contained in:
Dominik Jain authored and Dominik Jain committed 2025-12-28 12:48:30 +01:00
1 parent bd26cbd381
commit 4d1d2561cf
1 file changed
+4 -4
+4 -4
View File
@@ -184,8 +184,8 @@ class JetBrainsTypeHierarchyTool(Tool, ToolMarkerSymbolicRead, ToolMarkerOptiona
:return: Compact JSON with file-grouped hierarchy. Error string if not applicable.
"""
with JetBrainsPluginClient.from_project(self.project) as client:
subtypes = {}
supertypes = {}
subtypes = None
supertypes = None
if hierarchy_type in ("super", "both"):
supertypes_response = client.get_supertypes(
name_path=name_path,
@@ -211,9 +211,9 @@ class JetBrainsTypeHierarchyTool(Tool, ToolMarkerSymbolicRead, ToolMarkerOptiona
symbol_compact = {symbol["relative_path"]: [symbol["name_path"]]}
result_dict: dict[str, dict | list] = {"symbol": symbol_compact}
if supertypes:
if supertypes is not None:
result_dict["supertypes"] = supertypes
if subtypes:
if subtypes is not None:
result_dict["subtypes"] = subtypes
result = self._to_json(result_dict)