@@ -457,11 +457,11 @@ async def kernel_wrapper(kernel_arguments: KernelArguments = None, **kwargs) ->
457457 return kernel_wrapper
458458
459459 @staticmethod
460- def load_tools_config (agent_type : str , config_path : Optional [str ] = None ) -> Dict [str , Any ]:
460+ def load_tools_config (filename : str , config_path : Optional [str ] = None ) -> Dict [str , Any ]:
461461 """Load tools configuration from a JSON file.
462462
463463 Args:
464- agent_type : The type of agent (e.g., "marketing ", "hr ")
464+ filename : The filename without extension (e.g., "hr ", "marketing ")
465465 config_path: Optional explicit path to the configuration file
466466
467467 Returns:
@@ -471,16 +471,26 @@ def load_tools_config(agent_type: str, config_path: Optional[str] = None) -> Dic
471471 # Default path relative to the tools directory
472472 current_dir = os .path .dirname (os .path .abspath (__file__ ))
473473 backend_dir = os .path .dirname (current_dir ) # Just one level up to get to backend dir
474- config_path = os .path .join (backend_dir , "tools" , f"{ agent_type } _tools.json" )
474+
475+ # Normalize filename to avoid issues with spaces and capitalization
476+ # Convert "Hr Agent" to "hr" and "TechSupport Agent" to "tech_support"
477+ logging .debug (f"Normalizing filename: { filename } " )
478+ normalized_filename = filename .replace (" " , "_" ).replace ("-" , "_" ).lower ()
479+ # If it ends with "_agent", remove it
480+ if normalized_filename .endswith ("_agent" ):
481+ normalized_filename = normalized_filename [:- 6 ]
482+ logging
483+ config_path = os .path .join (backend_dir , "tools" , f"{ normalized_filename } _tools.json" )
484+ logging .debug (f"Looking for tools config at: { config_path } " )
475485
476486 try :
477487 with open (config_path , "r" ) as f :
478488 return json .load (f )
479489 except Exception as e :
480- logging .error (f"Error loading { agent_type } tools configuration: { e } " )
490+ logging .error (f"Error loading { filename } tools configuration: { e } " )
481491 # Return empty default configuration
482492 return {
483- "agent_name" : f"{ agent_type .capitalize ()} Agent" ,
493+ "agent_name" : f"{ filename .capitalize ()} Agent" ,
484494 "system_message" : "You are an AI assistant" ,
485495 "tools" : []
486496 }
0 commit comments