Repository navigation
Python: Normalize naive timestamps to UTC in checkpoint selection - #9944
Hardik K (hardikkaurani) wants to merge 2 commits into
Conversation
…t_latest_checkpoint Normalize ISO 8601 timestamps without timezone offsets to UTC when selecting the latest checkpoint, preventing TypeError when comparing offset-naive and offset-aware datetimes across saved checkpoints. Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
…ware timestamps Add parameterized regression tests for InMemoryCheckpointStorage and FileCheckpointStorage verifying that get_latest correctly selects the newest checkpoint when storages contain a mixture of naive and timezone-aware timestamps without raising TypeError. Signed-off-by: Hardik Kaurani <hardikkaurani1@gmail.com>
|
/review |
There was a problem hiding this comment.
MAF Automated Review — Iteration 1
Result: No findings
Scope: full PR (2 commit(s)): 8cbe2a6de527, f935ace732cb
Model: gpt-5.6-sol
Overview
The PR narrowly normalizes offset-naive checkpoint timestamps to UTC before comparison while preserving aware-offset ordering and the existing lineage/ID tie-breakers. The regression test covers both core storage implementations and verifies both aware-newer and naive-newer selection. No publishable defect was established in the changed core path.
Reviewed the supplied pull-request change set across correctness, security/reliability, architecture, and failure behavior.
No publishable findings remained after source verification for this scope.
|
/review |
|
Hi Eduard van Valkenburg (@eavanvalkenburg), The merge queue run 41804121496 failed due to a pytest-xdist worker crash ( I've rebased the branch onto the latest Could you please re-add this PR to the merge queue when you have a moment? Thank you! |
Motivation & Context
In
agent-framework(Python workflows),WorkflowCheckpoint.timestampis an ISO 8601 timestamp string. While default timestamps generated byWorkflowCheckpointinclude timezone information (UTC), timestamps supplied externally or written by tools can be offset-naive (e.g."2026-01-01T00:00:00").When
storage.get_latestevaluates candidate checkpoints,_select_latest_checkpointpreviously invokeddatetime.fromisoformat(cp.timestamp)directly insidemax(...). In Python, comparing an offset-naive datetime with an offset-aware datetime raises:This caused
get_latestto fail unexpectedly whenever a storage held a combination of naive and timezone-aware timestamps.Description & Review Guide
What are the major changes?
_parse_checkpoint_timestamphelper in_workflows/_checkpoint.pywhich normalizes naive timestamps by assigningtimezone.utc._select_latest_checkpointto use_parse_checkpoint_timestampformax(...)timestamp calculation and candidate filtering.InMemoryCheckpointStorageandFileCheckpointStorageinpackages/core/tests/workflow/test_checkpoint.pyverifying thatget_latestselects the newest checkpoint without raisingTypeError.What is the impact of these changes?
TypeErrorwhen selecting latest checkpoints across mixed timestamp formats.Related Issue
Fixes #9941
AI Assistance
Contribution Checklist
cc Eduard van Valkenburg (@eavanvalkenburg)