Python: get_latest timestamp ties return a checkpoint chosen by save order, can restore stale state
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
Research direction
Start by locating InMemoryCheckpointStorage.get_latest and FileCheckpointStorage.get_latest, then read the WorkflowCheckpoint docstring, especially iteration_count and previous_checkpoint_id. Verify behavior with identical timestamps saved in both orders; done means the checkpoint not superseded in the lineage chain is selected consistently, regardless of save order.
Written by the indexing model from the issue text.
Description
Description
InMemoryCheckpointStorage.get_latest picks max() by timestamp alone. Checkpoints at the same superstep boundary legitimately carry identical timestamps (the WorkflowCheckpoint docstring on iteration_count says so explicitly), and datetime.now() resolution means even distinct boundaries can collide. When timestamps tie, max() returns whichever checkpoint the dict iterates first, so the result depends on save order:
storage = InMemoryCheckpointStorage()
parent = WorkflowCheckpoint(workflow_name="w", graph_signature_hash="h", checkpoint_id="parent", timestamp=ts)
child = WorkflowCheckpoint(workflow_name="w", graph_signature_hash="h", checkpoint_id="child", timestamp=ts, previous_checkpoint_id="parent")
# save parent then child -> get_latest returns parent
# save child then parent -> get_latest returns child
A workflow resuming via get_latest can therefore restore the stale checkpoint, with no error anywhere.
FileCheckpointStorage.get_latest has the same timestamp-only max(); it happens to mask the issue via list ordering, but the same identical-timestamp input can pick the wrong one.
The checkpoint docstring itself says ordering is defined by the previous_checkpoint_id lineage chain, not timestamps alone.
Expected behavior
Ties on timestamp resolve through the lineage chain: the checkpoint that no other checkpoint supersedes is the latest, regardless of save order.
Environment
agent-framework python main (astryx-era clone from this week), Python 3.12
- Dominant language
- Python
- Stars
- 13.6k
- Forks
- 2.3k
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 342
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/agent-framework
-
python triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
microsoft/agent-framework#8523 · 1 comment ·
-
.NET compaction documentation
Difficulty 1/5 Under an hour Newbie friendliness 82/100
microsoft/agent-framework#4629 · 1 comment ·
-
harness python reproduced
microsoft/agent-framework#8567 · 2 comments · 1 assignee ·
-
.NET agents reproduced
microsoft/agent-framework#8566 · 1 comment · 1 assignee ·
-
.NET agents python
microsoft/agent-framework#8562 · 1 assignee ·
All issues in microsoft/agent-framework
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100