Automata from Agent Traces: Failure and Next-Step Prediction
Organizations: Holistic AI · PUC-Rio · University College London
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 success-only, so they miss the cross-run topology that links next-step and failure prediction. To recover that shared structure, we collapse an entire trace corpus into a single, compact finite-state machine (FSM) that serves as a structural substrate for the otherwise unpredictable behavior of LLM agents. Across twelve public datasets, the FSMs are compact (7-43 states), replay held-out data at >=0.997 fitness with near-identical topology across splits, and build in milliseconds. This substrate addresses both prediction goals. For next-step prediction, FSM-state context outperforms Agent Workflow Memory on every ground-truth-matched dataset. For failure prediction, per-state behavioral features reach held-out AUROC up to 0.94, and an online monitor ranks failing runs above passing ones from a partial trace, triggering early stopping well before completion. Behavioral topology thus appears shaped more by the deployment harness than by the LLM, providing a model-agnostic structural primitive for safety auditing and runtime monitoring.
Figures & tables
| Ours | RPNI | Alergia | |||||
|---|---|---|---|---|---|---|---|
| Dataset | Fit | Fit | Fit | Compr. | |||
| SWE-agent | 25 | 0.999 | 59,510 † | 0.646 | 35 | 0.999 | 2,380 |
| WebArena | 25 | 1.000 | 382 | 1.000 | 149 | 1.000 | 15 |
| AgentNet | 25 | 1.000 | 62,495 † | 0.742 | 45 | 1.000 | 2,500 |
| tau2-bench (air) | 18 | 1.000 | 6,506 † | 0.844 | 23 | 0.999 | 361 |
| tau2-bench (ret) | 19 | 1.000 | 14,249 † | 0.837 | 25 | 1.000 | 750 |
| Method | SWE-sm | SWE-ag | W&W | M2W | ATB | Avg |
|---|---|---|---|---|---|---|
| Uniform | 3.170 | 4.585 | 3.000 | 2.807 | 3.807 | 3.474 |
| Unigram | 2.461 | 2.850 | 2.229 | 1.856 | 2.799 | 2.439 |
| RPNI | 3.851 | 4.284 | 2.855 | 3.549 | 2.448 | 3.397 |
| Our FSM | 0.638 | 1.071 | 0.963 | 0.756 | 1.243 | 0.934 |
| FSM-PPM-AD | 0.463 | 0.741 | 0.624 | 0.782 | 1.309 | 0.784 |
| Ens(D0/3/5/7) | 0.465 | 0.700 | 0.621 | 0.736 | 1.262 | 0.757 |
| Context format | Top-1 (%) |
|---|---|
| No memory (trace prefix only) | 27.6 |
| AWM (linear success workflows) ( Wang et al., 2025d ) | 52.9 |
| ASG-full (state + transitions + full graph) | 52.2 |
| ASG++ (ASG-full + multi-step continuations) | 49.2 |
| ASG-success (success-only ASG-full) | 50.3 |
| ASG (minimal: probabilities + top-15 continuations) | 65.1 |
| Dataset | AWM | FSM | ||
|---|---|---|---|---|
| WebArena | 4,800 | 65.5 | 81.2 | +15.7 |
| SWE-smith | 300 | 74.7 | 100.0 | +25.3 |
| SWE-agent | 1,200 | 67.7 | 70.5 | +2.8 |
| tau2-bench (tel) | 1,095 | 28.5 | 45.6 | +17.1 |
| tau2-bench (ret) † | 1,095 | 52.9 | 65.1 | +12.2 |
| tau2-bench (air) | 480 | 56.5 | 57.3 | +0.8 |
Appendix figures & tables39 assets
Supplementary material from the paper’s appendix.
Appendix
| Dataset | Domain | Traces | Labels | |
| Labeled (main results) | ||||
| SWE-smith | Coding | 500 | 9 | ✓ |
| SWE-agent | Coding | 2,000 | 24 ∗ | ✓ |
| WebArena | Web nav. | 8,337 | 24 | ✓ |
| AgentNet | Desktop GUI | 5,000 | 24 | ✓ |
| tau2-bench (air) | Cust. svc. | 800 ‡ | 17 | ✓ |
| Self-AUROC (diagonal) | Cross-AUROC (off-diagonal) | ||||||
|---|---|---|---|---|---|---|---|
| Suite | mean | range | mean | range | gap | ||
| airline | 0.926 | 0.051 | 0.84–0.97 | 0.773 | 0.102 | 0.56–0.92 | 0.154 |
| retail | 0.749 | 0.052 | 0.68–0.82 | 0.681 | 0.075 | 0.54–0.79 | 0.068 |
| telecom | 0.956 | 0.028 | 0.92–0.99 | 0.905 | 0.045 | 0.82–0.99 | 0.051 |
| Mean (3 suites) | 0.877 | – | – | 0.786 | – | – | 0.091 |
| Ours | RPNI | Alergia | |||||
|---|---|---|---|---|---|---|---|
| Dataset | Fit | Fit | Fit | Compr. | |||
| Who_and_When | 9 | 1.000 | 971 | 0.984 | 12 | 1.000 | 108 |
| Mind2Web | 8 | 1.000 | 476 | 0.970 | 8 | 1.000 | 60 |
| GUI-Odyssey | 7 | 1.000 | 21,255 † | 0.929 | 24 | 0.999 | 3,036 |
| Ours | k-Tails ( ) | k-Tails ( ) | ||||
|---|---|---|---|---|---|---|
| Dataset | Fit | Fit | Fit | |||
| SWE-smith | 10 | 1.000 | 22 | 1.000 | 53 | 1.000 |
| SWE-agent | 25 | 0.999 | 74 | 0.996 | 332 | 0.993 |
| WebArena | 25 | 1.000 | 30 | 0.743 | 172 | 0.743 |
| AgentNet | 25 | 1.000 | 33 | 0.806 | TO | |
| tau2-bench (air) | 18 | 1.000 | 37 | 0.973 | 731 | 0.773 |
| Main | FSM-D ablation | ||||
|---|---|---|---|---|---|
| Dataset | Holdout | Len+Ent | FSM-D | ||
| tau2-bench (tel) | 42 | 0.941 | 0.725 | 0.857 | +0.132 |
| WebArena | 24 | 0.903 | 0.718 | 0.773 | +0.056 |
| AgentNet | 24 | 0.890 | 0.724 | 0.724 | +0.000 |
| ATBench | 14 | 0.894 | 0.555 | 0.703 | +0.147 |
| tau2-bench (air) | 17 | 0.864 | 0.625 | 0.777 | +0.152 |
| CV AUROC | Holdout AUROC | |||
|---|---|---|---|---|
| Dataset | Ours | Alergia | Ours | Alergia |
| tau2-bench (tel) | 0.923 | 0.748 | 0.915 | 0.752 |
| WebArena | 0.864 | 0.844 | 0.888 | 0.868 |
| AgentNet | 0.871 | 0.871 | 0.872 | 0.872 |
| SWE-agent | 0.790 | 0.709 | 0.805 | 0.714 |
| tau2-bench (air) | 0.792 | 0.664 | 0.826 | 0.764 |
| MLP | GRU | Transformer | ||||
|---|---|---|---|---|---|---|
| Dataset | Seq | FSM | Seq | FSM | Seq | FSM |
| SWE-smith | 0.663 | 0.699 | 0.683 | 0.700 | 0.649 | 0.665 |
| SWE-agent | 0.782 | 0.790 | 0.762 | 0.793 | 0.779 | 0.751 |
| tau2-tel | 0.962 | 0.969 | 0.958 | 0.970 | 0.964 | 0.967 |
| tau2-air | 0.816 | 0.839 | 0.793 | 0.815 | 0.819 | 0.845 |
| tau2-ret | 0.747 | 0.800 | 0.698 | 0.789 | 0.755 | 0.798 |
| Ours | RPNI | |||
|---|---|---|---|---|
| Dataset | Rand. | Perm. | Rand. | Perm. |
| SWE-smith | 0.0% | 0.1% | 0.0% | 0.0% |
| SWE-agent | 0.0% | 0.05% | 0.0% | 1.6% |
| WebArena | 0.0% | 0.02% | 0.2% | 75.3% |
| AgentNet | 0.0% | 0.02% | 0.2% | 0.9% |
| tau2-bench (air) | 0.0% | 0.0% | 0.0% | 11.5% |
| Dataset | Subst. | Insert | Delete | Swap | Suffix |
|---|---|---|---|---|---|
| SWE-smith | 81 | 100 | 98 | 100 | 100 |
| SWE-agent | 87 | 100 | 97 | 100 | 97 |
| tau2-tel | 77 | 96 | 61 | 93 | 100 |
| tau2-air | 78 | 90 | 77 | 93 | 97 |
| tau2-ret | 79 | 92 | 80 | 95 | 100 |
| WebArena | 100 | 96 | 84 | 100 | 68 |
| Alpha Miner | Heuristic Miner | Inductive Miner | |||||||
|---|---|---|---|---|---|---|---|---|---|
| Dataset | p/t | Fit | Prec | p/t | Fit | Prec | p/t | Fit | Prec |
| Who_and_When | 3/8 | 0.37 | 0.19 | 10/23 | 1.00 | 0.31 | 16/24 | 1.00 | 0.27 |
| SWE-smith | 7/9 | 0.15 | 0.20 | 13/22 | 1.00 | 0.36 | 25/33 | 1.00 | 0.23 |
| Mind2Web | 2/7 | 0.63 | 0.29 | 15/29 | 0.96 | 0.45 | 23/30 | 1.00 | 0.32 |
| SWE-agent | 12/24 | 0.05 | 0.00 | 21/59 | 1.00 | 0.20 | 44/70 | 1.00 | 0.13 |
| tau2-bench (air) | 3/17 | 0.45 | 0.24 | 15/37 | 0.95 | 0.20 | 63/93 | 1.00 | 0.17 |
| Convergence | Gen. gap (train test) | |||||||
|---|---|---|---|---|---|---|---|---|
| Dataset | Train | 0.99 at | Frac | 10% | 30% | 60% | 100% | |
| Who_and_When | 147 | 8 | 5% | 9 | +0.002 | +0.001 | 0 | 0 |
| SWE-smith | 400 | 40 | 10% | 10 | 0.002 | 0.001 | 0 | 0.001 |
| Mind2Web | 400 | 20 | 5% | 8 | 0.003 | 0.001 | 0 | 0 |
| SWE-agent | 1,600 | 240 | 15% | 25 | 0.002 | 0.001 | 0.001 | +0.001 |
| Dataset | Drop 0 1 | ||||
|---|---|---|---|---|---|
| SWE-agent | 2.16 | 1.06 | 0.80 | 0.79 | 51% |
| SWE-smith | 1.98 | 0.63 | 0.55 | 0.55 | 68% |
| Mind2Web | 1.69 | 0.74 | 0.79 | 0.68 | 56% |
| Fraction | SWE-agent | SWE-smith | ||
|---|---|---|---|---|
| FSM | Base | FSM | Base | |
| 10% | 0.657 | 0.400 | 0.722 | 0.416 |
| 25% | 0.656 | 0.456 | 0.687 | 0.693 |
| 50% | 0.726 | 0.677 | 0.681 | 0.668 |
| 75% | 0.726 | 0.672 | 0.688 | 0.685 |
| 100% | 0.773 | 0.753 | 0.682 | 0.692 |
| Dataset | Level | Fit | AUROC | |
|---|---|---|---|---|
| SWE-smith | role-only | 4 | 1.000 | 0.688 |
| role-type | 9 | 1.000 | 0.692 | |
| role-action | 9 | 1.000 | 0.692 | |
| tool-only | 9 | 1.000 | 0.692 | |
| SWE-agent | role-only | 2 | 1.000 | 0.663 |
| role-type | 18 | 0.999 | 0.659 |
| Dataset | Rule | Prec. | Recall | F1 |
|---|---|---|---|---|
| SWE-agent | cycle-rate | 0.956 | 0.451 | 0.613 |
| SWE-smith | cycle-rate | 0.267 | 0.750 | 0.393 |
| Dataset | FSM feat. | Trans. CE | Likelihood | N-gram |
|---|---|---|---|---|
| SWE-agent | 0.813 | 0.452 | 0.626 | 0.317 |
| SWE-smith | 0.718 | 0.719 | 0.711 | 0.622 |
| Dataset | ProbGuard ( Wang et al., 2025b ) | FSM features (ours) | |
|---|---|---|---|
| -bench (tel) | 0.709 | 0.941 | +0.232 |
| -bench (air) | 0.723 | 0.864 | +0.141 |
| -bench (ret) | 0.566 | 0.779 | +0.213 |
| SWE-agent | 0.683 | 0.799 | +0.116 |
| SWE-smith | 0.525 | 0.703 | +0.178 |
| Mean (5 shared datasets) | 0.641 | 0.817 | +0.176 |
| Dataset | Subst. | Insert. | Swap | Trunc. | Base |
|---|---|---|---|---|---|
| SWE-smith | 0.658 | 0.825 | 0.892 | 1.000 | 1.000 |
| SWE-agent | 0.818 | 0.885 | 0.938 | 0.999 | 0.999 |
| Mind2Web | 0.881 | 0.985 | 0.999 | 1.000 | 1.000 |
| Who&When | 0.828 | 0.865 | 1.000 | 1.000 | 1.000 |
| Dataset | Steps | Unigram | FSM | AWM | AWM cov. |
|---|---|---|---|---|---|
| SWE-smith | 5,500 | 50.0 | 100.0 | 34.5 | 34.5% |
| WebArena | 17,146 | 26.2 | 81.1 | 81.0 | 92.9% |
| SWE-agent | 22,288 | 49.1 | 65.7 | 26.6 | 57.0% |
| tau2 (tel) | 23,055 | 33.0 | 61.8 | 19.8 | 59.0% |
| tau2 (air) | 4,020 | 30.8 | 69.2 | 55.9 | 91.3% |
| tau2 (ret) | 10,207 | 27.4 | 72.6 | 63.5 | 91.4% |
| Test dataset | |||
| Train | Features | SWE-sm | SWE-ag |
| SWE-smith | FSM | 0.681 | 0.715 |
| Raw | 0.694 | 0.683 | |
| SWE-agent | FSM | 0.648 | 0.780 |
| Raw | 0.682 | 0.720 | |
| Dataset | 10% | 20% | 30% | 50% | 100% |
|---|---|---|---|---|---|
| SWE-smith | 0.502 | 0.662 | 0.703 | 0.660 | 0.685 |
| SWE-agent | 0.806 | 0.791 | 0.812 | 0.818 | 0.795 |
| Dataset | DecPts | Succ paths | Fail paths | Overlap | Top JSD |
|---|---|---|---|---|---|
| SWE-agent | 7 | 275 | 1,496 | 41 | 0.014 |
| SWE-smith | 5 | 330 | 123 | 11 | 0.021 |
| Dataset | FSM bits | Raw bits | MDL | Gzip | ||
|---|---|---|---|---|---|---|
| SWE-smith | 9 | 10 | 108 | 107,704 | 0.001 | 0.012 |
| SWE-agent | 27 | 25 | 340 | 556,450 | 0.001 | 0.018 |
| Mind2Web | 7 | 8 | 87 | 12,786 | 0.007 | 0.026 |
| Who&When | 8 | 9 | 99 | 12,276 | 0.008 | 0.019 |
| Path diversity | RQA (AUROC) | |||||||
|---|---|---|---|---|---|---|---|---|
| Dataset | Traces | Unique | Sing.% | Top-5% | RR | DET | maxDiag | diagEnt |
| SWE-smith | 500 | 442 | 82.0 | 5.8 | 0.662 | 0.643 | 0.631 | 0.599 |
| SWE-agent | 2,000 | 1,730 | 82.0 | 5.1 | 0.695 | 0.694 | 0.695 | 0.704 |
| tau2-tel | 1,824 | 5 | 0.0 | 100.0 | 0.562 | 0.563 | 0.562 | 0.566 |
| tau2-air | 800 | 624 | 67.5 | 6.4 | 0.511 | 0.338 | 0.566 | 0.612 |
| tau2-ret | 1,824 | 1,521 | 73.2 | 2.0 | 0.574 | 0.471 | 0.520 | 0.521 |
| Dataset | State | Visit% | Fitness drop |
|---|---|---|---|
| SWE-smith | system:text | 1.9 | 1.000 |
| user:text | 1.9 | 0.979 | |
| asst:tool:bash | 21.3 | 0.958 | |
| SWE-agent | user:text | 49.9 | 0.999 |
| edit:text | 16.6 | 0.344 | |
| search:text | 11.5 | 0.208 |
| Loops (backedges) | Graph motifs | |||||||
|---|---|---|---|---|---|---|---|---|
| Dataset | Succ | Fail | Ratio | AUROC | Self | Bidir | Tri | Hub deg |
| SWE-agent | 25.3 | 54.8 | 2.17 | 0.665 | 0 | 11 | 0 | 15 |
| SWE-smith | 43.6 | 60.7 | 1.39 | 0.654 | 0 | 6 | 0 | 7 |
| tau2-tel | 1.9 | 1.9 | 1.00 | 0.562 | 1 | 2 | 2 | 4 |
| tau2-air | 17.1 | 21.5 | 1.26 | 0.664 | 1 | 14 | 0 | 15 |
| tau2-ret | 20.3 | 21.0 | 1.03 | 0.537 | 1 | 15 | 0 | 16 |
| Critical transitions | |||
|---|---|---|---|
| Dataset | Transition | Freq | Criticality |
| SWE-smith | str_repl tool:text | 12.96 | 1.048 |
| SWE-smith | tool:text str_repl | 12.96 | 1.045 |
| SWE-agent | user:text edit:text | 9.20 | 0.657 |
| SWE-agent | edit:text user:text | 9.02 | 0.629 |
| Error localization (per-state error rate differential) | |||
| Dataset | Early | Mid | Late | Drift |
|---|---|---|---|---|
| SWE-agent | 1.83 | 1.55 | 1.69 | 0.15 |
| SWE-smith | 2.17 | 1.45 | 1.72 | 0.44 |
| tau2-tel | 1.39 | 0.95 | 0.97 | 0.42 |
| tau2-air | 2.17 | 1.82 | 1.95 | 0.21 |
| tau2-ret | 2.32 | 2.00 | 2.03 | 0.29 |
| GUI-Ody | 1.23 | 0.63 | 1.19 | 0.04 |
| Anomaly detection | Suffix (last ) | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Dataset | Rej | Occ | Term | Cyc | Comp | P@10 | ||||
| SWE-agent | 0.563 | 0.707 | 0.711 | 0.697 | 0.747 | 1.00 | 0.693 | 0.746 | 0.771 | 0.825 |
| SWE-smith | 0.406 | 0.605 | 0.429 | 0.679 | 0.653 | 0.20 | 0.540 | 0.546 | 0.550 | 0.590 |
| Dataset | Prec | Recall | F1 | Latency | Saved | Steps saved | Lift |
|---|---|---|---|---|---|---|---|
| SWE-agent | 85.9% | 95.5% | 0.904 | 32% | 68% | 16,711 | 1.02 |
| tau2-bench (air) | 76.0% | 79.2% | 0.776 | 56% | 44% | 325 | 1.27 |
| tau2-bench (ret) | 31.0% | 60.0% | 0.409 | 63% | 37% | 247 | 0.95 |
| SWE-smith | 16.0% | 100.0% | 0.276 | 17% | 83% | 936 | 1.00 |
| Threshold | Precision | Recall | F1 | Mean latency |
|---|---|---|---|---|
| 0.750 (p30) | 86.4% | 85.2% | 0.858 | 39% |
| 0.842 (p50) | 90.5% | 65.3% | 0.759 | 47% |
| 0.917 (p70) | 95.6% | 38.9% | 0.553 | 63% |
| 0.957 (p90) | 100.0% | 11.3% | 0.203 | 59% |
| Dataset | Features | CV AUROC | Holdout | |
|---|---|---|---|---|
| SWE-agent | bag (freq.) | 24 | 0.702 0.030 | 0.694 |
| bigram (trans.) | 62 | 0.699 0.029 | 0.698 | |
| stats (seq.) | 6 | 0.757 0.027 | 0.782 | |
| all-seq (LR) | 92 | 0.771 0.027 | 0.793 | |
| all-seq (MLP) | 92 | 0.711 0.044 | 0.764 | |
| FSM per-state | 34 | 0.790 0.021 | 0.813 |
AI Agent Monitoring
AI agent monitoring tracks actions, tool use, and execution traces to detect failures, misuse, drift, and policy violations during operation.
See all 271 papers