Runaway Agent Loop
Infinite execution cycle drains treasury through gas exhaustion
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
Agent Encounters Error
elizaOS agent attempts market order but receives timeout from RPC. Error handling triggers retry logic.
Retry Loop Initiates
Agent retries transaction with exponential backoff. Each retry costs gas. Counter increments: 1, 2, 4, 8...
Logic Error Compounds
Backoff calculation overflows. Agent interprets as 'retry immediately'. Begins executing 100+ tx/minute.
Treasury Depleted
Over 48 hours: 4,200 transactions. Gas fees: $178,000. No human intervention triggered. Treasury drained.
Incident Metrics — Without Protection
With AgentSentry Protection
After 100 transactions in 1 hour epoch, velocity limit exceeded.
Circuit state transitions CLOSED → OPEN. All further transactions blocked.
Telegram/Discord notification sent within 30 seconds of breach.
Total gas spent: $47 (100 tx). Treasury loss prevented: $178,373.
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