Tool-use API design for LLMs: 5 patterns that prevent agent loops and silent failures

TL;DR AI
2 min readKey summary
In July 2025, a Claude Code instance reportedly fell into a recursion loop, consumed 1.67 billion tokens in five hours, and racked up an estimated $16,000 to $50,000 in charges.
The incident exposed a key production risk for LLM agents: they can keep calling tools without crashing, turning silent failures into runaway costs.
The article recommends tool-design patterns that make agent state clearer, reduce ambiguity, and stop endless retries before they spiral.
Suggested fixes include self-describing results, explicit next_action_hint signals, and APIs that surface failure instead of hiding it.
