Skip to content

Conversation

@cleemullins
Copy link
Collaborator

@cleemullins cleemullins commented Oct 13, 2025

Fixes #165

The File Logger was incorrectly converting datetimes to strings as part of dealing with activty processing. Removed the not-needed conversion (string to datetime) to cleanup the underlying code and tests.

The logged warnings looked like:

tests/hosting_core/storage/test_file_transcript_storage.py::test_delete_transcript_removes_file
  D:\git\Agents-for-python\venv\Lib\site-packages\pydantic\main.py:528: UserWarning: Pydantic serializer warnings:
    PydanticSerializationUnexpectedValue(Expected `datetime` - serialized value may not be as expected [field_name='timestamp', input_value='2025-10-13T21:52:01.399099+00:00', input_type=str])
    return self.__pydantic_serializer__.to_json(

This fix is part of my ongoing effort to cleanup all the broken windows in our build and test system.

@cleemullins cleemullins changed the title Refactor timestamp handling in FileTranscriptStore and update related tests for consistency Refactor datetime handling in FileTranscriptStore to eliminate strings Oct 13, 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

This PR refactors datetime handling in the FileTranscriptStore to eliminate unnecessary string conversions that were causing Pydantic serialization warnings. The fix ensures datetime objects are used consistently instead of converting them to ISO string format unnecessarily.

  • Removed the _utc_iso_now() helper function that returned ISO string format
  • Updated log_activity() to set timestamps as datetime objects directly
  • Fixed test code to use datetime objects instead of ISO strings

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
libraries/microsoft-agents-hosting-core/microsoft_agents/hosting/core/storage/transcript_file_store.py Removed string conversion helper and updated timestamp assignment to use datetime objects
tests/hosting_core/storage/test_file_transcript_storage.py Updated test variables to use datetime objects instead of ISO strings

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@cleemullins cleemullins requested a review from axelsrz October 13, 2025 23:02
@cleemullins cleemullins self-assigned this Oct 13, 2025
@cleemullins cleemullins added the P1 label Oct 13, 2025
@cleemullins cleemullins enabled auto-merge (squash) October 13, 2025 23:09
@cleemullins cleemullins merged commit 7cde971 into main Oct 14, 2025
8 checks passed
@cleemullins cleemullins deleted the users/cleemullins/FixIncorrectTimeSerializationWarnings branch October 14, 2025 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pydantic serialization issues around timestamp

3 participants