Available Drivers
Driver Chain (Fallback Pattern)
LarAgentStorage classes support configuring multiple drivers in a chain. The first driver is the primary, and subsequent drivers serve as fallbacks:
- Reading: Tries the primary driver first. If it returns no data, falls back to the next driver.
- Writing: Writes to all drivers in the chain to keep them synchronized.
- Removing: Removes from all drivers.
InMemoryStorage
Stores data in PHP memory. Data is lost after the request ends. Ideal for testing or single-request agents.There is no point in using InMemoryStorage with other storage drivers in a fallback chain.
SessionStorage
Uses Laravel’s session to store data. Perfect for web applications where context should persist across user requests.CacheStorage
Uses Laravel’s cache system. Supports different cache stores like Redis, Memcached, or file.Custom configuration
Custom configuration
MyAgent
FileStorage
Stores data as JSON files on disk using Laravel’s filesystem.Custom configuration
Custom configuration
MyAgent
EloquentStorage
Stores each item as a separate database row. Best for applications that need to query individual messages or require advanced database features.Example here uses
historyStorageDrivers instead of defaultStorageDrivers to show chat history specific laravel model override.Custom configuration
Custom configuration
MyAgent
Additional methods:
Custom model example
Custom model example
SimpleEloquentStorage
Stores all data as a JSON blob in a single database row. Simple setup, good for basic use cases.Custom configuration
Custom configuration
MyAgent
Custom model example
Custom model example
Selection Guide
Next Steps
Chat History
Configure chat history storage and truncation strategies.
Usage Tracking
Track token usage and costs with storage drivers.

