Open-source TokenShield cuts off CrewAI retry loops before token burn explodes
bulleykebaal · reddit · 2026-07-25
A developer says they fixed runaway retry loops in CrewAI by adding turn-scoped sliding-window hashes to TokenShield, an open-source FastAPI gateway proxy.
- The problem: an agent stuck on a failing database tool would retry repeatedly, and each retry kept appending more context, driving prompt tokens from about 139 to 600+ per turn.
- The fix uses normalized signatures within a single turn only, avoiding false positives across later turns.
- The gateway now applies two defenses: first, soft steering with replanning instructions; then, if needed, a hard 429 cutoff to stop token burn immediately.
- The author says this helped cut off runaway multi-agent loops in CrewAI and similar frameworks before the bill arrives.
Related event: TokenShield fixes CrewAI retry loops with turn-scoped hashing(2 posts)→
More from coding & agent
- Warp's six non-engineering teams all run on Linear and Claude Code — mon__lim · 2026-09-11
- Is inference latency becoming the biggest bottleneck for production AI agents? — Euphoric_Sea632 · 2026-09-11
- Anthropic researcher: 99% of engineers now run swarms of 300+ self-improving agents — AlishaOutridge · 2026-09-11
- Gergely Orosz: Shipping 10x PRs With AI Agents, Sites Fill With Small Regressions — ducha_aiki · 2026-09-11
- Same Echo Maze prompt, three frontier models: all passed visually but shipped the same hidden bug — eyishazyer · 2026-09-11
- Astra storyboards plus Minimax H3 per-shot generation boost video success rates — Hailuo_AI · 2026-09-11