Expand description
Session typestate for compile-time safety of stateful LLM session lifecycle.
Uses the typestate pattern to make invalid state transitions uncompilable. Sessions track stateful LLM connections where only deltas (new messages) are sent after the initial context, avoiding the “Groundhog Day” problem of re-sending full context every tool call.
§State Transition Diagram
Session::new() → Created ── activate() ──→ Active ── close() ──→ Closed (terminal)
│
record_delta() ↺
│
expire() ──→ Expired (terminal)Modules§
- private 🔒
Structs§
- Active
- Session is active and accepting deltas.
- Closed
- Session was closed normally (terminal).
- Created
- Session has been created but not yet activated.
- Session
- A stateful LLM session with compile-time state tracking.
- Session
Expired - Session expired due to TTL (terminal).
- Session
Record - Internal data storage for a session, independent of typestate. This is what gets persisted to the database.
- Stored
Session - A session as stored in the database (status-agnostic).
Enums§
- Loaded
Session - Enum representing all possible runtime states of a session. Use this when you need to handle sessions loaded from the database.
- Session
State Error - Errors when transitioning session states.
- Session
Status - Status of a stateful LLM session.
Traits§
- Session
State - Marker trait for session states.