Overview
Stately Expert is a framework for building AI agents that combines state machines with large language models to create more structured and intelligent autonomous systems. Unlike traditional LLM-based agents that rely solely on prompt engineering, Stately Expert uses XState-powered state machines to guide agent behavior through defined states and transitions. The framework incorporates observations, feedback, and insights to enable agents to learn from past experiences and improve decision-making over time. Built on top of the Vercel AI SDK, it supports multiple model providers including OpenAI, Anthropic, Google, Mistral, and others. Agents can maintain context across interactions, follow structured workflows, and adapt their behavior based on rewards and feedback. This approach is particularly valuable for applications requiring predictable behavior patterns, compliance with specific processes, or systems that need to improve through experience rather than just responding to immediate prompts.
Pros
- + State machine structure provides predictable, auditable agent behavior with clear transition logic
- + Learning capabilities through observations and feedback enable agents to improve performance over time
- + Flexible model provider support via Vercel AI SDK integration allows switching between different LLMs
Cons
- - Higher complexity compared to simple prompt-based agents, requiring knowledge of both XState and AI concepts
- - Documentation appears incomplete with placeholder sections for key setup instructions
- - State machine approach may be overkill for simple conversational agents or basic AI tasks
Use Cases
- • Customer service chatbots that need to follow specific escalation workflows and remember interaction history
- • Game AI characters that must exhibit consistent behavior patterns while adapting to player actions
- • Automated support systems requiring structured decision trees with learning from resolution outcomes