Exactly-once for AI agents

Crash. Retry.
Act once.

When an agent crashes mid-run and retries, it re-fires actions that already happened. SafeAct makes every action run exactly once, with a durable record — in your own code, an MCP server, or a LangChain agent.

$ pip install safeact-mcp
100% open source · Apache-2.0 One SQLite file · no server No signup · just pip install
charge_card() · 40 retries, 1 key
Naïve tool
0
charges
re-runs on every retry
@safe tool
0
charges
idempotent by key
Drops into the stack you already use
MCP Model Context Protocol LC LangChain LG LangGraph py Your own Python
The whole change

One decorator. A caller-supplied key.

Your side effect stays exactly as you wrote it.

Add @safe and pass a key that names the logical action. The same key seen again returns the stored result instead of re-running — and it holds across process restarts, because the record lives in SQLite, not memory.

  • Exactly-once, even across crashes & retries
  • Honest in-doubt — never a blind retry
  • Sync & async · one file · no server
refund_agent.py
from safeact import safe

@safe(store="agent.db")
def charge_refund(key, customer, amount):
    stripe.charge(customer, amount)   # real side effect
    return {"charged": amount}

# retry-safe: runs once, then replays the result
charge_refund("refund-8842", cust, 50)
charge_refund("refund-8842", cust, 50)  # no double-charge
What the open-source core gives you

Four guarantees.

Enforced in code, underneath any agent framework — and proven in a durable record.

Exactly once

Crash, restart, retry — the action happens once, and holds across process restarts.

Honest in-doubt

If the gap is truly unknowable, it stops and surfaces for a human — never a blind retry.

Audited

A durable record of every attempt and its outcome — your whole audit trail.

Composable

Saga rollback for multi-step flows; drops into MCP & LangChain in one line.

Verify, then execute

Two checkpoints every agent action should pass.

An agent can hurt you two ways: a wrong answer, or a double action. wobbly catches one. SafeAct stops the other.

01 · Verifytest-time
wobbly

Is the agent's judgment sound?

Catches wrong, brittle, and biased outputs before any action fires — with no labels and no answer key. Runs in CI, on your laptop, zero risk.

535 receipts · flagged outputs 2.7× more likely to be wrong
02 · Executerun-time
SafeAct

Did it happen — once, on the record?

Runs the action exactly once through crashes, restarts and retries — honest in-doubt when it genuinely can't know, with a durable record of every attempt.

exactly-once · mutation-tested · one SQLite file
One refund · two failures · two tools

A support agent decides to refund $50. The $50 could be hallucinated — it should have been $5. Or the refund could fire twice, because the run crashed and retried. wobbly flags the shaky refund in testing. SafeAct guarantees the good one fires exactly once in production.

100% open source · no paid tier

Four libraries. One trust thesis.

The whole thesis, shipped as four small packages — one pip install each, every line open source. No server, no account, no upsell.

Apache-2.0 licensed 0 external deps in core Runs offline Read the source on GitHub

Let your AI act. Keep the proof.

SafeAct comes out of running real, action-taking agents in production — where we learned exactly how they break. Free and open source.