Expand description
Session persistence layer
Provides pluggable session storage via the SessionStore trait.
§Default Implementation
FileSessionStore stores each session as a JSON file:
- Session metadata (id, name, timestamps)
- Configuration (system prompt, policies)
- Conversation history (messages)
- Context usage statistics
§Custom Backends
Implement SessionStore trait for custom backends (Redis, PostgreSQL, etc.):
ⓘ
use a3s_code::store::{
SessionData, SessionSnapshotV1, SessionStore, SessionStoreCapabilities,
};
struct RedisStore { /* ... */ }
#[async_trait::async_trait]
impl SessionStore for RedisStore {
// Required by AgentSession::save: commit the entire value in one
// backend transaction / atomic replacement.
async fn save_snapshot(&self, snapshot: &SessionSnapshotV1) -> Result<()> { /* ... */ }
async fn load_snapshot(&self, id: &str) -> Result<Option<SessionSnapshotV1>> { /* ... */ }
fn capabilities(&self) -> SessionStoreCapabilities {
SessionStoreCapabilities { atomic_session_snapshots: true }
}
// Legacy fragment APIs remain available for migration compatibility.
async fn save(&self, session: &SessionData) -> Result<()> { /* ... */ }
async fn load(&self, id: &str) -> Result<Option<SessionData>> { /* ... */ }
async fn delete(&self, id: &str) -> Result<()> { /* ... */ }
async fn list(&self) -> Result<Vec<String>> { /* ... */ }
async fn exists(&self, id: &str) -> Result<bool> { /* ... */ }
}Structs§
- Context
Usage - Context usage statistics persisted with saved sessions.
- File
Session Store - File-based session store.
- LlmConfig
Data - Serializable LLM configuration
- Memory
Session Store - In-memory session store for testing
- Session
Config - Serializable session configuration.
- Session
Data - Serializable session data for persistence
- Session
Snapshot V1 - A complete, versioned persistence generation for one session.
- Session
Store Capabilities - Persistence guarantees advertised by a session store implementation.
Enums§
- Session
State - Session state persisted with saved sessions.
Constants§
- DEFAULT_
AUTO_ COMPACT_ THRESHOLD - Default auto-compact threshold (80% of context window).
- SESSION_
SNAPSHOT_ SCHEMA_ VERSION - Schema version written by
SessionSnapshotV1.
Traits§
- Session
Store - Session storage trait