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.
This commit is contained in:
mykonos-ibiza 2025-08-09 23:05:07 +05:30
parent 5d56125d2c
commit 9433afc745
1 changed files with 13 additions and 1 deletions

View File

@ -1384,7 +1384,19 @@ async def get_agents(
filtered_agents = []
tools_filter = []
if tools:
# 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