Agent loops on tool errors: the fix is in what tools return, not the prompt
block_intelligence · reddit · 2026-11-27
A Reddit practitioner breaks down a common agent failure mode: a tool call fails and the model retries with identical args until it hits the step limit, wasting calls without crashing.
Key fixes, mostly outside the prompt:
- Return short, specific errors with a hint (e.g. "orderid must be numeric, got 'ABC-123'. use searchorders first") instead of "Error 400" or raw stack traces — loops mostly disappeared once models knew what was wrong.
- Add a retry guard in the loop itself: hash tool name + args, and after two identical failures stop sending the call and inject a message saying it already failed. Prompt instructions like "don't repeat failed calls" get ignored once context grows long.
- Separate retryable from non-retryable errors in the response: timeouts get code-level backoff retries; validation and permission errors should never be retried as-is, and saying so explicitly cuts noise.
The author closes by asking whether others let models see transient errors at all, or handle retries in code and only surface fixable ones.
More from coding & agent
- OpenRouter tip: your best coding evals come from your own codebase, not benchmarks — togethercompute · 2026-11-29
- Web2MCP Turns Any Web App into MCP Tools with One Recording, No Browser at Call Time — Electrical_Pen_4989 · 2026-11-29
- Dev ports 100k lines of Go to Rust+TS in 2 days with Gemini, memes about it — PrasoonPratham · 2026-11-29
- Inference Arena: agents race to build C/C++ inference engines from scratch — my_cat_can_code · 2026-11-29
- Verification is the new AI bottleneck: two questions to ask before any agent task — curious_vii · 2026-11-29
- Software work is moving up the stack: AI automates pixels, humans keep purpose — ciguleva · 2026-11-29