Open-source TokenShield adds turn-scoped hashes to stop CrewAI retry loops

bulleykebaal · reddit · 2026-07-25

Fixing CrewAI retry loops with turn-scoped hashes

The author refactored their open-source TokenShield FastAPI gateway after feedback from an earlier discussion on catching agents that get stuck retrying.

They tested it on a stubborn local CrewAI script where an agent repeatedly hit a failing database tool maxiter=10. Without the shield, the agent hammered the tool 10 times and prompt usage grew from about 139 tokens on the first turn to 600+ tokens per turn as chat history kept being appended.

What changed

The takeaway is that turn-scoped hashing can keep circuit breakers precise in CrewAI-style multi-agent graphs while preventing runaway API costs.

Original post →

More from coding & agent

coding & agent channel →