From 9433afc745f4c262f526997bd40f57975dbc571f Mon Sep 17 00:00:00 2001 From: mykonos-ibiza <222371740+mykonos-ibiza@users.noreply.github.com> Date: Sat, 9 Aug 2025 23:05:07 +0530 Subject: [PATCH] fix: enhance tools parameter handling in agent retrieval - Added support for tools parameter to accept string, dict, or list types. - Implemented logging for unexpected tools parameter types and cases where a dict is received. - Ensured tools filtering is robust and handles various input formats appropriately. --- backend/agent/api.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/agent/api.py b/backend/agent/api.py index cbbb6c7e..17219429 100644 --- a/backend/agent/api.py +++ b/backend/agent/api.py @@ -1384,7 +1384,19 @@ async def get_agents( filtered_agents = [] tools_filter = [] if tools: - tools_filter = [tool.strip() for tool in tools.split(',') if tool.strip()] + # Handle case where tools might be passed as dict instead of string + if isinstance(tools, str): + tools_filter = [tool.strip() for tool in tools.split(',') if tool.strip()] + elif isinstance(tools, dict): + # If tools is a dict, log the issue and skip filtering + logger.warning(f"Received tools parameter as dict instead of string: {tools}") + tools_filter = [] + elif isinstance(tools, list): + # If tools is a list, use it directly + tools_filter = [str(tool).strip() for tool in tools if str(tool).strip()] + else: + logger.warning(f"Unexpected tools parameter type: {type(tools)}, value: {tools}") + tools_filter = [] for agent in agents_data: # Get version data if available and extract configuration