State-machine-powered LLM agents with XState: the machine owns control flow, the model only picks legal events, so invalid agent actions are impossible by construction.