-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Fix JSON serialization of team state by handling datetime objects in message dump #6797
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
Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
|
Add a unit test to validate the change. |
Co-authored-by: ekzhu <320302+ekzhu@users.noreply.github.com>
Added comprehensive unit test Warning Firewall rules blocked me from connecting to one or more addressesI tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6797 +/- ##
=======================================
Coverage 80.40% 80.40%
=======================================
Files 233 233
Lines 17904 17904
=======================================
Hits 14395 14395
Misses 3509 3509
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Problem
When saving team state to JSON, users encountered a serialization error due to datetime objects in messages:
The issue occurred because
BaseChatMessageandBaseAgentEventclasses both have acreated_atfield of typedatetime, which is not JSON serializable by default.Solution
Changed the
BaseMessage.dump()method to use Pydantic's JSON-aware serialization mode:This leverages Pydantic's built-in capability to automatically convert datetime objects to ISO 8601 format strings during serialization.
Benefits
Testing
Verified the fix with comprehensive tests covering:
Example of working code after the fix:
Fixes #6793.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.