Skip to content

Commit e6f9a47

Browse files
committed
agent invoke parameter no working
1 parent 230f977 commit e6f9a47

File tree

2 files changed

+8
-84
lines changed

2 files changed

+8
-84
lines changed

src/backend/kernel_agents/agent_base.py

Lines changed: 2 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -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\nPlease perform this action"
205+
f"{action_request.action}\n\nPlease perform this action"
282206
)
283207

284208
response_content = ""

src/backend/kernel_agents/group_chat_manager.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ class Step(BaseDataModel):
247247
step.human_approval_status = HumanFeedbackStatus.rejected
248248
self._memory_store.update_step(step)
249249
track_event_if_configured(
250-
"Group Chat Manager - Step has been rejected and updated into the cosmos",
250+
f"{AgentType.GROUP_CHAT_MANAGER.value} - Step has been rejected and updated into the cosmos",
251251
{
252252
"status": StepStatus.rejected,
253253
"session_id": message.session_id,
@@ -272,7 +272,7 @@ async def _update_step_status(
272272
step.status = StepStatus.completed
273273
await self._memory_store.update_step(step)
274274
track_event_if_configured(
275-
"Group Chat Manager - Received human feedback, Updating step and updated into the cosmos",
275+
f"{AgentType.GROUP_CHAT_MANAGER.value} - Received human feedback, Updating step and updated into the cosmos",
276276
{
277277
"status": StepStatus.completed,
278278
"session_id": step.session_id,
@@ -290,7 +290,7 @@ async def _execute_step(self, session_id: str, step: Step):
290290
step.status = StepStatus.action_requested
291291
await self._memory_store.update_step(step)
292292
track_event_if_configured(
293-
"Group Chat Manager - Update step to action_requested and updated into the cosmos",
293+
f"{AgentType.GROUP_CHAT_MANAGER.value} - Update step to action_requested and updated into the cosmos",
294294
{
295295
"status": StepStatus.action_requested,
296296
"session_id": step.session_id,
@@ -317,7 +317,7 @@ async def _execute_step(self, session_id: str, step: Step):
317317
if step.id == current_step_id:
318318
break
319319
formatted_string += f"Step {i}\n"
320-
formatted_string += f"Group chat manager: {step.action}\n"
320+
formatted_string += f"{AgentType.GROUP_CHAT_MANAGER.value}: {step.action}\n"
321321
formatted_string += f"{step.agent.name}: {step.agent_reply}\n"
322322
formatted_string += "<conversation_history \\>"
323323

@@ -353,13 +353,13 @@ async def _execute_step(self, session_id: str, step: Step):
353353
)
354354

355355
track_event_if_configured(
356-
f"Group Chat Manager - Requesting {formatted_agent} to perform the action and added into the cosmos",
356+
f"{AgentType.GROUP_CHAT_MANAGER.value} - Requesting {formatted_agent} to perform the action and added into the cosmos",
357357
{
358358
"session_id": session_id,
359359
"user_id": self._user_id,
360360
"plan_id": step.plan_id,
361361
"content": f"Requesting {formatted_agent} to perform action: {step.action}",
362-
"source": "GroupChatManager",
362+
"source": AgentType.GROUP_CHAT_MANAGER.value,
363363
"step_id": step.id,
364364
},
365365
)

0 commit comments

Comments
 (0)