Infinite Tool Call Loop Despite "Guard" in Prompt
I'm hitting a wall with a Tool Agent that sometimes gets stuck in an infinite loop. The behavior is inconsistent, sometimes it works perfectly, other times it repeatedly calls the same tool. The Problem: My agent is supposed to call the consultation_booking tool once to finalize a booking. However, it will call it, receive the output, and then immediately call it again on the next run. To prevent this, I've tried several fixes: I've adjusted the tool's response, rewritten its description, and added guards to my system prompt. Here's some of the guards logic from my prompt: #POST‑BOOKING GUARD (prevent double‑booking) Before considering another consultation_booking you MUST scan the conversation history for the **most recent tool result**: • If the most recent result contains "tool_used": "consultation_booking" and "confirmed": true → the lead already has a locked slot. • In that state you may only call consultation_booking again if the lead explicitly requests to reschedule... Another Guard: D. When you call `consultation_booking`, you must stop after the first tool response. Read the JSON from the last node: - If `confirmed` is `true`, return that JSON once and end the turn. - If `confirmed` is `false`, return { tool_used:"consultation_booking", confirmed:false, reason:"<short reason>" } and wait for a new slot. Has anyone else dealt with this kind of intermittent looping?