Researchers convert agent execution traces into compact finite-state machines containing 7 to 43 states that reconstruct held-out data with 0.997 or higher fitness. The approach outperforms existing memory-based methods for predicting an agent’s next action and achieves up to 0.94 AUROC for failure detection. The resulting finite-state-machine substrate enables runtime monitoring that can trigger early stopping by identifying failing execution paths before task completion.