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
- Agent-Native apps: why agents bypassing your UI can break business rules — rseroter · 2026-10-27
- 'My intelligence stack': developer splits AI coding work across Opus 5.5, Fable and Astra with human review gates — sh_reya · 2026-10-27
- Baseten webinar: evaluate open models for coding agents by benchmarking on your own merged PRs — baseten · 2026-10-27
- Thorsten Ball on working with agents: run more evals, automate everything, use the best models — omarsar0 · 2026-10-27
- Where to draw the approval line for scheduled agent jobs — Reddit discussion — MemStrata · 2026-10-27
- 4 MCP servers worth a look: full-text YouTube search, Chrome session reuse, Framer editing — Prior_Engineering486 · 2026-10-27