@@ -138,51 +138,6 @@ async def async_init(self):
138138 # Tools are registered with the kernel via get_tools_from_config
139139 return self
140140
141- async def invoke_async (self , * args , ** kwargs ):
142- """Invoke this agent asynchronously.
143-
144- This method is required for compatibility with AgentGroupChat.
145-
146- Args:
147- *args: Positional arguments
148- **kwargs: Keyword arguments
149-
150- Returns:
151- The agent's response
152- """
153- # Ensure agent is initialized
154- if self ._agent is None :
155- await self .async_init ()
156-
157- # Get the text input from args or kwargs
158- text = None
159- if args and isinstance (args [0 ], str ):
160- text = args [0 ]
161- elif "text" in kwargs :
162- text = kwargs ["text" ]
163- elif "arguments" in kwargs and hasattr (kwargs ["arguments" ], "get" ):
164- text = kwargs ["arguments" ].get ("text" ) or kwargs ["arguments" ].get ("input" )
165-
166- if not text :
167- settings = kwargs .get ("settings" , {})
168- if isinstance (settings , dict ) and "input" in settings :
169- text = settings ["input" ]
170-
171- # If text is still not found, create a default message
172- if not text :
173- text = "Hello, please assist with a task."
174-
175- # Use the text to invoke the agent
176- try :
177- logging .info (f"Invoking { self ._agent_name } with text: { text [:100 ]} ..." )
178- response = await self ._agent .invoke (
179- self ._kernel , text , settings = kwargs .get ("settings" , {})
180- )
181- return response
182- except Exception as e :
183- logging .error (f"Error invoking { self ._agent_name } : { e } " )
184- return f"Error: { str (e )} "
185-
186141 def _register_functions (self ):
187142 """Register this agent's functions with the kernel."""
188143 # Use the kernel function decorator approach instead of from_native_method
@@ -204,37 +159,6 @@ async def handle_action_request_wrapper(*args, **kwargs):
204159 self ._kernel .add_function (self ._agent_name , kernel_func )
205160
206161 # Required method for AgentGroupChat compatibility
207- async def send_message_async (
208- self , message_content : ChatMessageContent , chat_history : ChatHistory
209- ):
210- """Send a message to the agent asynchronously, adding it to chat history.
211-
212- Args:
213- message_content: The content of the message
214- chat_history: The chat history
215-
216- Returns:
217- None
218- """
219- # Convert message to format expected by the agent
220- if hasattr (message_content , "role" ) and hasattr (message_content , "content" ):
221- self ._chat_history .append (
222- {"role" : message_content .role , "content" : message_content .content }
223- )
224-
225- # If chat history is provided, update our internal history
226- if chat_history and hasattr (chat_history , "messages" ):
227- # Update with the latest messages from chat history
228- for msg in chat_history .messages [
229- - 5 :
230- ]: # Only use last 5 messages to avoid history getting too long
231- if msg not in self ._chat_history :
232- self ._chat_history .append (
233- {"role" : msg .role , "content" : msg .content }
234- )
235-
236- # No need to return anything as we're just updating state
237- return None
238162
239163 async def handle_action_request (self , action_request : ActionRequest ) -> str :
240164 """Handle an action request from another agent or the system.
@@ -274,11 +198,11 @@ async def handle_action_request(self, action_request: ActionRequest) -> str:
274198
275199 try :
276200 # Use the agent to process the action
277- chat_history = self ._chat_history .copy ()
201+ # chat_history = self._chat_history.copy()
278202
279203 # Call the agent to handle the action
280204 async_generator = self ._agent .invoke (
281- self . _kernel , f"{ action_request .action } \n \n Please perform this action"
205+ f"{ action_request .action } \n \n Please perform this action"
282206 )
283207
284208 response_content = ""
0 commit comments