Week 7 · Enterprise AI

Loops need a limit

0:00 / 3:00

15 seconds

847 tool calls.

The agent chased a bad join overnight. Finance found it before ops did.

AgentStep nMax stepsHard stopHaltEscalate
Lesson notesLoops need a limit: the short version+

Week 7 · Agents · about 3 minutes

What you will be able to do

Cap agent steps so Helix cannot burn tokens forever on a stuck tool loop.

The idea

Every ReAct loop needs max_steps (and often a token budget). When the cap hits, stop and escalate.

Unbounded loops are a cost and safety bug, not a feature.

for step in range(1, max_steps + 1):
    action = agent.next(messages)
    if action.done:
        return action.result
raise AgentLimitError(max_steps)

If there is no cap, there is no production agent.

Key takeaways

  • max_steps is mandatory.
  • Escalate when the cap hits.
  • Unbounded = incident.

Part of the Forward Deployed Engineer roadmap. New to the role? Start with what a Forward Deployed Engineer does.