Back to Scenarios
Attack Scenario

Runaway Agent Loop

Infinite execution cycle drains treasury through gas exhaustion

$180K Lost
4,200+ transactions
48 hours undetected

A runaway agent loop occurs when an AI agent enters an infinite or near-infinite execution cycle, typically triggered by error handling logic failures or state corruption. Without velocity limits or circuit breakers, the agent continues executing transactions until treasury is exhausted. AgentSentry prevents this via velocity guards (max tx/epoch) and automatic circuit breaker trips.

Attack Flow — Without AgentSentry

1

Agent Encounters Error

elizaOS agent attempts market order but receives timeout from RPC. Error handling triggers retry logic.

2

Retry Loop Initiates

Agent retries transaction with exponential backoff. Each retry costs gas. Counter increments: 1, 2, 4, 8...

3

Logic Error Compounds

Backoff calculation overflows. Agent interprets as 'retry immediately'. Begins executing 100+ tx/minute.

4

Treasury Depleted

Over 48 hours: 4,200 transactions. Gas fees: $178,000. No human intervention triggered. Treasury drained.

Incident Metrics — Without Protection

4,247
Transactions Executed
48h 12m
Time Elapsed
$178,420
Gas Consumed
NEVER
Alert Sent

With AgentSentry Protection

Velocity Guard Triggers

After 100 transactions in 1 hour epoch, velocity limit exceeded.

VELOCITY_EXCEEDED: 100/100 tx in epoch
Circuit Breaker Trips

Circuit state transitions CLOSED → OPEN. All further transactions blocked.

CIRCUIT_OPEN: Manual reset required
Human Alert Fires

Telegram/Discord notification sent within 30 seconds of breach.

ALERT: Circuit tripped on agent-001
Treasury Protected

Total gas spent: $47 (100 tx). Treasury loss prevented: $178,373.

SAVED: $178,373 (99.97% prevented)

Prevention Configuration

// AgentSentry Policy — Runaway Loop Prevention
const policy: SentryPolicy = {
  name: "velocity-guard",
  circuitBreaker: {
    enabled: true,
    tripThreshold: 100,           // Max 100 tx per epoch
    epochWindow: 3600000,         // 1 hour epoch
    cooldownPeriod: 1800000,      // 30 min cooldown
    autoReset: false,             // Require human reset
  },
  velocityLimits: {
    maxTxPerMinute: 10,
    maxTxPerHour: 100,
    maxConsecutiveErrors: 5,      // Trip after 5 errors
  },
  alerting: {
    channels: ["telegram", "discord"],
    onTrip: true,
    onWarning: true,              // Alert at 80% threshold
  },
};

Prevent Runaway Loops

Deploy circuit breakers in under 10 minutes

Shield Your Agent