Home/
Part XIII — Expert Mode: Systems, Agents, and Automation/37. Agentic Workflows (Without Letting It Run Wild)/37.4 Termination conditions and budgets
37.4 Termination conditions and budgets
Overview and links for this section of the guide.
On this page
The Infinite Loop Problem
Agents get stuck. "I'll try method A. Failed. I'll try method A again. Failed."
You must implement a **Time-to-Live (TTL)** or **Max Steps** counter. `if step_count > 10: raise AgentgaveUpError()`
Budgets
Track tokens/dollars per run. `current_cost += run_cost`. If `current_cost > $1.00`, kill the process. This prevents a runaway agent from burning your API key overnight.