Escalate to a human after N replies without resolving (anti-loop lock)
How to turn on the deterministic lock that forces a handoff to a human after your AI agent has replied N times without resolving the case.
Watch this step in the video · Confidence threshold and escalating after N replies
The anti-loop lock is a deterministic safety net: the system counts, in code, how many consecutive replies the AI agent has sent in the current segment without the conversation being resolved, and forces a human handoff once it hits the number you set. It doesn't depend on the model "realizing" it's stuck — the system makes the call.
Requirements
- An active AI agent with at least one fallback destination configured (where to escalate to).
- Access to the agent editor's Behavior tab.
Setup
- Open the agent under AI Agents and go to the Behavior tab.
- Find the "Escalate to a human after N replies without resolving" field.
- Enter the number N of consecutive bot replies you'll tolerate before escalating (0 or empty = disabled, the default for every new agent).
- Set "What to do on escalation" (
fallback_action): transfer to a specific human agent, transfer to a team, close the conversation, or no action. - Save your changes.
How the lock counts
- It only counts genuine bot replies (real outbound messages) — not transfer notes or off-schedule notices.
- The count resets every time a human replies in the conversation — if a human agent picks up the chat and hands it back to the bot, the counter starts over from zero.
- Once it hits N, the system automatically generates a context summary for the human (if you have that option enabled) and runs the configured fallback action.
Example
You set N=3 with fallback_action = "Transfer to team" → Support team. A customer asks the bot the same technical question three different ways, and the agent replies three times without the customer confirming it's resolved. On the fourth turn, the system doesn't let the bot reply again: it automatically transfers the conversation to the Support team with a summary of what was discussed.
Tips
- N=3 or N=4 is a reasonable starting point for technical support agents; N=2 works better for sales agents, where every message without progress is more costly.
- Combine it with the confidence threshold (
auto_handoff_confidence_threshold) to cover two different scenarios: low model confidence (immediate escalation) and objective stalling (count-based escalation). - Test the behavior in the Sandbox by simulating several turns in a row before shipping it to production.
Troubleshooting
- "I set N but it never escalates": check that the saved value isn't 0 or empty, and that the fallback team/agent exists and is active.
- "It escalates too early": check whether one of your bot's messages is being counted as a genuine reply when it's actually a transfer note — this usually resolves itself, since the system automatically excludes those events.
Related articles
-
Create your first AI agent
Learn what an AI agent does in Omnifox, how to give it instructions, connect it to a channel and test it in the sandbox before it talks to real customers.
-
How to write good instructions for your AI agent
Learn how to write clear instructions so your AI agent replies with the right tone, limits and actions.
-
AI Agents complete guide
AI Agents in depth, in 65 chapters: creating, instructions, tools, knowledge, behavior, tester, inbox, workflows, analytics and usage, with every setting explained.
-
Connect your AI agent to WhatsApp, Instagram, Messenger and web chat
An agent with no channels serves nobody. Connect it to your WhatsApp, Instagram, Messenger or website chat from the Connections section, then switch it on so it starts replying.
-
Start here: AI Agents in 8 minutes
AI Agents essentials in a short video: creating an agent, its instructions, tools, knowledge, channels, the tester, hours and handing over to a person.