Full Example
How It Works
Composition over Inheritance
TheAgent class uses composition for storage. Instead of inheriting from a specific storage agent, you pass a storage backend to the constructor:
Automatic Persistence
When usingasync with agent:, the agent automatically:
- Loads state and messages from storage on start.
- Saves messages after every
chat()orstream()call. - Saves state whenever
set_state()orupdate_state()is called.