Overview
Resource exhaustion occurs when agents consume computational resources—tokens, API calls, compute time, or memory—far beyond intended levels. In agentic systems, this can happen through runaway loops, inefficient tool use, or deliberate attacks.
Resource Types at Risk
Token Consumption
Normal task: ~2,000 tokens
Runaway agent: 500,000+ tokens
Cost impact: 250x expected
API Calls
Intended: 5 tool calls per task
Runaway: 500+ tool calls
Impact: Rate limits, blocked access, excessive costs
Compute Resources
Agents spawning sub-agents spawning sub-agents...
Exponential growth in active processes
Memory
Agent accumulates context without summarization
Memory grows unbounded
System becomes unresponsive
Exhaustion Patterns
Infinite Loop
Agent: "I need to verify this. Let me search again."
Agent: "Results inconclusive. Let me search again."
Agent: "Still not certain. Let me search again."
[Continues indefinitely]
Recursive Agent Spawning
Task requires expertise → Spawn specialist agent
Specialist needs help → Spawn another agent
Chain continues → Exponential agent growth
Perfectionism Loop
Agent: "Let me improve this output."
Agent: "Still not perfect. One more revision."
Agent: "Almost there. Just a few more changes."
[Never reaches 'good enough']
Tool Call Amplification
Single user request triggers:
1 request → 10 sub-queries → 100 tool calls → 1000 API calls
Multi-Agent Amplification
Coordination Overhead
2 agents: 4 potential interactions
5 agents: 25 potential interactions
10 agents: 100 potential interactions
n agents: n² potential interactions
Echo Chamber Loops
Agent A asks B for clarification
Agent B asks C for details
Agent C asks A for context
[Circular dependency consumes resources]
Cost Impact Examples
Token Costs
GPT-4: $0.03/1K tokens
Runaway agent (1M tokens): $30 per incident
10 incidents/day: $300/day, $9,000/month
API Rate Limits
Exhausting rate limits blocks legitimate operations:
Runaway agent consumes daily quota in 1 hour
→ System unusable for remaining 23 hours
Prevention Architecture
Resource Budgets
class ResourceBudget:
def __init__(self, max_tokens=10000, max_tools=50, max_time=300):
self.token_budget = max_tokens
self.tool_budget = max_tools
self.time_budget = max_time
self.start_time = time.time()
def check_budget(self, tokens_used, tools_used):
if tokens_used > self.token_budget:
raise BudgetExceeded("Token limit reached")
if tools_used > self.tool_budget:
raise BudgetExceeded("Tool call limit reached")
if time.time() - self.start_time > self.time_budget:
raise BudgetExceeded("Time limit reached")