Mintplex-Labs/anything-llm · warning
[loop-detect] Suspected loop: ${reason}
Error message
[loop-detect] Suspected loop: ${reason} What it means
The loop-detect heuristic decided the agent is stuck repeating the same behavior (identical tool calls/results). alertLoopingAgent injects a STOP nudge into the proxy interrupt queue (or the pi RPC channel) telling the agent to change approach, and broadcasts an ask_for_help event so the user can intervene; it is rate-limited by pendingHelp and alertedAt so it does not spam.
Source
Thrown at open-computer/services/interface-service/loop-detect/index.js:135
}
/** Call whenever a text message turn arrives (increments no-tool-turn counter). */
function onTextMessage() {
LOOP_DETECT.turnsSinceToolCall++;
}
// ─── Intervention ─────────────────────────────────────────────────────────
/**
* Injects a stop nudge into the LLM proxy interrupt queue and, if the proxy
* is not in use, also writes directly to the pi RPC channel. Surfaces an
* ask_for_help event so the user can intervene if the nudge fails.
*/
function alertLoopingAgent(reason) {
if (!workspace.piProcess) return;
if (workspace.pendingHelp) return;
console.warn(`[loop-detect] Suspected loop: ${reason}`);
LOOP_DETECT.alertedAt = Date.now();
const nudge =
`STOP. You are stuck in a loop: ${reason}. ` +
`The same tool calls are returning identical results. ` +
`Do NOT repeat the same action. Try a completely different approach: ` +
`use a different tool, navigate to a different URL, use curl instead of the browser, ` +
`or move on to the next step of the task.`;
if (settings.LLM_PROXY_TARGET) {
setPendingInterrupt(nudge);
}
if (workspace.piRpc) {
workspace.piRpc.write(
JSON.stringify({
id: `loop-nudge-${Date.now()}`,
type: "prompt",View on GitHub (pinned to 3aec848f28)
Solutions
- Watch for the ask_for_help event and intervene manually with a hint or by taking over the session.
- Improve the agent's task prompt to enumerate fallback strategies (different tool, curl instead of browser, skip step).
- Raise temperature or diversity settings so the model explores alternative actions.
- Fix the underlying blocker (login, selector, network) that produces identical results each attempt.
Defensive patterns
Strategy: fallback
Prevention
- Write task prompts that enumerate fallback strategies (different tool, curl, skip).
- Cap consecutive identical tool calls in the agent harness.
- Fix environmental blockers (logins, selectors) that produce identical results.
- Surface ask_for_help events to an operator channel so loops get human attention quickly.
When it happens
Trigger: Agent retrying the same failing selector or navigation because the page never changes; identical API/tool responses each turn; a task whose next step keeps erroring so the model re-issues the same call; prompt that strongly biases one tool.
Common situations: Scraping targets that require login the agent cannot complete; flaky selectors; agent temperature too low so it repeats the first plausible action.
AI-assisted analysis of Mintplex-Labs/anything-llm@3aec848f28 (2026-08-18).
Data as JSON: /api/errors/0fa770544e46564b.
Report an issue: GitHub.