Python: Refactor ag-ui to clean up some patterns#2363
Merged
moonbox3 merged 9 commits intomicrosoft:mainfrom Nov 27, 2025
Merged
Python: Refactor ag-ui to clean up some patterns#2363moonbox3 merged 9 commits intomicrosoft:mainfrom
moonbox3 merged 9 commits intomicrosoft:mainfrom
Conversation
Member
Python Test Coverage Report •
Python Unit Test Overview
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
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_stateparameter 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 |
python/packages/ag-ui/agent_framework_ag_ui/_orchestration/__init__.py
Outdated
Show resolved
Hide resolved
dmytrostruk
reviewed
Nov 21, 2025
python/packages/ag-ui/agent_framework_ag_ui/_orchestration/_state_manager.py
Show resolved
Hide resolved
eavanvalkenburg
approved these changes
Nov 25, 2025
dmytrostruk
approved these changes
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
dmytrostruk
approved these changes
Nov 27, 2025
arisng
pushed a commit
to arisng/agent-framework
that referenced
this pull request
Feb 2, 2026
* Refactor ag-ui to clean up some patterns * Mypy fixes * Fix imports, typing, tests, logging. * Fix test import error * Fix imports again * Fix thread handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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