pub trait SessionStore: Send + Sync {
Show 13 methods
// Required methods
fn create_session<'life0, 'async_trait>(
&'life0 self,
session: Session,
) -> Pin<Box<dyn Future<Output = StoreResult<Session>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn list_sessions<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<Session>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn get_session<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<Option<Session>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn delete_session<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn append_message<'life0, 'async_trait>(
&'life0 self,
message: MessageRecord,
) -> Pin<Box<dyn Future<Output = StoreResult<MessageRecord>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn list_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<MessageRecord>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn update_usage<'life0, 'life1, 'async_trait>(
&'life0 self,
message_id: &'life1 Uuid,
usage: TokenUsage,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn update_session<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
id: &'life1 Uuid,
title: &'life2 str,
model: Option<&'life3 ModelName>,
) -> Pin<Box<dyn Future<Output = StoreResult<Session>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait { ... }
fn list_sessions_paginated<'life0, 'async_trait>(
&'life0 self,
pagination: Pagination,
filter: SessionFilter,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<Session>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn list_messages_paginated<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 Uuid,
pagination: Pagination,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<MessageRecord>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn get_latest_compaction<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<Option<MessageRecord>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn mark_compacted<'life0, 'life1, 'async_trait>(
&'life0 self,
_message_id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Persists conversation sessions and their message history.
Implementations must be Send + Sync to support concurrent access
from the agent runtime. Backends are selected at compile time via
Cargo feature flags.
Required Methods§
Sourcefn create_session<'life0, 'async_trait>(
&'life0 self,
session: Session,
) -> Pin<Box<dyn Future<Output = StoreResult<Session>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create_session<'life0, 'async_trait>(
&'life0 self,
session: Session,
) -> Pin<Box<dyn Future<Output = StoreResult<Session>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Persists a new session and returns it with server-assigned fields.
Sourcefn list_sessions<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<Session>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_sessions<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<Session>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns all sessions ordered by most recently updated (descending).
Sourcefn get_session<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<Option<Session>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_session<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<Option<Session>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns a session by identifier, or None if not found.
Sourcefn delete_session<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn delete_session<'life0, 'life1, 'async_trait>(
&'life0 self,
id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Deletes a session and all related data (cascading delete).
Implementations MUST cascade the deletion to at minimum:
- All messages belonging to the session
- All tool executions belonging to the session
- All usage records belonging to the session
Embedding associations should be set to NULL or deleted.
Artifacts associated with the session should be deleted.
This operation is idempotent: deleting a non-existent session succeeds silently.
Sourcefn append_message<'life0, 'async_trait>(
&'life0 self,
message: MessageRecord,
) -> Pin<Box<dyn Future<Output = StoreResult<MessageRecord>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn append_message<'life0, 'async_trait>(
&'life0 self,
message: MessageRecord,
) -> Pin<Box<dyn Future<Output = StoreResult<MessageRecord>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Appends a message to a session’s history.
Sourcefn list_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<MessageRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_messages<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<MessageRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns all messages for a session ordered by creation time.
Sourcefn update_usage<'life0, 'life1, 'async_trait>(
&'life0 self,
message_id: &'life1 Uuid,
usage: TokenUsage,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn update_usage<'life0, 'life1, 'async_trait>(
&'life0 self,
message_id: &'life1 Uuid,
usage: TokenUsage,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Updates token usage on an existing message record.
Provided Methods§
Sourcefn update_session<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
id: &'life1 Uuid,
title: &'life2 str,
model: Option<&'life3 ModelName>,
) -> Pin<Box<dyn Future<Output = StoreResult<Session>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn update_session<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
id: &'life1 Uuid,
title: &'life2 str,
model: Option<&'life3 ModelName>,
) -> Pin<Box<dyn Future<Output = StoreResult<Session>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Updates a session’s title and/or model.
Fields set to None are left unchanged.
§Errors
Returns StorageError::NotFound when the session does not exist.
Default implementation returns StorageError::BackendError; backends
should override this with a proper implementation.
Sourcefn list_sessions_paginated<'life0, 'async_trait>(
&'life0 self,
pagination: Pagination,
filter: SessionFilter,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<Session>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_sessions_paginated<'life0, 'async_trait>(
&'life0 self,
pagination: Pagination,
filter: SessionFilter,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<Session>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Returns sessions matching the filter, paginated.
Default implementation calls list_sessions
and filters/paginates in memory. Backends should override with native
implementations for efficiency.
Sourcefn list_messages_paginated<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 Uuid,
pagination: Pagination,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<MessageRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_messages_paginated<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 Uuid,
pagination: Pagination,
) -> Pin<Box<dyn Future<Output = StoreResult<Vec<MessageRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns messages for a session, paginated.
Default implementation calls list_messages
and paginates in memory. Backends should override with native
implementations for efficiency.
Sourcefn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health_check<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Checks connectivity to the backend.
Returns Ok(()) if the backend is reachable and responsive.
Default implementation returns Ok(()).
Sourcefn get_latest_compaction<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<Option<MessageRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_latest_compaction<'life0, 'life1, 'async_trait>(
&'life0 self,
session_id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<Option<MessageRecord>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Returns the most recent compaction user message for a session.
Used for incremental summarization: prior compaction summaries are fed back to the compaction LLM so it can update the summary instead of regenerating from scratch.
Default implementation iterates list_messages
in reverse; backends should override with a native indexed query.
Sourcefn mark_compacted<'life0, 'life1, 'async_trait>(
&'life0 self,
_message_id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn mark_compacted<'life0, 'life1, 'async_trait>(
&'life0 self,
_message_id: &'life1 Uuid,
) -> Pin<Box<dyn Future<Output = StoreResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Marks a message as compacted, setting its is_summary flag.
Used after the compaction LLM produces a summary to signal that older tool outputs upstream of this message are eligible for pruning.
Default implementation is a no-op; backends that need to track compaction state for pruning should override.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".