pub trait SessionStore:
Send
+ Sync
+ 'static {
// Required methods
fn save_state<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
state: &'life2 AgentCheckpointState,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait;
fn load_state<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<AgentCheckpointState>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete_state<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
}Expand description
Hot-state store for in-flight Agent Loop checkpoints.
The local default implementation is NoopSessionStore — a zero-cost
no-op that never persists anything. Cloud implementations write to Redis
with a short TTL to enable crash recovery across pod restarts.
§Semantics
- Checkpoint failures are non-fatal by design: the Agent Loop MUST NOT
abort because a
save_statecall failed. Callers should log the error and continue. load_statereturnsOk(None)when no checkpoint exists (new session).delete_stateis idempotent: deleting a non-existent key isOk(()).
Uses #[async_trait] so it is dyn-compatible (Arc<dyn SessionStore>).
Required Methods§
Sourcefn save_state<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
state: &'life2 AgentCheckpointState,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn save_state<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
state: &'life2 AgentCheckpointState,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Persist the current loop state for a session.
Called after each tool execution. Failures should be treated as warnings, not errors.
Sourcefn load_state<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<AgentCheckpointState>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn load_state<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Option<AgentCheckpointState>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Load the most recent checkpoint for a session.
Returns Ok(None) if no checkpoint exists (fresh session or already
cleaned up).
Sourcefn delete_state<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_state<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Remove all checkpoint state for a session.
Should be called after the Agent Loop finishes (success or failure) to avoid stale state in Redis/KV.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".