Skip to content

Conversation

@moonbox3
Copy link
Contributor

Motivation and Context

This is a pure refactor of existing functionality for ag-ui. No breaking changes introduced. All integrated features still work - tested with AG-UI's Dojo app along with the getting starter script.

Description

Cleaning up some patterns in ag-ui.

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.

@moonbox3 moonbox3 self-assigned this Nov 21, 2025
Copilot AI review requested due to automatic review settings November 21, 2025 02:43
@markwallace-microsoft
Copy link
Member

markwallace-microsoft commented Nov 21, 2025

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/ag-ui/agent_framework_ag_ui
   _agent.py50394%65, 121, 181
   _endpoint.py410100% 
   _events.py3211894%216, 237, 266, 283, 306, 319, 351, 360–363, 424–425, 429, 490–491, 570, 583
   _orchestrators.py2581893%137, 355, 387, 439–441, 444, 447–448, 452–455, 457–459, 503, 508
packages/ag-ui/agent_framework_ag_ui/_orchestration
   _message_hygiene.py109397%106, 170–171
   _state_manager.py46197%91
   _tooling.py541375%20–22, 29–31, 40–44, 55–56
packages/core/agent_framework
   _agents.py2905182%329, 388–390, 436, 490, 508, 670, 849, 852–854, 983–986, 988, 991–993, 1082, 1123, 1125, 1134–1139, 1145, 1147, 1157–1158, 1165, 1167–1168, 1176–1180, 1188–1189, 1191, 1196, 1198, 1232, 1273–1274, 1276, 1289
TOTAL15594236284% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
2230 130 💤 0 ❌ 0 🔥 53.839s ⏱️

Copilot finished reviewing on behalf of moonbox3 November 21, 2025 02:45
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 refactors the ag-ui package to improve code organization and maintainability by extracting complex orchestration logic into focused, testable modules. No breaking changes are introduced.

Key changes:

  • Extracted message sanitization, deduplication, tool handling, and state management into dedicated modules under _orchestration/
  • Refactored event handling into smaller, more focused methods for better readability
  • Added support for Pydantic models as state schemas
  • Introduced default_state parameter for FastAPI endpoints to seed initial state
  • Converted f-string logging to lazy evaluation format (using % formatting) for better performance

Reviewed Changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/test_tooling.py New tests for tool merging and registration utilities
tests/test_state_manager.py New tests for state initialization, snapshots, and context injection
tests/test_message_hygiene.py New tests for message sanitization and deduplication logic
tests/test_agent_wrapper_comprehensive.py Added test for Pydantic model state schema support
tests/test_endpoint.py Added test for default_state seeding in endpoints
agent_framework_ag_ui/_orchestrators.py Refactored to use extracted orchestration modules; converted to lazy logging
agent_framework_ag_ui/_orchestration/tooling.py New module for server tool collection, client tool registration, and tool merging
agent_framework_ag_ui/_orchestration/state_manager.py New module managing state defaults, snapshots, and structured updates
agent_framework_ag_ui/_orchestration/message_hygiene.py New module for message sanitization and deduplication
agent_framework_ag_ui/_orchestration/__init__.py Module exports for orchestration helpers
agent_framework_ag_ui/_events.py Refactored event handling into smaller methods; converted to lazy logging
agent_framework_ag_ui/_endpoint.py Added default_state parameter with deep copy support for initial state seeding
agent_framework_ag_ui/_agent.py Added Pydantic model support for state_schema with normalization logic

@moonbox3 moonbox3 added the ag-ui label Nov 21, 2025
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

Copilot reviewed 26 out of 26 changed files in this pull request and generated 4 comments.

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@moonbox3 moonbox3 enabled auto-merge November 26, 2025 08:45
@moonbox3 moonbox3 added this pull request to the merge queue Nov 26, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 26, 2025
@moonbox3 moonbox3 added this pull request to the merge queue Nov 26, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 26, 2025
@moonbox3 moonbox3 enabled auto-merge November 26, 2025 23:32
@moonbox3 moonbox3 added this pull request to the merge queue Nov 26, 2025
github-merge-queue bot pushed a commit that referenced this pull request Nov 26, 2025
* Refactor ag-ui to clean up some patterns

* Mypy fixes

* Fix imports, typing, tests, logging.

* Fix test import error

* Fix imports again
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Nov 26, 2025
@moonbox3 moonbox3 added this pull request to the merge queue Nov 27, 2025
Merged via the queue into microsoft:main with commit 8cf8b0f Nov 27, 2025
23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants