Detect and Handle Conversation Loops in AI Agents
A conversation “loops” when a customer keeps re-asking the same question and the agent keeps replying without moving the thread forward. That pattern is the single most damaging failure an AI concierge can produce — the customer walks away frustrated, and nothing on the agent side noticed. Orbit ships a deterministic loop detector that reads the recent message window and answers “is this conversation stuck?” on demand; the inbox surfaces that verdict as the supervisor “conversation in a loop” banner. This guide shows how to read the evaluation, hand the thread to a person, and gate agent promotions on loop-free behavior. Endpoint paths below are relative. Send them againsthttps://api.orbit.devotel.io/api/v1.
1. Where loop-check fits in the supervisor loop
POST /agents/conversations/:conversationId/loop-check reads the recent
message window and returns a LoopEvaluation:
data object of the standard data/meta
API envelope) carries the verdict plus the evidence your supervisor needs:
2. What the detector looks at
Three signals feed the verdict; any one of them is enough to setisLoop: true. Reason codes stay stable so analytics can group them:
semantic_re_ask— two customer turns inside the window share a token-overlap similarity at or above the threshold (default 0.55). This catches “what’s my balance” / “tell me my balance please” / “balance again?” — the customer repeating the same request in slightly different wording while the agent re-answers the same way. The matching pair comes back inreAskPairso the supervisor sees the exact two messages.negative_sentiment_delta— the earliest customer turn in the window scored neutral-or-positive and the latest turn fell to the negative threshold (default −0.3). That is the escalation-from-polite-to-exasperated shape a stuck loop shows.explicit_escalate_keyword— the newest customer turn contains a direct ask to reach a person (“talk to a human”, “real person”, “this isn’t working”). This short-circuits everything else; respect the stated preference immediately.
recommendedAction maps those signals to a next step:
none— no loop; keep the agent on it.offer_handoff— re-ask similarity fired; prompt the customer or the supervisor to take over.escalate_now— explicit keyword or a sentiment crater; handoff now.
3. Operator handoff — take over, override, or mark a ticket
A loop verdict without a handoff path leaves the customer stuck in the same place. Wire the banner and the poll to three actions:- Take over with live-summary. A supervisor opens
GET /inbox/conversations/:conversationId/live-summary?window_turns=Nto get a rolling 1–2 sentence AI summary of the last turns, then either takes the conversation over in the inbox or releases the thread back to the agent after a fix. The summary is opt-in per tenant for AI features. - Override with the handoff endpoint. When the evaluation is
escalate_now(or a human decides anyway), firePOST /conversations/:id/handoffwith a reason. That clears the AI assignment, flips the conversation back to the unassigned queue, and stamps the reason category on the row so a report can aggregate loop handoffs separately from arbitrary handoffs. The receiving operator then picks the thread up from the queue rather than from the agent’s surface. - Mark a ticket for review. Not every loop warrants a human
interruption. Submit the conversation to the agent’s labeling queue with
POST /agents/:agentId/labeling/annotationsso QA and fine-tuning pick up the failure later (section 5).
4. Gate promotions on loop behavior, not just quality
Loop-free behavior belongs in the pre-promotion gate next to the model and quality checks. The rollout pipeline already runs persona simulation, shadow comparison, and regression tests before a candidate reaches traffic — wire loop-check into the same stage gates so a candidate that loops on the golden conversations halts before the rollout advances. When you run the AI agent rollout pipeline, add loop evaluation to the stage checklist before advancing:- Save the candidate as an agent version (same as for regression tests).
- Replay the saved regression conversations against the candidate.
- Post the loop-check on each replayed conversation’s id and require
isLoop: falsebefore you advance the stage.
5. How labeling picks up the pattern — loops are a symptom, not a bug
Treat a loop as a signal that the agent’s knowledge, prompt, or tooling is missing something the customer needs. The route is deliberately deterministic — it does not ask an LLM “is this a loop,” so it can run on every conversation cheaply — which also means the pattern that produced the loop names its own remedy. Labeling moves the failure into the eval/fine-tune pipeline where the fix actually lands:6. Example: poll loop-check, hand off when the verdict lands
A sideband supervisor script polls loop-check on the conversations an agent is handling, and hands the thread to the queue when the verdict says loop:evaluation.isLoop boolean, hand off via
the conversations endpoint, and label the failure for the agent’s review
queue. Nothing here alters the agent configuration or the conversation row
inside the loop-check call itself — the mutation is the explicit handoff and
the separate annotation.
Keep the poll to the same cadence the supervisor banner uses, and tune the
window once (section 2) instead of per request.
Troubleshooting
See also
- AI Agent Rollout Pipeline — promotions gated on simulation, comparison, and regression results, now also on loop-free behavior.
- Human-in-the-Loop Oversight — supervisor takeover, override, and release on live conversations.
- Live Conversation Monitor — the operator surface on which the loop-check banner and the labeling queue both live.
- Continuous Production Evals — after launch, production sampling keeps testing the same conversations the loop detector reads.