Loop Guard

Loop Guard prevents tota from getting stuck in repetitive tool-call cycles. It runs automatically on every agentic request — no setup needed.

#How it works

Loop Guard tracks every tool call and detects four failure patterns:

PatternWhat triggers it
Identical callsThe same tool is called with the same parameters repeatedly
Failing loopToo many consecutive tool calls return errors
No-action stepstota keeps thinking but calls no tools, making no progress
Text repeatThe agent's reasoning text repeats across steps

When a threshold is hit, tota surfaces a warning and either retries differently or halts gracefully with an explanation.

#High-tolerance tools

The following tools get a +2 threshold bonus — they are legitimately called many times in a row (reading multiple files, paginating results, etc.):

fetch_url, read_file, list_dir, web_search, github_api, analyze_image

#Adaptive thresholds

When failures accumulate (3+ failed calls in the recent window), thresholds are halved automatically to stop runaway loops faster.

#Configuration

All thresholds can be overridden via environment variables in ~/.tota/.env:

Env VarDescriptionDefault
LOOP_ABSOLUTE_MAXHard cap on total tool calls per request100
LOOP_FAILED_ABSOLUTE_MAXStop after this many failed calls25
LOOP_NO_ACTION_MAXSteps with no tool calls before stopping10
LOOP_IDENTICAL_THRESHOLDConsecutive identical calls before warning5
LOOP_SIMILAR_THRESHOLDConsecutive failing calls before warning8
LOOP_SAME_TOOL_THRESHOLDConsecutive same-tool calls before warning10
LOOP_TEXT_REPEAT_THRESHOLDRepeated step texts before warning3
LOOP_MAX_STEPSMax agentic steps per request50
ℹ️

If tota stops mid-task with a loop guard message, it usually means the task needs more specific instructions, the tools don't have access to the right paths, or a dependency (network, file) is unavailable. Retry with a more focused prompt.