Skip to content

Conversation

@moonbox3
Copy link
Contributor

@moonbox3 moonbox3 commented Jan 21, 2026

Motivation and Context

This refactor restructures AG-UI orchestration to reduce bespoke state handling and make the flow maintainable. The existing code was growing in complexity and brittleness; this change consolidates orchestration, simplifies state transitions, and removes ad hoc management paths.

Important

The only breaking change here is we're removing the confirmation strategies - no need for this custom behavior. The confirmation_strategy arg is no longer passed into AgentFrameworkAgent.

Description

Testing:

  • All samples from AG-UI dojo were tested with the AzureOpenAIClient, AnthropicClient, and the AzureAIClient
  • Multiple MCP tools were tested
  • Human-in-the-loop approvals with MCP tools were tested
  • Unit test coverage > 85% for current package

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.

@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Jan 21, 2026

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/ag-ui/agent_framework_ag_ui
   _agent.py36197%62
   _client.py1401192%37, 88–92, 238, 268, 423–425
   _endpoint.py46197%92
   _message_adapters.py4428979%65, 75–76, 85–88, 117–118, 121, 125–127, 136–138, 147–158, 160–162, 192, 205–206, 216–217, 254, 257, 259, 262, 265, 281, 298, 320, 351, 356, 367–368, 419, 435–436, 496–499, 501, 507, 515–516, 518, 522–525, 538, 627–630, 632, 697, 732–734, 736–739, 742–743, 745, 751, 754, 756, 759, 761, 767–768, 770
   _run.py43212171%151–158, 301, 320–321, 336–337, 348, 351–352, 354–355, 357–359, 369, 379–382, 386–388, 390, 400, 403–406, 408–409, 412–418, 421–423, 426, 442–444, 451, 457–458, 460–461, 475–481, 492, 505, 507–508, 542–543, 595–597, 609–611, 635, 640–642, 758, 769–770, 777, 824–826, 841, 847, 855, 857, 893–899, 902–905, 907–916, 919, 926–927, 932, 938–940, 953–955
   _types.py36197%12
packages/ag-ui/agent_framework_ag_ui/_orchestration
   _helpers.py1070100% 
   _tooling.py570100% 
packages/anthropic/agent_framework_anthropic
   _chat_client.py36215158%51, 362, 385, 387, 402, 424–427, 436, 438, 469–473, 475, 477–478, 480, 485–486, 488, 521–522, 531, 533–534, 539, 556–557, 599, 614, 618–619, 635, 644, 646, 650–651, 694–696, 698, 711–712, 719–721, 725–727, 731–734, 745, 747, 769, 779, 801–807, 814–815, 823–824, 832–835, 842–843, 849–850, 856–857, 863, 871–873, 877, 884–885, 891–892, 898–899, 905, 913–916, 923–924, 943, 950–951, 970, 992, 994, 1003–1004, 1010, 1032–1033, 1039–1040, 1049–1059, 1066–1072, 1079–1085, 1092–1101, 1108–1111
packages/core/agent_framework
   _agents.py2995282%51, 90, 98, 101, 104, 406–408, 454, 636, 805, 808–810, 928–930, 935–937, 1038, 1079, 1081, 1090–1095, 1101, 1103, 1113–1114, 1121, 1123–1124, 1132–1136, 1144–1145, 1147, 1152, 1154, 1188, 1233–1234, 1236, 1238, 1249
   _tools.py7707490%226, 272, 323, 325, 353, 523, 555–556, 658, 660, 680, 698, 712, 724, 729, 731, 738, 771, 827–829, 870, 895–904, 910–919, 955, 965, 1206, 1543, 1629–1633, 1772, 1774, 1840, 1932, 1938, 1980–1981, 1994–1995, 2038, 2122, 2160–2161, 2200–2202, 2240–2241, 2251, 2308–2309, 2316–2317
TOTAL17006264984% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
3229 213 💤 0 ❌ 0 🔥 1m 4s ⏱️

@moonbox3 moonbox3 added the breaking change Introduces changes that are not backward compatible and may require updates to dependent code. label Jan 21, 2026
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 performs a major refactoring of the AG-UI orchestration system to simplify the run logic and fix several bugs. The changes consolidate orchestration into a single linear flow in _run.py, removing the complex orchestrator pattern and confirmation strategies.

Changes:

  • Simplified orchestration by consolidating into a single run_agent_stream() function in _run.py
  • Fixed Anthropic client bug where empty text content was causing API errors
  • Fixed MCP tool approval handling by ensuring approval tools are properly passed to the execution handler
  • Removed confirmation strategies (BREAKING CHANGE)

Reviewed changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
python/packages/core/agent_framework/_tools.py Added debug logging and fixed conversation_id filtering in tool invocation
python/packages/core/agent_framework/_agents.py Added tool deduplication by name when merging options
python/packages/anthropic/agent_framework_anthropic/_chat_client.py Fixed empty text content handling and added conversation_id to ignored options
python/packages/ag-ui/agent_framework_ag_ui/_run.py New 949-line orchestration implementation replacing orchestrators
python/packages/ag-ui/agent_framework_ag_ui/_orchestration/_tooling.py Fixed approval tool detection to ensure tools are passed when needed
python/packages/ag-ui/agent_framework_ag_ui/_agent.py Simplified to use new run_agent_stream() function
python/packages/ag-ui/agent_framework_ag_ui/__init__.py Removed confirmation strategy exports
python/packages/ag-ui/agent_framework_ag_ui_examples/agents/ Removed confirmation_strategy parameters from agent examples
Multiple test files Removed obsolete tests and added new tests for simplified architecture

@moonbox3 moonbox3 moved this to In Review in Agent Framework Jan 21, 2026
@markwallace-microsoft markwallace-microsoft added the documentation Improvements or additions to documentation label Jan 22, 2026
@moonbox3 moonbox3 added this pull request to the merge queue Jan 23, 2026
Merged via the queue into microsoft:main with commit 5436354 Jan 23, 2026
25 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Done in Agent Framework Jan 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ag-ui breaking change Introduces changes that are not backward compatible and may require updates to dependent code. documentation Improvements or additions to documentation python

Projects

Status: Done

4 participants