agent

Create state-machine-powered LLM agents using XState

open-sourceagent-frameworks
Visit WebsiteView on GitHub
341
Stars
+28
Stars/month
0
Releases (6m)

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

Getting Started

Install the Stately Expert framework via npm, define a state machine using XState syntax with states and transitions for your agent's workflow, then create an agent instance that combines your state machine with an LLM provider from the Vercel AI SDK