From f8578aeac3a7debcc21e5697e0f0c90ad71a1637 Mon Sep 17 00:00:00 2001 From: Molecule AI SDK Lead Date: Thu, 23 Apr 2026 19:25:45 +0000 Subject: [PATCH] =?UTF-8?q?fix(sdk):=20repair=20broken=20=5F=5Fall=5F=5F?= =?UTF-8?q?=20list=20=E2=80=94=20new=20constants/func=20escaped=20list=20b?= =?UTF-8?q?oundary?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The PR accidentally embedded the new module-level constants and make_idempotency_key function inside the __all__ list literal, causing a SyntaxError. Fix closes the list after the existing exports and adds make_idempotency_key + verify_plugin_sha256 as proper string entries (compute_plugin_sha256 was removed in this PR so it is omitted). --- molecule_agent/client.py | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/molecule_agent/client.py b/molecule_agent/client.py index 7580341..06dc9eb 100644 --- a/molecule_agent/client.py +++ b/molecule_agent/client.py @@ -958,39 +958,6 @@ __all__ = [ "DEFAULT_HEARTBEAT_INTERVAL", "DEFAULT_STATE_POLL_INTERVAL", "DEFAULT_URL_CACHE_TTL", -# Retry-on-429 defaults for idempotent GET calls. -# Matches the behaviour of the TypeScript MCP server's platformGet(). -DEFAULT_GET_MAX_RETRIES = 3 # retry up to 3 times on 429 -_RETRY_BASE_DELAY = 1.0 # seconds — first delay -_RETRY_MAX_DELAY = 30.0 # seconds — cap -_RETRY_JITTER_FRAC = 0.25 # ±25% jitter around base delay - -# KI-002 — idempotency key granularity: round to the current minute so -# that concurrent restarts within the same 60-second window produce the -# same key, while distinct tasks or distinct minutes produce distinct keys. -_IDEMPOTENCY_ROUND_SECONDS = 60 - - -def make_idempotency_key(task_text: str) -> str: - """Compute a deterministic idempotency key for a delegation task. - - Combines the task text with the current wall-clock minute to produce - a SHA-256 hex digest. Rounding to minute-level means two container - restarts within the same minute that send the same task string will - share the same key, preventing the platform from processing a duplicate - delegation. A different minute (or a different task string) yields a - different key. - - Args: - task_text: The task description string being delegated. - - Returns: - A 64-character hex string (SHA-256 digest). - """ - # Round current time down to the nearest minute — same-task restarts - # within this minute share a key; after the minute rolls over the key - # changes so a genuinely new task is always treated as new. - now = int(time.time()) // _IDEMPOTENCY_ROUND_SECONDS * _IDEMPOTENCY_ROUND_SECONDS - payload = f"{task_text}:{now}" - return hashlib.sha256(payload.encode("utf-8")).hexdigest() + "verify_plugin_sha256", + "make_idempotency_key", ]