From 64e19d62ac52fa93e6015a0862fbc4d355a9286d Mon Sep 17 00:00:00 2001 From: Sanjusha_tridz Date: Thu, 19 Feb 2026 05:39:08 +0000 Subject: [PATCH] fix: use parameter description in generated tool JSON -Previously, the tool schema generation relied solely on the 'label' field, ignoring the 'description' field in the parameters table. -This change updates 'prepare_function_params' and 'build_params_json_from_table' to prioritize 'param.description'. It now falls back to 'param.label' only if the description is empty. This ensures the AI agent receives more accurate context for function arguments. --- .../agent_tool_function/agent_tool_function.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/huf/huf/doctype/agent_tool_function/agent_tool_function.py b/huf/huf/doctype/agent_tool_function/agent_tool_function.py index 854cde8a..a3c5ac86 100644 --- a/huf/huf/doctype/agent_tool_function/agent_tool_function.py +++ b/huf/huf/doctype/agent_tool_function/agent_tool_function.py @@ -107,7 +107,7 @@ def prepare_function_params(self): for param in self.parameters: properties[param.fieldname] = { "type": param.type, - "description": param.label, + "description": param.description or param.label, } params = { @@ -205,7 +205,7 @@ def prepare_function_params(self): for param in self.parameters: properties[param.fieldname] = { "type": "string", - "description": f"File URL/Path for field '{param.label or param.fieldname}'" + "description": param.description or f"File URL/Path for field '{param.label or param.fieldname}'" } else: properties["file_url"] = { @@ -230,7 +230,7 @@ def prepare_function_params(self): for param in self.parameters: filter_properties[param.fieldname] = { "type": param.type, - "description": param.label or f"Filter by {param.fieldname}" + "description": param.description or param.label or f"Filter by {param.fieldname}" } params = { @@ -335,7 +335,7 @@ def prepare_function_params(self): query_required = [] for param in self.parameters: - field_schema = {"type": param.type, "description": param.label} + field_schema = {"type": param.type, "description": param.description or param.label} if param.type == "string" and param.options: field_schema["enum"] = param.options.split("\n") @@ -368,7 +368,7 @@ def prepare_function_params(self): body_required = [] for param in self.parameters: - field_schema = {"type": param.type, "description": param.label} + field_schema = {"type": param.type, "description": param.description or param.label} if param.type == "string" and param.options: field_schema["enum"] = param.options.split("\n") @@ -520,7 +520,7 @@ def build_params_json_from_table(self): for param in self.parameters: obj = { "type": param.type, - "description": param.label, + "description": param.description or param.label, } # Explicitly allow any keys/values for object types