Documentation
¶
Overview ¶
Package session provides in-memory conversation session management for the chatbot. Sessions are keyed by ID and hold a sliding window of messages.
Design ref: docs/chatbot-design-spec.md §5.3
Index ¶
Constants ¶
const DefaultMaxMessages = 40
DefaultMaxMessages is the maximum number of messages kept per session.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is a concurrent-safe session store. Sessions are held in memory and are lost on process restart.
func NewManager ¶
NewManager creates a new session manager.
func (*Manager) GetOrCreate ¶
GetOrCreate returns the session for the given ID, creating it if needed. If id is empty, a new session with a generated ID is created.
type Session ¶
type Session struct {
ID string
Messages []llm.Message
CreatedAt time.Time
UpdatedAt time.Time
// contains filtered or unexported fields
}
Session holds the conversation state for a single chat session.
func (*Session) AddMessage ¶
AddMessage appends a message and trims the window if needed. Tool call/result pairs are kept together: we always trim from the front, skipping the system messages.