From 022aba2f1bccb9a2992eb08824caab363db7396c Mon Sep 17 00:00:00 2001 From: DZH166 <248446924+DZH166@users.noreply.github.com> Date: Sun, 15 Nov 2026 05:20:23 +0800 Subject: [PATCH] Python: resolve checkpoint timestamp ties in the approval resume test --- .../declarative/tests/test_invoke_mcp_tool_executor.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/python/packages/declarative/tests/test_invoke_mcp_tool_executor.py b/python/packages/declarative/tests/test_invoke_mcp_tool_executor.py index 8e03b626f28..d4e169ed3a6 100644 --- a/python/packages/declarative/tests/test_invoke_mcp_tool_executor.py +++ b/python/packages/declarative/tests/test_invoke_mcp_tool_executor.py @@ -455,7 +455,13 @@ def build(): assert "context-second" not in repr(checkpoints) assert "context-first" not in repr(approval.data) assert "context-second" not in repr(approval.data) - checkpoint = max(checkpoints, key=lambda item: item.timestamp) + # Several superstep checkpoints can share a timestamp (they are taken within one + # host clock tick, in particular on Windows), and a plain ``max`` over the ISO + # timestamp strings then returns the first-saved checkpoint in storage order, so + # the restore starts from a stale state. Use the storage's lineage-aware + # selection, which resolves timestamp ties through ``previous_checkpoint_id``. + checkpoint = await storage.get_latest(workflow_name=workflow.name) + assert checkpoint is not None assert checkpoint.state[_HEADER_BINDING_KEY] not in repr(approval.data) if restore: workflow = build()