Skip to main content
Create a chatbot that persists conversation history using SQLite, so users can continue where they left off.

Full Example

How It Works

Composition over Inheritance

The Agent class uses composition for storage. Instead of inheriting from a specific storage agent, you pass a storage backend to the constructor:

Automatic Persistence

When using async with agent:, the agent automatically:
  1. Loads state and messages from storage on start.
  2. Saves messages after every chat() or stream() call.
  3. Saves state whenever set_state() or update_state() is called.