From a0e8ad254b6b4a2b287ce98f9bf6e7c707892616 Mon Sep 17 00:00:00 2001 From: Justin Skywork Date: Mon, 23 Mar 2026 20:26:18 -0400 Subject: [PATCH] feat: implement ExecutionGuard to prevent redundant runs on timeout #143 --- intentkit/core/execution/ExecutionGuard.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 intentkit/core/execution/ExecutionGuard.py diff --git a/intentkit/core/execution/ExecutionGuard.py b/intentkit/core/execution/ExecutionGuard.py new file mode 100644 index 000000000..382e295cb --- /dev/null +++ b/intentkit/core/execution/ExecutionGuard.py @@ -0,0 +1,18 @@ +import threading + +class ExecutionGuard: + """ + Ensures a skill or task runs only once, even in case of timeouts. + Prevents double-spending or redundant transactions in agent workflows. + """ + def __init__(self): + self._lock = threading.Lock() + self._executed = False + + def run_once(self, func, *args, **kwargs): + with self._lock: + if self._executed: + print("Task already executed or in progress.") + return None + self._executed = True + return func(*args, **kwargs)