Add created_at to BaseChatMessage and BaseAgentEvent#6557
Add created_at to BaseChatMessage and BaseAgentEvent#6557ekzhu merged 6 commits intomicrosoft:mainfrom
Conversation
|
I think if you need functionality like this then |
|
I think this is fine. |
|
Thanks for feedbacks, @ekzhu and @jackgerrits . Could you please review this PR when you have time? |
There was a problem hiding this comment.
Pull Request Overview
This PR instruments messages and events with a creation timestamp, adjusts tests to ignore that dynamic field, and tidies imports in the user guide.
- Adds a
created_atfield (UTC timezone) to bothBaseChatMessageandBaseAgentEvent - Introduces helper functions (
compare_messages,compare_message_lists,compare_task_results) to compare models without the dynamic timestamp - Updates tests to use those comparators instead of direct equality, and reorders imports in the tutorial notebook
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/models.ipynb | Reordered imports for Path and Image |
| python/packages/autogen-agentchat/src/autogen_agentchat/messages.py | Added created_at: datetime to core message/event models |
| python/packages/autogen-agentchat/tests/utils.py | Created comparison helpers and switched the log handler to use model_dump_json |
python/packages/autogen-agentchat/tests/ (test_group_chat*.py, test_assistant_agent.py, etc.) |
Replaced direct == assertions with compare_messages/compare_task_results |
Comments suppressed due to low confidence (2)
python/packages/autogen-agentchat/src/autogen_agentchat/messages.py:89
- There are no tests verifying the new
created_atfield. Consider adding tests to assert that instances ofBaseChatMessageandBaseAgentEventinclude a timezone-awarecreated_atattribute.
created_at: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
python/packages/autogen-core/docs/src/user-guide/agentchat-user-guide/tutorial/models.ipynb:454
- The tutorial notebook hasn’t been updated to illustrate the new
created_atfield. Consider adding an example that shows how to read or persistcreated_atfromBaseChatMessageandBaseAgentEvent.
"source": [
|
@ekzhu |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #6557 +/- ##
=======================================
Coverage 79.53% 79.54%
=======================================
Files 225 225
Lines 16642 16647 +5
=======================================
+ Hits 13237 13242 +5
Misses 3405 3405
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:
|
Why are these changes needed?
I added
created_atto both BaseChatMessage and BaseAgentEvent classes that store the time these Pydantic model instances are generated. And then users will be able to usecreated_atto build up a customized external persisting state management layer for their case.Related issue number
#6169 (reply in thread)
Checks