FSMs Predict LLM Agent Failures and Next Steps

Seonglae Cho, Franklin Cardenoso Fernandez, Umar Mohammed, Zekun Wu, Kleyton Da Costa, Ilham Wicaksono, Adriano Koshiyama· August 26, 2026 View original

Key takeaways

  • LLM agent traces can be converted into compact finite-state machines (FSMs).
  • FSMs provide transparency for safety auditing and runtime monitoring of agents.
  • FSM-state context improves next-step prediction for LLM agents.
  • FSM-derived features enable early and accurate prediction of agent failures.

Who benefits

AI DevelopmentSoftware EngineeringAutomationCybersecurityManufacturing

Summary

This study introduces a method to convert LLM agent traces into compact finite-state machines (FSMs) to make their behavior transparent for safety auditing and runtime monitoring. These FSMs effectively predict next steps and identify potential failures early in multi-step tasks.

LLM-based agents, while capable of executing complex multi-step tasks, often produce opaque behavioral traces that hinder safety auditing and runtime monitoring. Existing analysis methods typically focus on individual traces or successful outcomes, missing the overarching structural patterns that link next-step and failure prediction. This research addresses this by proposing a novel approach: collapsing an entire corpus of agent traces into a single, compact finite-state machine (FSM). These FSMs serve as a structural foundation for understanding the otherwise unpredictable behavior of LLM agents. Across twelve public datasets, the generated FSMs proved to be compact, accurately replaying held-out data with high fitness, and building rapidly. This structural substrate effectively supports both prediction goals. For next-step prediction, the FSM-state context consistently outperformed existing methods. For failure prediction, behavioral features derived from the FSM achieved high accuracy in identifying failing runs, enabling early stopping from partial traces. This suggests that the behavioral topology of LLM agents is significantly influenced by the deployment environment rather than solely the LLM itself, providing a model-agnostic primitive for enhancing safety and monitoring.

Why it matters

Professionals deploying LLM agents can use FSMs to gain transparency into agent behavior, predict failures early, and ensure safer, more reliable operation, which is crucial for complex automated workflows.

How to implement this in your domain

  1. 1Implement FSM generation: Integrate tools or scripts to automatically generate FSMs from LLM agent trace logs for ongoing behavioral analysis.
  2. 2Develop early warning systems: Utilize FSM-derived behavioral features to build real-time monitors that predict agent failures and trigger early stopping.
  3. 3Enhance safety auditing: Use the compact FSMs to systematically audit LLM agent behavior, identify unexpected states, and ensure adherence to operational guidelines.
  4. 4Optimize agent workflows: Analyze FSMs to understand common agent pathways, bottlenecks, and failure points, informing improvements to agent design and deployment harnesses.

Original post by Seonglae Cho, Franklin Cardenoso Fernandez, Umar Mohammed, Zekun Wu, Kleyton Da Costa, Ilham Wicaksono, Adriano Koshiyama

"arXiv:2608.23670v1 Announce Type: new Abstract: LLM-based agents execute multi-step tasks, but their behavioral structure remains opaque: long unstructured traces resist the safety auditing and runtime monitoring that deployment requires. Existing approaches operate per-trace or…"

View on X

Originally posted by Seonglae Cho, Franklin Cardenoso Fernandez, Umar Mohammed, Zekun Wu, Kleyton Da Costa, Ilham Wicaksono, Adriano Koshiyama on X · view source

Want to go deeper?

Turn these trends into skills with Learnijoy's hands-on AI & tech courses.

Explore courses