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.
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.
-
Giving your AI actions (tools)
Tools turn your AI agent into a teammate that acts: it closes conversations, assigns to a human, updates contacts, books appointments and triggers workflows.
-
How to test your agent in the sandbox
Use the sandbox to chat with your AI agent and validate replies, actions and tone before publishing it.
-
Handoff: when and how the AI passes the conversation to a human
Set up the handoff from AI to a human agent so no customer gets stuck when personal attention is needed.