Expand description
§Conversation Session Manager
Manages multi-turn conversation sessions with full CRUD, context windowing, and automatic summarisation when token budgets are exceeded.
§Overview
SessionManager stores sessions in a lock-free [DashMap], assigning
each a unique u64 ID. Each Session holds an ordered list of
Messages with per-message token counts. Context retrieval trims the
oldest non-system messages to stay within a caller-supplied token budget.
§Example
use tokio_prompt_orchestrator::session_mgr::{SessionManager, Role};
let mgr = SessionManager::default();
let id = mgr.create(Some("You are a helpful assistant.".into()));
mgr.append(id, Role::User, "Hello!".into()).unwrap();
let ctx = mgr.get_context(id, 4096).unwrap();
assert_eq!(ctx.len(), 2); // system + userStructs§
- Message
- A single message within a
Session. - Session
- A conversation session holding an ordered sequence of
Messages. - Session
Manager - Concurrent, lock-free store of
Sessions keyed byu64ID. - Session
Stats - Aggregate statistics across all sessions in a
SessionManager.
Enums§
- Role
- The speaker role of a conversation message.
- Session
Error - Errors produced by
SessionManageroperations.