Skip to content

Python: Fix GroupChat orchestrator message cleanup issue#3712

Merged
moonbox3 merged 4 commits intomicrosoft:mainfrom
alliscode:investigation/issue-3705-1770327487
Feb 6, 2026
Merged

Python: Fix GroupChat orchestrator message cleanup issue#3712
moonbox3 merged 4 commits intomicrosoft:mainfrom
alliscode:investigation/issue-3705-1770327487

Conversation

@alliscode
Copy link
Member

@alliscode alliscode commented Feb 5, 2026

Apply clean_conversation_for_handoff to GroupChatOrchestrator and AgentBasedGroupChatOrchestrator _handle_response methods to remove tool-related content that causes API errors from empty messages.

Moves remaining orchestration-related files to the orchestrations package (were previously missed in the original PR to move things).

Fixes #3705

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

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
@github-actions github-actions bot changed the title Fix GroupChat orchestrator message cleanup issue Python: Fix GroupChat orchestrator message cleanup issue Feb 5, 2026
…-3705-1770327487

# Conflicts:
#	python/packages/orchestrations/agent_framework_orchestrations/_group_chat.py
@alliscode alliscode marked this pull request as ready for review February 5, 2026 23:25
Copilot AI review requested due to automatic review settings February 5, 2026 23:25
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Feb 5, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/orchestrations/agent_framework_orchestrations
   _base_group_chat_orchestrator.py1701292%135, 301, 316, 350–352, 356, 375, 436, 480–482
   _concurrent.py1933084%52, 61–62, 70–71, 90–91, 96, 123, 128, 133–134, 140, 162, 172, 179, 347, 350, 378, 434, 446, 485, 487–488, 490, 502–503, 508, 530, 534
   _group_chat.py2943986%173, 336, 343, 372, 383–384, 390, 395, 411, 438–443, 445, 478–481, 483, 488–492, 656, 661, 675, 756, 762, 808, 828, 903–904, 938, 957, 976, 986
   _handoff.py3835785%110–111, 113, 142–143, 165–175, 177, 179, 181, 186, 286, 340, 365, 393, 401–402, 416, 465–466, 498, 545–547, 734, 741, 746, 833, 836, 845–848, 858, 863, 870, 876–879, 914, 919, 1116, 1119, 1127, 1145, 1152, 1227
   _magentic.py6209185%67–76, 81, 85–96, 261, 272, 276, 296, 357, 366, 368, 410, 427, 436–437, 439–441, 443, 454, 596, 598, 638, 686, 722–724, 726, 734–737, 741–744, 787, 814–817, 908, 914, 920, 959, 997, 1026, 1043, 1054, 1108–1109, 1113–1115, 1139, 1160–1161, 1174, 1190, 1212, 1260–1261, 1299–1300, 1459, 1468, 1471, 1476, 1872, 1927, 1942, 1971
   _orchestration_request_info.py540100% 
   _orchestration_state.py28582%20, 28, 68, 85–86
   _orchestrator_helpers.py21290%90–91
   _sequential.py1141487%74, 167, 185, 196, 202, 239, 241–242, 244, 256–257, 262, 284, 288
TOTAL16518200687% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3911 225 💤 0 ❌ 0 🔥 1m 5s ⏱️

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where group chat orchestrators fail with API errors due to empty messages when tool-related content is not properly cleaned from the conversation history. The fix applies the existing clean_conversation_for_handoff utility function to remove tool calls, tool responses, and function approval requests before appending messages to the conversation history or broadcasting them to participants.

Changes:

  • Import clean_conversation_for_handoff from _orchestrator_helpers module
  • Apply message cleaning in GroupChatOrchestrator._handle_response after processing participant responses
  • Apply the same cleaning in AgentBasedGroupChatOrchestrator._handle_response for consistency

@moonbox3 moonbox3 added the agent orchestration Issues related to agent orchestration label Feb 6, 2026
@moonbox3 moonbox3 added this pull request to the merge queue Feb 6, 2026
Merged via the queue into microsoft:main with commit c609b14 Feb 6, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent orchestration Issues related to agent orchestration python

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Python: [Bug]: Group Chat orchestrator message cleanup issue

4 participants