Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions intentkit/core/execution/ExecutionGuard.py
Original file line number Diff line number Diff line change
@@ -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)