@@ -527,7 +527,7 @@ async def _create_structured_plan(
527527 session_id = input_task .session_id ,
528528 user_id = self ._user_id ,
529529 action = "Analyze the task: " + input_task .description ,
530- agent = "GenericAgent" ,
530+ agent = AgentType . GENERIC . value , # Using the correct value from AgentType enum
531531 status = StepStatus .planned ,
532532 human_approval_status = HumanFeedbackStatus .requested ,
533533 timestamp = datetime .datetime .utcnow ().isoformat (),
@@ -692,8 +692,48 @@ def _generate_args(self, objective: str) -> any:
692692 if hasattr (self , "_agent_instances" ) and self ._agent_instances :
693693 # Process each agent to get their tools
694694 for agent_name , agent in self ._agent_instances .items ():
695+ # First try to get tools directly from the agent's corresponding tool class
696+ tools_dict = None
697+
698+ # Try to access plugins property which returns the get_all_kernel_functions result
699+ if hasattr (agent , "plugins" ):
700+ try :
701+ # Access plugins as a property, not a method
702+ tools_dict = agent .plugins
703+ logging .info (f"Got tools dictionary from { agent_name } 's plugins property" )
704+
705+ # Check if tools_dict is a list or a dictionary
706+ if isinstance (tools_dict , list ):
707+ # Convert list to dictionary if needed
708+ tools_dict_converted = {}
709+ for i , func in enumerate (tools_dict ):
710+ func_name = getattr (func , "__name__" , f"function_{ i } " )
711+ tools_dict_converted [func_name ] = func
712+ tools_dict = tools_dict_converted
713+ logging .info (f"Converted tools list to dictionary for { agent_name } " )
714+
715+ except Exception as e :
716+ logging .warning (f"Error accessing plugins property for { agent_name } : { e } " )
717+
718+ # Process tools from tools_dict if available
719+ if tools_dict :
720+ for func_name , func in tools_dict .items ():
721+ # Check if the function has necessary attributes
722+ if hasattr (func , "__name__" ) and hasattr (func , "__doc__" ):
723+ description = func .__doc__ or f"Function { func_name } "
724+
725+ # Create tool entry
726+ tool_entry = {
727+ "agent" : agent_name ,
728+ "function" : func_name ,
729+ "description" : description ,
730+ "arguments" : "{}" , # Default empty dict
731+ }
732+
733+ tools_list .append (tool_entry )
695734
696- if hasattr (agent , "_tools" ) and agent ._tools :
735+ # Fall back to the previous approach if no tools_dict found
736+ elif hasattr (agent , "_tools" ) and agent ._tools :
697737 # Add each tool from this agent
698738 for tool in agent ._tools :
699739 if hasattr (tool , "name" ) and hasattr (tool , "description" ):
0 commit comments