My LLM kept calling tools it shouldn't, so I built a state machine to stop it
Dev.to / 6/11/2026
💬 OpinionDeveloper Stack & InfrastructureIdeas & Deep AnalysisTools & Practical Usage
Key Points
- The article describes a real failure case where an LLM confirmed a booking even though the database showed it was already sold.
- It explains that prompt-based safeguards are insufficient because the underlying issue is that restricted tools can be present in the LLM’s context during the wrong conversation step.
- To prevent incorrect tool use, the author built a declarative state machine that controls which tools are available per conversation state.
- The proposed approach, implemented in the zero-dependency TypeScript library reactive-fsm, ensures the model cannot call tools unless the state machine has enabled them for that phase.
Continue reading this article on the original site.
Read original →Related Articles

Black Hat USA
AI Business
langchain-core==1.4.5
LangChain Releases

When is your SaaS feature actually high-risk under the EU AI Act? The Annex III decision tree.
Dev.to

API Spend Caps, React DoS Patch, and Deno 2.6/2.8: What Senior Engineers Need to Act On This Week
Dev.to

HomeVision Studio — AI Interior Redesign for Any Room
Dev.to