Customer Agent: Loop Detection

Detects if a customer agent is stuck asking the same question repeatedly or circling back in loops during a conversation.

result = evaluator.evaluate(
    eval_templates="customer_agent_loop_detection",
    inputs={
        "conversation": "User: I need help with my bill.\nAgent: Can you provide your account number?\nUser: It's 12345.\nAgent: Can you provide your account number?\nUser: I already told you, it's 12345.\nAgent: Can you provide your account number?"
    },
    model_name="turing_flash"
)

print(result.eval_results[0].output)
print(result.eval_results[0].reason)
import { Evaluator, Templates } from "@future-agi/ai-evaluation";

const evaluator = new Evaluator();

const result = await evaluator.evaluate(
  "customer_agent_loop_detection",
  {
    conversation: "User: I need help with my bill.\nAgent: Can you provide your account number?\nUser: It's 12345.\nAgent: Can you provide your account number?\nUser: I already told you, it's 12345.\nAgent: Can you provide your account number?"
  },
  {
    modelName: "turing_flash",
  }
);

console.log(result);
Input
Required InputTypeDescription
conversationstringThe full conversation history between the customer and agent
Output
FieldDescription
ResultReturns one of: never, occasionally, frequently, or always — indicating how often the agent gets stuck in a loop
ReasonProvides a detailed explanation of the loop detection assessment

What to Do When Loop Detection is Flagged

  • Review the conversation flow to identify where repetition occurs
  • Add state tracking to ensure the agent remembers previously collected information
  • Implement fallback logic to handle cases where user input is not recognized
  • Test with diverse user inputs to identify edge cases that trigger loops

Comparing Loop Detection with Similar Evals

  • Customer Agent: Context Retention: Loop Detection identifies repetitive agent behavior, while Context Retention evaluates whether the agent remembers and applies earlier context.
  • Conversation Coherence: Loop Detection focuses on repetitive patterns, while Conversation Coherence evaluates the overall logical flow of the dialogue.
Was this page helpful?

Questions & Discussion