meerkat_core/checkpoint.rs
1//! Session checkpointing trait for periodic persistence.
2//!
3//! Host-mode agents run indefinitely, so the normal post-turn persistence path
4//! (`PersistentSessionService::persist_full_session`) never fires after the
5//! initial `create_session`. This trait allows the agent to checkpoint the
6//! session after each keep-alive interaction.
7
8use crate::session::Session;
9use async_trait::async_trait;
10
11/// Periodic session persistence hook.
12///
13/// Implementations clone what they need from the borrowed `Session`.
14/// Errors are logged, not propagated — a checkpoint failure should not
15/// kill the agent loop.
16#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
17#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
18pub trait SessionCheckpointer: Send + Sync {
19 /// Save a snapshot of the current session state.
20 async fn checkpoint(&self, session: &Session);
21}