← All questions
AgentsHard· Agent Fundamentals

Walk through a concrete, production-grade set of guardr...

A step ceiling alone is the guardrail most people name first, and it’s necessary but leaves several gaps that only show up under real production load. Five checks together close them:

  • Max steps — a hard ceiling on total iterations; exceeding it terminates the run and alerts, rather than continuing indefinitely.
  • Budget cap — track spend per session independently of step count, since steps vary wildly in cost. A run that hits its dollar ceiling should terminate even if it’s well under the step limit — otherwise a handful of expensive steps can blow the budget while looking perfectly normal on a step counter.
  • Repeated-action detection — if the last several tool calls are identical, that’s a loop signature independent of whether the step count looks fine; terminate with a specific reason rather than letting it keep counting toward the cap.
  • Per-step timeout — cap how long any single tool call is allowed to take. Without this, one unresponsive external API can stall the entire run regardless of how tight the other limits are.
  • Tool allowlist — the agent can only call pre-approved tools; anything else returns an error rather than executing. This closes off an entire category of runaway behavior where a misconfigured or hallucinated tool call cascades into something unintended.

Knowing all five, not just the step ceiling, is what separates a answer that sounds right from one that’s actually been through a production incident — each one catches a failure mode none of the others do.

Code playground (Python)