Skip to content
ML Academy

LLMs, GenAI, RAG, agents, evaluation · insight-1553

Detect repeated identical tool calls and break the loop before the budget runs out

Evidence type
practitioner heuristic
Difficulty
easy
Roles
ML engineer, Applied AI
Industries
cross-industry

Summary: situation, action, reason, boundary

  1. Situation

    An agent searches, gets an unhelpful result, and issues the same call with the same arguments again and again.

  2. Action

    Keep a per-run record of tool name plus normalised arguments, and when the same call repeats a small number of times without new information, stop the loop and either change strategy, ask the user or escalate with the trace.

  3. Reason

    A hard budget bounds the damage but only after the waste; a repeat check recognises the stuck pattern in two or three steps and gives a more useful failure.

  4. Boundary

    Any agent loop with search, lookup or retry-style tools.

Symptom or risk

The run burns its whole step and token budget producing nothing, and the user waits until the cap fires.

Exceptions

Polling a job status legitimately repeats a call; give such tools a separate, timed allowance.

Trade-offs

Argument normalisation takes care, and near-duplicate calls with trivial changes can slip past.

Pitfalls

Treating the model's own wording changes as new progress when the retrieved data is the same.

Lessons and concepts