Skip to content

Commit 3f053ee

Browse files
author
alliscode
committed
Fix GroupChat orchestrator message cleanup issue
Apply clean_conversation_for_handoff to GroupChatOrchestrator and AgentBasedGroupChatOrchestrator _handle_response methods to remove tool-related content that causes API errors from empty messages. Fixes microsoft#3705
1 parent 98cd728 commit 3f053ee

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎python/packages/core/agent_framework/_workflows/_group_chat.py‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
from ._conversation_state import decode_chat_messages, encode_chat_messages
4848
from ._executor import Executor
4949
from ._orchestration_request_info import AgentApprovalExecutor
50+
from ._orchestrator_helpers import clean_conversation_for_handoff
5051
from ._workflow import Workflow
5152
from ._workflow_builder import WorkflowBuilder
5253
from ._workflow_context import WorkflowContext
@@ -193,6 +194,8 @@ async def _handle_response(
193194
) -> None:
194195
"""Handle a participant response."""
195196
messages = self._process_participant_response(response)
197+
# Remove tool-related content to prevent API errors from empty messages
198+
messages = clean_conversation_for_handoff(messages)
196199
self._append_messages(messages)
197200

198201
if await self._check_terminate_and_yield(cast(WorkflowContext[Never, list[ChatMessage]], ctx)):
@@ -360,6 +363,8 @@ async def _handle_response(
360363
) -> None:
361364
"""Handle a participant response."""
362365
messages = self._process_participant_response(response)
366+
# Remove tool-related content to prevent API errors from empty messages
367+
messages = clean_conversation_for_handoff(messages)
363368
self._append_messages(messages)
364369
if await self._check_terminate_and_yield(cast(WorkflowContext[Never, list[ChatMessage]], ctx)):
365370
return

0 commit comments

Comments
 (0)