News for hackers. Stuff that matters.

Show HN: SafeAgent – exactly-once execution guard for AI agents

LLM agents and tool-calling systems frequently retry or replay actions.

This becomes dangerous when the action is irreversible: - sending emails - opening tickets - executing trades - triggering payouts

SafeAgent is a small Python library that enforces exactly-once execution for agent actions using request-ID deduplication.

Example:

from settlement.settlement_requests import SettlementRequestRegistry

registry = SettlementRequestRegistry()

def send_email(): print("EMAIL SENT")

registry.execute( request_id="email:user123:invoice", action="send_email", payload={"to": "[email protected]"}, execute_fn=send_email )

If the same request_id is replayed, the action does not run again.

Instead the original execution receipt is returned.

pip install safeagent-exec-guard

GitHub: https://github.com/azender1/SafeAgent

PyPI: https://pypi.org/project/safeagent-exec-guard/

( 1 comment | 2 points | on HN )
Re:Show HN: SafeAgent – exactly-once execution guard for AI ... by stratifyintel on Friday March 06, 2026 @12:37AM (#47271287)
This becomes a real issue once agents start interacting with external systems. Retries are easy to miss during development, but once you add tool calls + network failures the agent loop can replay same action multiple times.

Idempotency/request IDs end up becoming pretty important for anything that touches emails, payments, tickets etc