The problem: agent tries action → fails → retries the same action → fails again → repeats 500+ times because there's no state memory.
My fix: hash the execution state and compare it to the last N steps. If there's a match, circuit breaker kicks in and forces the agent to try something different or stop entirely.
Built a dashboard around this because staring at JSON logs at 3am is miserable. Shows the agent's decision tree in real time with a visual indicator when the loop prevention fires.
Stack is Next.js + Vercel AI SDK. It's live at empusaai .com and the state-hashing logic is open source on GitHub.
Would love feedback on whether this is actually useful or if I just over-engineered a solution to my own bad prompts.