Skip to main content

rskit_agent/memory/
traits.rs

1use async_trait::async_trait;
2use rskit_errors::AppError;
3use rskit_llm::types::Message;
4
5// ── Memory trait ────────────────────────────────────────────────────────────
6
7/// Async conversation memory backend.
8#[async_trait]
9pub trait Memory: Send + Sync {
10    /// Load all messages for a session.
11    async fn load(&self, session_id: &str) -> Result<Vec<Message>, AppError>;
12
13    /// Replace the entire message list for a session.
14    async fn save(&self, session_id: &str, messages: &[Message]) -> Result<(), AppError>;
15
16    /// Append messages to an existing session (creating it if needed).
17    async fn append(&self, session_id: &str, messages: &[Message]) -> Result<(), AppError>;
18
19    /// Remove all messages for a session.
20    async fn clear(&self, session_id: &str) -> Result<(), AppError>;
21}