Skip to content

CubeLoop — a Pythonic, async-native agent harness core designed for high performance, readability, and production-grade persistence.

fix(checkpointer): compare MySQL run IDs bytewise

xfgong6b8f58ff1bc4
diff --git a/cubeloop/checkpointer/mysql/checkpointer.py b/cubeloop/checkpointer/mysql/checkpointer.py
index 027cbad..d9e9a66 100644
--- a/cubeloop/checkpointer/mysql/checkpointer.py
+++ b/cubeloop/checkpointer/mysql/checkpointer.py
@@ -757,7 +757,7 @@ class MySQLCheckpointer:
"updated_at = CURRENT_TIMESTAMP "
"WHERE thread_id = %s "
"AND JSON_UNQUOTE(JSON_EXTRACT(pending_request, '$.question_id')) = %s "
- "AND run_id = %s",
+ "AND BINARY run_id = BINARY %s",
(thread_id, question_id, run_id),
)
return cur.rowcount == 1
diff --git a/tests/checkpointer/test_mysql_pending_request.py b/tests/checkpointer/test_mysql_pending_request.py
index bcca5b0..d5d0b7e 100644
--- a/tests/checkpointer/test_mysql_pending_request.py
+++ b/tests/checkpointer/test_mysql_pending_request.py
@@ -48,6 +48,9 @@ async def test_mysql_compare_and_clear_pending_request(clean_mysql_db) -> None:
assert not await cp.clear_pending_request_if_matches(
"t-1", question_id="q-current", run_id="run-old"
)
+ assert not await cp.clear_pending_request_if_matches(
+ "t-1", question_id="q-current", run_id="RUN-NEW"
+ )
assert await cp.load_pending("t-1") == (_req(qid="q-current"), "run-new")
assert await cp.clear_pending_request_if_matches(