SessionManager

org.llm4s.assistant.SessionManager
class SessionManager(sessionDir: DirectoryPath, agent: Agent)

Manages session persistence for the interactive assistant.

SessionManager handles saving and loading conversation sessions to disk, enabling users to resume previous conversations and maintain context across multiple interactions.

== Key Features ==

  • '''Session Save''': Persists AgentState as JSON with markdown companion
  • '''Session Load''': Restores sessions with tool registry reconstruction
  • '''Session Listing''': Shows recent sessions sorted by modification time
  • '''Filename Sanitization''': Safely handles special characters in titles

== Storage Format == Sessions are stored as two files:

  • {title}.json - Machine-readable session state for loading
  • {title}.md - Human-readable markdown for viewing/sharing

== Usage Example ==

val manager = new SessionManager(DirectoryPath("/path/to/sessions"), agent)

// Save current session
val info = manager.saveSession(sessionState, Some("My Conversation"))

// List recent sessions
val sessions = manager.listRecentSessions(limit = 5)

// Load a previous session
val loaded = manager.loadSession("My Conversation", tools)

Value parameters

agent

Agent instance for markdown formatting

sessionDir

Directory path where sessions are stored

Attributes

See also

SessionState for the state being persisted

SessionInfo for session metadata returned after save

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def listRecentSessions(limit: Int): Either[AssistantError, Seq[String]]

Lists recent sessions for welcome screen display

Lists recent sessions for welcome screen display

Attributes

def loadSession(sessionTitle: String, tools: ToolRegistry): Either[AssistantError, SessionState]

Loads a session from JSON file by title

Loads a session from JSON file by title

Attributes

def saveSession(state: SessionState, title: Option[String]): Either[AssistantError, SessionInfo]

Saves a session in both JSON and markdown formats

Saves a session in both JSON and markdown formats

Attributes