# Automata from Agent Traces: Failure and Next-Step Prediction

*Seonglae Cho, Franklin Cardenoso Fernandez, Umar Mohammed, Zekun Wu, Kleyton da Costa, Ilham Wicaksono, Adriano Koshiyama*

[NeurIPS page](https://neurips.cc/virtual/2026/poster/148996) · [OpenReview](https://openreview.net/forum?id=taEDHOLbwW) · [Open on the map](../papers.html#p148996)

Category: [LLM Agents, Evals & Benchmarks](../pcat/17.md) › [Agent Evaluation Benchmarks](../pgroup/424.md) · Type: new method · Keywords: LLM agent traces, finite-state machine extraction, next-step prediction, failure prediction, safety auditing, behavioral modeling

Areas: [AI Agents](../areas/agents.md) › Agent Robustness › Agent Failure Attribution; [Evaluation & Benchmarks](../areas/evaluation.md) › Language Model and Agent Benchmarks › Multi-Agent System Evaluation

## Summary
The paper extracts provably minimal finite-state machines (FSMs) from LLM agent traces to enable next-step and failure prediction, providing a compact structural substrate for safety auditing.

## Explained to a 5-year-old
People use smart computer programs that do many tasks step by step. These programs leave behind long records of what they did. The researchers turned those records into a tiny picture that shows the main steps. This picture helps guess what will happen next and spot when the program might make a mistake. It works for many different programs and helps keep them safe.

## Explained to a 5-year-old, longer
Smart computer programs, like chatbots, can do many things by following a series of steps. When they work, they write down everything they do, making a long list of actions. This list can be hard to read and understand, especially when there are many steps. The researchers looked at many of these lists from different programs. They built a simple map that shows only the important parts of the steps. The map is like a picture that shows where the program can be and what it can do next. Because the map is simple, it can be made quickly and uses very little memory. With this map, the program can guess what will happen next, like predicting the next word in a sentence. It can also notice when the program is about to do something wrong or stop working. The map works even if the program is changed or replaced, because it focuses on the steps, not the words. This helps people check if the program is safe and stop it early if it looks like it might fail. In the end, the simple map makes it easier to watch and improve smart computer programs.

## For a technical reader
The paper builds a compact finite-state model directly from the step-by-step logs of LLM agents, using a prefix-tree construction followed by state merging to guarantee minimality. This model serves as a unified context for both predicting the next action and flagging potential failures, outperforming existing baselines on multiple public datasets. The approach runs in milliseconds, scales to dozens of states, and is model-agnostic, allowing a single model to replay traces from different LLMs. By providing early-stopping capability at just 32% of a trace, it reduces monitoring overhead and improves safety in production deployments.

## Problem
LLM agents generate long, unstructured execution traces that are difficult to audit and monitor for safety. Existing methods focus on individual traces or only on successful runs, lacking a way to capture the underlying behavioral structure needed for predicting future steps and detecting failures.

## Method
The approach constructs a prefix tree from agent traces and then merges structurally similar states to obtain provably minimal finite-state machines. This yields a compact model that can be used as context for next-step prediction and failure detection.

## Results
The FSMs are compact (7-43 states), achieve high replay fitness with zero structural variance, and are built in milliseconds. For next-step prediction, FSM-state context outperforms Agent Workflow Memory on all eight ground-truth-matched datasets, and for failure prediction, per-state features achieve AUROC up to 0.94, enabling early-stopping at 32% trace completion.

## Contributions
The paper provides a provably minimal finite-state machine extraction technique that captures the structural topology of LLM agent behavior, enabling both next-step and failure prediction. It also demonstrates that this structural substrate is largely model-agnostic, as a single FSM can replay four different LLMs at perfect fitness.

## Practical relevance
The approach provides a model-agnostic structural primitive for safety auditing and runtime monitoring of deployed LLM agents, allowing early detection of failures and reducing monitoring overhead.

## Research questions this paper is counted under

- [How can we model the underlying structure of long, unstructured execution traces for analysis and prediction?](../q/358.md)

This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. [Suggest a correction](../feedback/?on=p/148996)
