Documentation
¶
Index ¶
- type JSONLBackend
- func (b *JSONLBackend) AddFullMessage(sessionKey string, msg providers.Message)
- func (b *JSONLBackend) AddMessage(sessionKey, role, content string)
- func (b *JSONLBackend) Close() error
- func (b *JSONLBackend) GetHistory(key string) []providers.Message
- func (b *JSONLBackend) GetSummary(key string) string
- func (b *JSONLBackend) Save(key string) error
- func (b *JSONLBackend) SetHistory(key string, history []providers.Message)
- func (b *JSONLBackend) SetSummary(key, summary string)
- func (b *JSONLBackend) TruncateHistory(key string, keepLast int)
- type Session
- type SessionManager
- func (sm *SessionManager) AddFullMessage(sessionKey string, msg providers.Message)
- func (sm *SessionManager) AddMessage(sessionKey, role, content string)
- func (sm *SessionManager) Close() error
- func (sm *SessionManager) GetHistory(key string) []providers.Message
- func (sm *SessionManager) GetOrCreate(key string) *Session
- func (sm *SessionManager) GetSummary(key string) string
- func (sm *SessionManager) Save(key string) error
- func (sm *SessionManager) SetHistory(key string, history []providers.Message)
- func (sm *SessionManager) SetSummary(key string, summary string)
- func (sm *SessionManager) TruncateHistory(key string, keepLast int)
- type SessionStore
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type JSONLBackend ¶ added in v0.2.2
type JSONLBackend struct {
// contains filtered or unexported fields
}
JSONLBackend adapts a memory.Store into the SessionStore interface. Write errors are logged rather than returned, matching the fire-and-forget contract of SessionManager that the agent loop relies on.
func NewJSONLBackend ¶ added in v0.2.2
func NewJSONLBackend(store memory.Store) *JSONLBackend
NewJSONLBackend wraps a memory.Store for use as a SessionStore.
func (*JSONLBackend) AddFullMessage ¶ added in v0.2.2
func (b *JSONLBackend) AddFullMessage(sessionKey string, msg providers.Message)
func (*JSONLBackend) AddMessage ¶ added in v0.2.2
func (b *JSONLBackend) AddMessage(sessionKey, role, content string)
func (*JSONLBackend) Close ¶ added in v0.2.2
func (b *JSONLBackend) Close() error
Close releases resources held by the underlying store.
func (*JSONLBackend) GetHistory ¶ added in v0.2.2
func (b *JSONLBackend) GetHistory(key string) []providers.Message
func (*JSONLBackend) GetSummary ¶ added in v0.2.2
func (b *JSONLBackend) GetSummary(key string) string
func (*JSONLBackend) Save ¶ added in v0.2.2
func (b *JSONLBackend) Save(key string) error
Save persists session state. Since the JSONL store fsyncs every write immediately, the data is already durable. Save runs compaction to reclaim space from logically truncated messages (no-op when there are none).
func (*JSONLBackend) SetHistory ¶ added in v0.2.2
func (b *JSONLBackend) SetHistory(key string, history []providers.Message)
func (*JSONLBackend) SetSummary ¶ added in v0.2.2
func (b *JSONLBackend) SetSummary(key, summary string)
func (*JSONLBackend) TruncateHistory ¶ added in v0.2.2
func (b *JSONLBackend) TruncateHistory(key string, keepLast int)
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
func NewSessionManager ¶
func NewSessionManager(storage string) *SessionManager
func (*SessionManager) AddFullMessage ¶ added in v0.1.1
func (sm *SessionManager) AddFullMessage(sessionKey string, msg providers.Message)
AddFullMessage adds a complete message with tool calls and tool call ID to the session. This is used to save the full conversation flow including tool calls and tool results.
func (*SessionManager) AddMessage ¶
func (sm *SessionManager) AddMessage(sessionKey, role, content string)
func (*SessionManager) Close ¶ added in v0.2.2
func (sm *SessionManager) Close() error
Close is a no-op for the in-memory SessionManager; it satisfies the SessionStore interface so callers can release resources uniformly.
func (*SessionManager) GetHistory ¶
func (sm *SessionManager) GetHistory(key string) []providers.Message
func (*SessionManager) GetOrCreate ¶
func (sm *SessionManager) GetOrCreate(key string) *Session
func (*SessionManager) GetSummary ¶ added in v0.1.1
func (sm *SessionManager) GetSummary(key string) string
func (*SessionManager) Save ¶
func (sm *SessionManager) Save(key string) error
func (*SessionManager) SetHistory ¶ added in v0.1.2
func (sm *SessionManager) SetHistory(key string, history []providers.Message)
SetHistory updates the messages of a session.
func (*SessionManager) SetSummary ¶ added in v0.1.1
func (sm *SessionManager) SetSummary(key string, summary string)
func (*SessionManager) TruncateHistory ¶ added in v0.1.1
func (sm *SessionManager) TruncateHistory(key string, keepLast int)
type SessionStore ¶ added in v0.2.2
type SessionStore interface {
// AddMessage appends a simple role/content message to the session.
AddMessage(sessionKey, role, content string)
// AddFullMessage appends a complete message including tool calls.
AddFullMessage(sessionKey string, msg providers.Message)
// GetHistory returns the full message history for the session.
GetHistory(key string) []providers.Message
// GetSummary returns the conversation summary, or "" if none.
GetSummary(key string) string
// SetSummary replaces the conversation summary.
SetSummary(key, summary string)
// SetHistory replaces the full message history.
SetHistory(key string, history []providers.Message)
// TruncateHistory keeps only the last keepLast messages.
TruncateHistory(key string, keepLast int)
// Save persists any pending state to durable storage.
Save(key string) error
// Close releases resources held by the store.
Close() error
}
SessionStore defines the persistence operations used by the agent loop. Both SessionManager (legacy JSON backend) and JSONLBackend satisfy this interface, allowing the storage layer to be swapped without touching the agent loop code.
Write methods (Add*, Set*, Truncate*) are fire-and-forget: they do not return errors. Implementations should log failures internally. This matches the original SessionManager contract that the agent loop relies on.