One safety rule
Every agent loop needs a budget before it starts. If the budget is used up, stop and return a safe status instead of asking the model one more time.
Do not copy older tutorials with unbounded while loops. Current agent frameworks expose max-turn, model-call, and tool-call limits because runaway loops are a normal failure mode.
What runaway means
A runaway agent keeps calling tools without getting closer to a final answer. It may repeat the same search, retry a broken API call, or ask the model again after every weak result.
In a hackathon project, this can burn credits, spam APIs, hit rate limits, or make your demo hang in front of judges.