-
Notifications
You must be signed in to change notification settings - Fork 813
Python: Refactor ag-ui to clean up some patterns #2363
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Python Test Coverage Report •
Python Unit Test Overview
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this 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_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
There was a problem hiding this 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.
python/packages/ag-ui/agent_framework_ag_ui/_orchestration/_state_manager.py
Show resolved
Hide resolved
There was a problem hiding this 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.
* Refactor ag-ui to clean up some patterns * Mypy fixes * Fix imports, typing, tests, logging. * Fix test import error * Fix imports again
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