Skip to content

azender1/SafeAgent

Repository files navigation

SafeAgent

Trading Demo

Deterministic execution for real-world actions under uncertainty.


The Problem

Agents don’t fail on decisions.
They fail on uncertain completion.

submit order
timeout
retry
submit order   <-- duplicate

Real Impact

Position: 2 → 4 shares
Capital: $710.20 → $1420.40

Not bad logic.
Just no execution boundary.


The Fix

SafeAgent enforces:

  • request identity
  • execution boundary
  • deterministic retry resolution
timeout
retry
SafeAgent: returning cached result

Core Idea

Agent → SafeAgent → Real World

Retries don’t replay.
They resolve.


PeerPlay Settlement Use Case

SafeAgent is also the settlement guard for PeerPlay-style tournament payout flows.

  • tournament result verified
  • payout request sent
  • confirmation lost / timeout
  • retry fires

Without an execution boundary, the same winner can be paid twice. With SafeAgent, the retry resolves against the prior request record and returns the original result.

Start here:

  • examples/peerplay_tournament_settlement_demo.py
  • failure-cases/05_peerplay_tournament_duplicate_payout/README.md

Failure Cases

  • Trading → double position
  • Payments → duplicate charge
  • Notifications → duplicate send
  • State desync → unintended re-entry
  • PeerPlay → duplicate tournament payout

See: failure-cases/


Working Demos

  • Trading retry demo: assets/safeagent_trading_demo_v2.gif
  • Postgres runtime proof: assets/postgres_demo.gif
  • PeerPlay tournament settlement: examples/peerplay_tournament_settlement_demo.py
  • Deck: deck/SAFEAGENT_DECK_PRO_V2_FINAL.pptx

Before / After

Before After Demo

Execution Guard

Execution Guard Demo
Show Postgres runtime proof
Postgres Demo

Full Video

Download MP4


Status

Reference implementation for handling duplicate execution under uncertain completion.


Repo

github.com/azender1/SafeAgent

About

Execution control layer for AI agents — prevents duplicate or incorrect real-world actions under retries, uncertainty, and stale context.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors