Documentation
¶
Index ¶
- Constants
- Variables
- func GetEnvironmentInfo(workingDir string) string
- func ReadPromptFiles(workDir, filename string) ([]string, error)
- func ResolveSessionID(ctx context.Context, store Store, ref string) (string, error)
- type EvalCriteria
- type EvalResult
- type EvalResultChecks
- type InMemorySessionStore
- func (s *InMemorySessionStore) AddMessage(_ context.Context, sessionID string, msg *Message) (int64, error)
- func (s *InMemorySessionStore) AddSession(_ context.Context, session *Session) error
- func (s *InMemorySessionStore) AddSubSession(_ context.Context, parentSessionID string, subSession *Session) error
- func (s *InMemorySessionStore) AddSummary(_ context.Context, sessionID, summary string, firstKeptEntry int) error
- func (s *InMemorySessionStore) Close() error
- func (s *InMemorySessionStore) DeleteSession(_ context.Context, id string) error
- func (s *InMemorySessionStore) GetSession(_ context.Context, id string) (*Session, error)
- func (s *InMemorySessionStore) GetSessionSummaries(_ context.Context) ([]Summary, error)
- func (s *InMemorySessionStore) GetSessions(_ context.Context) ([]*Session, error)
- func (s *InMemorySessionStore) SetSessionStarred(_ context.Context, id string, starred bool) error
- func (s *InMemorySessionStore) UpdateMessage(_ context.Context, messageID int64, msg *Message) error
- func (s *InMemorySessionStore) UpdateSession(_ context.Context, session *Session) error
- func (s *InMemorySessionStore) UpdateSessionTitle(_ context.Context, sessionID, title string) error
- func (s *InMemorySessionStore) UpdateSessionTokens(_ context.Context, sessionID string, inputTokens, outputTokens int64, ...) error
- type Item
- type Message
- type MessageUsageRecord
- type Migration
- type MigrationManager
- type Opt
- func WithAgentName(name string) Opt
- func WithExcludedTools(names []string) Opt
- func WithHideToolResults(hideToolResults bool) Opt
- func WithID(id string) Opt
- func WithImplicitUserMessage(content string) Opt
- func WithMaxConsecutiveToolCalls(n int) Opt
- func WithMaxIterations(maxIterations int) Opt
- func WithMaxOldToolCallTokens(n int) Opt
- func WithMessages(messages []Item) Opt
- func WithNonInteractive(nonInteractive bool) Opt
- func WithParentID(parentID string) Opt
- func WithPermissions(perms *PermissionsConfig) Opt
- func WithSendUserMessage(sendUserMessage bool) Opt
- func WithSystemMessage(content string) Opt
- func WithTitle(title string) Opt
- func WithToolsApproved(toolsApproved bool) Opt
- func WithUserMessage(content string) Opt
- func WithWorkingDir(workingDir string) Opt
- type PermissionsConfig
- type RelevanceCheck
- type RelevanceCriterionResult
- type SQLiteSessionStore
- func (s *SQLiteSessionStore) AddMessage(ctx context.Context, sessionID string, msg *Message) (int64, error)
- func (s *SQLiteSessionStore) AddSession(ctx context.Context, session *Session) error
- func (s *SQLiteSessionStore) AddSubSession(ctx context.Context, parentSessionID string, subSession *Session) error
- func (s *SQLiteSessionStore) AddSummary(ctx context.Context, sessionID, summary string, firstKeptEntry int) error
- func (s *SQLiteSessionStore) Close() error
- func (s *SQLiteSessionStore) DeleteSession(ctx context.Context, id string) error
- func (s *SQLiteSessionStore) GetSession(ctx context.Context, id string) (*Session, error)
- func (s *SQLiteSessionStore) GetSessionSummaries(ctx context.Context) ([]Summary, error)
- func (s *SQLiteSessionStore) GetSessions(ctx context.Context) ([]*Session, error)
- func (s *SQLiteSessionStore) SetSessionStarred(ctx context.Context, id string, starred bool) error
- func (s *SQLiteSessionStore) UpdateMessage(ctx context.Context, messageID int64, msg *Message) error
- func (s *SQLiteSessionStore) UpdateSession(ctx context.Context, session *Session) error
- func (s *SQLiteSessionStore) UpdateSessionTitle(ctx context.Context, sessionID, title string) error
- func (s *SQLiteSessionStore) UpdateSessionTokens(ctx context.Context, sessionID string, inputTokens, outputTokens int64, ...) error
- type Session
- func (s *Session) AddMessage(msg *Message)
- func (s *Session) AddMessageUsageRecord(agentName, model string, cost float64, usage *chat.Usage)
- func (s *Session) AddSubSession(subSession *Session)
- func (s *Session) AllowedDirectories() []string
- func (s *Session) Duration() time.Duration
- func (s *Session) GetAllMessages() []Message
- func (s *Session) GetLastAssistantMessageContent() string
- func (s *Session) GetLastUserMessageContent() string
- func (s *Session) GetLastUserMessages(n int) []string
- func (s *Session) GetMessages(a *agent.Agent, extraSystemMessages ...chat.Message) []chat.Message
- func (s *Session) IsSubSession() bool
- func (s *Session) MessageCount() int
- func (s *Session) OwnCost() float64
- func (s *Session) TotalCost() float64
- type SizeCheck
- type Store
- type Summary
- type ToolCallsCheck
Constants ¶
const ( // DefaultMaxOldToolCallTokens is the default maximum number of tokens to keep from tool call // arguments and results. Older tool calls beyond this budget will have their // content replaced with a placeholder. Tokens are approximated as len/4. DefaultMaxOldToolCallTokens = 40000 )
Variables ¶
Functions ¶
func GetEnvironmentInfo ¶ added in v1.52.0
GetEnvironmentInfo returns formatted environment information including working directory, git repository status, and platform information
func ReadPromptFiles ¶ added in v1.52.0
ReadPromptFiles looks for a prompt file in the working directory hierarchy and in the user's home folder. If found in both locations, both contents are returned. The working directory content is returned first, followed by the home folder content.
func ResolveSessionID ¶
ResolveSessionID resolves a session reference to an actual session ID. Supports relative references like "-1" (last session), "-2" (second to last), etc. If the reference is not relative, it returns the input unchanged.
Types ¶
type EvalCriteria ¶
type EvalCriteria struct {
Relevance []string `json:"relevance"` // Statements that should be true about the response
WorkingDir string `json:"working_dir,omitempty"` // Subdirectory under evals/working_dirs/
Size string `json:"size,omitempty"` // Expected response size: S, M, L, XL
Setup string `json:"setup,omitempty"` // Optional sh script to run in the container before docker agent run --exec
Image string `json:"image,omitempty"` // Custom Docker image for this eval (overrides --base-image)
}
EvalCriteria contains the evaluation criteria for a session.
func (*EvalCriteria) UnmarshalJSON ¶ added in v1.32.4
func (e *EvalCriteria) UnmarshalJSON(data []byte) error
UnmarshalJSON implements custom JSON unmarshaling for EvalCriteria that rejects unknown fields. This ensures eval JSON files don't contain typos or unsupported fields that would be silently ignored.
type EvalResult ¶ added in v1.42.0
type EvalResult struct {
Passed bool `json:"passed"`
Successes []string `json:"successes,omitempty"`
Failures []string `json:"failures,omitempty"`
Error string `json:"error,omitempty"`
Cost float64 `json:"cost"`
OutputTokens int64 `json:"output_tokens"`
Checks EvalResultChecks `json:"checks"`
}
EvalResult contains the evaluation scoring outcome for a session.
type EvalResultChecks ¶ added in v1.42.0
type EvalResultChecks struct {
Size *SizeCheck `json:"size,omitempty"`
ToolCalls *ToolCallsCheck `json:"tool_calls,omitempty"`
Relevance *RelevanceCheck `json:"relevance,omitempty"`
}
EvalResultChecks groups the individual check results. Only checks that were evaluated will be present (omitted if nil).
type InMemorySessionStore ¶
type InMemorySessionStore struct {
// contains filtered or unexported fields
}
func (*InMemorySessionStore) AddMessage ¶
func (s *InMemorySessionStore) AddMessage(_ context.Context, sessionID string, msg *Message) (int64, error)
AddMessage adds a message to a session at the next position. Returns the ID of the created message (for in-memory, this is a simple counter).
func (*InMemorySessionStore) AddSession ¶
func (s *InMemorySessionStore) AddSession(_ context.Context, session *Session) error
func (*InMemorySessionStore) AddSubSession ¶
func (s *InMemorySessionStore) AddSubSession(_ context.Context, parentSessionID string, subSession *Session) error
AddSubSession creates a sub-session and links it to the parent.
func (*InMemorySessionStore) AddSummary ¶
func (s *InMemorySessionStore) AddSummary(_ context.Context, sessionID, summary string, firstKeptEntry int) error
AddSummary adds a summary item to a session at the next position.
func (*InMemorySessionStore) Close ¶
func (s *InMemorySessionStore) Close() error
Close is a no-op for in-memory stores.
func (*InMemorySessionStore) DeleteSession ¶
func (s *InMemorySessionStore) DeleteSession(_ context.Context, id string) error
func (*InMemorySessionStore) GetSession ¶
func (*InMemorySessionStore) GetSessionSummaries ¶
func (s *InMemorySessionStore) GetSessionSummaries(_ context.Context) ([]Summary, error)
func (*InMemorySessionStore) GetSessions ¶
func (s *InMemorySessionStore) GetSessions(_ context.Context) ([]*Session, error)
func (*InMemorySessionStore) SetSessionStarred ¶
SetSessionStarred sets the starred status of a session.
func (*InMemorySessionStore) UpdateMessage ¶
func (s *InMemorySessionStore) UpdateMessage(_ context.Context, messageID int64, msg *Message) error
UpdateMessage updates an existing message by its ID.
func (*InMemorySessionStore) UpdateSession ¶
func (s *InMemorySessionStore) UpdateSession(_ context.Context, session *Session) error
UpdateSession updates an existing session, or creates it if it doesn't exist (upsert). This enables lazy session persistence - sessions are only stored when they have content. Note: Like SQLite, this only stores metadata. Messages are stored separately via AddMessage.
func (*InMemorySessionStore) UpdateSessionTitle ¶
func (s *InMemorySessionStore) UpdateSessionTitle(_ context.Context, sessionID, title string) error
UpdateSessionTitle updates only the title.
func (*InMemorySessionStore) UpdateSessionTokens ¶
func (s *InMemorySessionStore) UpdateSessionTokens(_ context.Context, sessionID string, inputTokens, outputTokens int64, cost float64) error
UpdateSessionTokens updates only token/cost fields.
type Item ¶
type Item struct {
// Message holds a regular conversation message
Message *Message `json:"message,omitempty"`
// SubSession holds a complete sub-session from task transfers
SubSession *Session `json:"sub_session,omitempty"`
// Summary is a summary of the session up until this point
Summary string `json:"summary,omitempty"`
// FirstKeptEntry is the index (into the session's Messages slice) of the
// first message that was kept verbatim during compaction. Messages from
// this index onward (up to the summary item itself) are appended after
// the summary when reconstructing the conversation. A value of -1 (or 0
// with no summary) means no messages were kept.
FirstKeptEntry int `json:"first_kept_entry,omitempty"`
// Cost tracks the cost of operations associated with this item that
// don't produce a regular message (e.g., compaction/summarization).
Cost float64 `json:"cost,omitempty"`
}
Item represents either a message or a sub-session
func NewMessageItem ¶
NewMessageItem creates a SessionItem containing a message
func NewSubSessionItem ¶
NewSubSessionItem creates a SessionItem containing a sub-session
func (*Item) IsSubSession ¶
IsSubSession returns true if this item contains a sub-session
type Message ¶
type Message struct {
// ID is the database ID of the message (used for persistence tracking)
ID int64 `json:"-"`
AgentName string `json:"agentName"` // TODO: rename to agent_name
Message chat.Message `json:"message"`
// Implicit is an optional field to indicate if the message shouldn't be shown to the user. It's needed for special situations
// like when an agent transfers a task to another agent - new session is created with a default user message, but this shouldn't be shown to the user.
// Such messages should be marked as true
Implicit bool `json:"implicit,omitempty"`
}
Message is a message from an agent
func ImplicitUserMessage ¶
func SystemMessage ¶
func UserMessage ¶
func UserMessage(content string, multiContent ...chat.MessagePart) *Message
type MessageUsageRecord ¶
type MessageUsageRecord struct {
AgentName string `json:"agent_name"`
Model string `json:"model"`
Cost float64 `json:"cost"`
Usage chat.Usage `json:"usage"`
}
MessageUsageRecord stores usage data for a single assistant message. Used in remote mode where messages aren't stored in the client-side session.
type Migration ¶
type Migration struct {
ID int
Name string
Description string
UpSQL string
DownSQL string
AppliedAt time.Time
// UpFunc is an optional Go function to run after UpSQL (for data migrations)
UpFunc func(ctx context.Context, db *sql.DB) error
}
Migration represents a database migration
type MigrationManager ¶
type MigrationManager struct {
// contains filtered or unexported fields
}
MigrationManager handles database migrations
func NewMigrationManager ¶
func NewMigrationManager(db *sql.DB) *MigrationManager
NewMigrationManager creates a new migration manager
func (*MigrationManager) GetAppliedMigrations ¶
func (m *MigrationManager) GetAppliedMigrations(ctx context.Context) ([]Migration, error)
GetAppliedMigrations returns a list of applied migrations
func (*MigrationManager) InitializeMigrations ¶
func (m *MigrationManager) InitializeMigrations(ctx context.Context) error
InitializeMigrations sets up the migrations table and runs pending migrations
func (*MigrationManager) RunPendingMigrations ¶
func (m *MigrationManager) RunPendingMigrations(ctx context.Context) error
RunPendingMigrations executes all migrations that haven't been applied yet
type Opt ¶
type Opt func(s *Session)
func WithAgentName ¶
WithAgentName pins this session to a specific agent. When set, RunStream resolves the agent from the session rather than the shared runtime state, which is required for concurrent background agent tasks.
func WithExcludedTools ¶ added in v1.41.0
WithExcludedTools sets tool names that should be filtered out of the agent's tool list for this session. This prevents recursive tool calls in skill sub-sessions.
func WithHideToolResults ¶
func WithImplicitUserMessage ¶
func WithMaxConsecutiveToolCalls ¶ added in v1.32.5
WithMaxConsecutiveToolCalls sets the threshold for consecutive identical tool call detection. 0 means "use runtime default of 5". Negative values are ignored.
func WithMaxIterations ¶
func WithMaxOldToolCallTokens ¶ added in v1.36.0
WithMaxOldToolCallTokens sets the maximum token budget for old tool call content. Set to -1 to disable truncation (unlimited tool content). Set to 0 to use the default (40000).
func WithMessages ¶ added in v1.38.0
func WithNonInteractive ¶ added in v1.43.0
func WithParentID ¶
WithParentID marks this session as a sub-session of the given parent. Sub-sessions are not persisted as standalone entries in the session store.
func WithPermissions ¶
func WithPermissions(perms *PermissionsConfig) Opt
func WithSendUserMessage ¶
func WithSystemMessage ¶
func WithToolsApproved ¶
func WithUserMessage ¶
func WithWorkingDir ¶
type PermissionsConfig ¶
type PermissionsConfig struct {
// Allow lists tool name patterns that are auto-approved without user confirmation.
Allow []string `json:"allow,omitempty"`
// Ask lists tool name patterns that always require user confirmation,
// even for tools that are normally auto-approved (e.g. read-only tools).
Ask []string `json:"ask,omitempty"`
// Deny lists tool name patterns that are always rejected.
Deny []string `json:"deny,omitempty"`
}
PermissionsConfig defines session-level tool permission overrides using pattern-based rules (Allow/Ask/Deny arrays).
type RelevanceCheck ¶ added in v1.42.0
type RelevanceCheck struct {
Passed bool `json:"passed"`
PassedCount float64 `json:"passed_count"`
Total float64 `json:"total"`
Results []RelevanceCriterionResult `json:"results"`
}
RelevanceCheck contains the result of the LLM judge relevance check.
type RelevanceCriterionResult ¶ added in v1.42.0
type RelevanceCriterionResult struct {
Criterion string `json:"criterion"`
Passed bool `json:"passed"`
Reason string `json:"reason,omitempty"`
}
RelevanceCriterionResult contains the judge's verdict on a single relevance criterion.
type SQLiteSessionStore ¶
type SQLiteSessionStore struct {
// contains filtered or unexported fields
}
SQLiteSessionStore implements Store using SQLite
func (*SQLiteSessionStore) AddMessage ¶
func (s *SQLiteSessionStore) AddMessage(ctx context.Context, sessionID string, msg *Message) (int64, error)
AddMessage adds a message to a session at the next position. Returns the ID of the created message item.
func (*SQLiteSessionStore) AddSession ¶
func (s *SQLiteSessionStore) AddSession(ctx context.Context, session *Session) error
AddSession adds a new session to the store, including any messages
func (*SQLiteSessionStore) AddSubSession ¶
func (s *SQLiteSessionStore) AddSubSession(ctx context.Context, parentSessionID string, subSession *Session) error
AddSubSession creates a sub-session and links it to the parent.
func (*SQLiteSessionStore) AddSummary ¶
func (s *SQLiteSessionStore) AddSummary(ctx context.Context, sessionID, summary string, firstKeptEntry int) error
AddSummary adds a summary item to a session at the next position.
func (*SQLiteSessionStore) Close ¶
func (s *SQLiteSessionStore) Close() error
Close closes the database connection
func (*SQLiteSessionStore) DeleteSession ¶
func (s *SQLiteSessionStore) DeleteSession(ctx context.Context, id string) error
DeleteSession deletes a session by ID
func (*SQLiteSessionStore) GetSession ¶
GetSession retrieves a session by ID
func (*SQLiteSessionStore) GetSessionSummaries ¶
func (s *SQLiteSessionStore) GetSessionSummaries(ctx context.Context) ([]Summary, error)
GetSessionSummaries retrieves lightweight session metadata for listing (excludes sub-sessions). This is much faster than GetSessions as it doesn't load message content.
func (*SQLiteSessionStore) GetSessions ¶
func (s *SQLiteSessionStore) GetSessions(ctx context.Context) ([]*Session, error)
GetSessions retrieves all root sessions (excludes sub-sessions)
func (*SQLiteSessionStore) SetSessionStarred ¶
SetSessionStarred sets the starred status of a session.
func (*SQLiteSessionStore) UpdateMessage ¶
func (s *SQLiteSessionStore) UpdateMessage(ctx context.Context, messageID int64, msg *Message) error
UpdateMessage updates an existing message by its ID.
func (*SQLiteSessionStore) UpdateSession ¶
func (s *SQLiteSessionStore) UpdateSession(ctx context.Context, session *Session) error
UpdateSession updates an existing session's metadata, or creates it if it doesn't exist (upsert). Only metadata is modified - use AddMessage, AddSubSession, AddSummary for items. Messages are persisted separately via events to avoid duplication.
func (*SQLiteSessionStore) UpdateSessionTitle ¶
func (s *SQLiteSessionStore) UpdateSessionTitle(ctx context.Context, sessionID, title string) error
UpdateSessionTitle updates only the title.
func (*SQLiteSessionStore) UpdateSessionTokens ¶
func (s *SQLiteSessionStore) UpdateSessionTokens(ctx context.Context, sessionID string, inputTokens, outputTokens int64, cost float64) error
UpdateSessionTokens updates only token/cost fields.
type Session ¶
type Session struct {
// ID is the unique identifier for the session
ID string `json:"id"`
// Title is the title of the session, set by the runtime
Title string `json:"title"`
// Evals contains evaluation criteria for this session (used by eval framework)
Evals *EvalCriteria `json:"evals,omitempty"`
// EvalResult contains the evaluation scoring outcome (populated after eval run).
EvalResult *EvalResult `json:"eval_result,omitempty"`
// Messages holds the conversation history (messages and sub-sessions)
Messages []Item `json:"messages"`
// CreatedAt is the time the session was created
CreatedAt time.Time `json:"created_at"`
// ToolsApproved is a flag to indicate if the tools have been approved
ToolsApproved bool `json:"tools_approved"`
// NonInteractive indicates the session is running in a non-interactive context
// (e.g. MCP server, A2A adapter, evaluation framework) where there is no user
// to provide input. This is distinct from ToolsApproved which can also be set
// in interactive TUI sessions when a user approves all tools.
NonInteractive bool `json:"non_interactive,omitempty"`
// HideToolResults is a flag to indicate if tool results should be hidden
HideToolResults bool `json:"hide_tool_results"`
// WorkingDir is the base directory used for filesystem-aware tools
WorkingDir string `json:"working_dir,omitempty"`
// SendUserMessage is a flag to indicate if the user message should be sent
SendUserMessage bool
// MaxIterations is the maximum number of agentic loop iterations to prevent infinite loops
// If 0, there is no limit
MaxIterations int `json:"max_iterations"`
// MaxConsecutiveToolCalls is the maximum number of consecutive identical tool call
// batches before the agent is terminated. Prevents degenerate loops where the model
// repeatedly issues the same call without making progress. Default: 5.
MaxConsecutiveToolCalls int `json:"max_consecutive_tool_calls,omitempty"`
// MaxOldToolCallTokens is the maximum number of tokens to keep from old tool call
// arguments and results. Older tool calls beyond this budget will have their
// content replaced with a placeholder. Tokens are approximated as len/4.
// Set to -1 to disable truncation (unlimited tool content).
// Default: 40000 (when not configured or set to 0).
MaxOldToolCallTokens int `json:"max_old_tool_call_tokens,omitempty"`
// Starred indicates if this session has been starred by the user
Starred bool `json:"starred"`
InputTokens int64 `json:"input_tokens"`
OutputTokens int64 `json:"output_tokens"`
Cost float64 `json:"cost"`
// Permissions holds session-level permission overrides.
// When set, these are evaluated before team-level permissions.
Permissions *PermissionsConfig `json:"permissions,omitempty"`
// AgentModelOverrides stores per-agent model overrides for this session.
// Key is the agent name, value is the model reference (e.g., "openai/gpt-4o" or a named model from config).
// When a session is loaded, these overrides are reapplied to the runtime.
AgentModelOverrides map[string]string `json:"agent_model_overrides,omitempty"`
// CustomModelsUsed tracks custom models (provider/model format) used during this session.
// These are shown in the model picker for easy re-selection.
CustomModelsUsed []string `json:"custom_models_used,omitempty"`
// ExcludedTools lists tool names that should be filtered out of the agent's
// tool list for this session. This is used by skill sub-sessions to prevent
// recursive run_skill calls.
ExcludedTools []string `json:"-"`
// AgentName, when set, tells RunStream which agent to use for this session
// instead of reading from the shared runtime currentAgent field. This is
// required for background agent tasks where multiple sessions may run
// concurrently on different agents.
AgentName string `json:"-"`
// ParentID indicates this is a sub-session created by task transfer.
// Sub-sessions are not persisted as standalone entries; they are embedded
// within the parent session's Messages array.
ParentID string `json:"-"`
// MessageUsageHistory stores per-message usage data for remote mode.
// In remote mode, messages are managed server-side, so we track usage separately.
// This is not persisted (json:"-") as it's only needed for the current session display.
MessageUsageHistory []MessageUsageRecord `json:"-"`
// contains filtered or unexported fields
}
Session represents the agent's state including conversation history and variables
func BranchSession ¶
BranchSession creates a new session branched from the parent at the given position. Messages up to (but not including) branchAtPosition are deep-cloned into the new session.
func (*Session) AddMessage ¶
AddMessage adds a message to the session
func (*Session) AddMessageUsageRecord ¶
AddMessageUsageRecord appends a usage record for remote mode where messages aren't stored locally. This enables the /cost dialog to show per-message breakdown even when using a remote runtime.
func (*Session) AddSubSession ¶
AddSubSession adds a sub-session to the session
func (*Session) AllowedDirectories ¶
AllowedDirectories returns the directories that should be considered safe for tools
func (*Session) GetAllMessages ¶
GetAllMessages extracts all messages from the session, including from sub-sessions
func (*Session) GetLastAssistantMessageContent ¶
func (*Session) GetLastUserMessageContent ¶
func (*Session) GetLastUserMessages ¶
GetLastUserMessages returns up to n most recent user messages, ordered from oldest to newest. Returns nil if n <= 0.
func (*Session) GetMessages ¶
func (*Session) IsSubSession ¶
IsSubSession returns true if this session is a sub-session (has a parent).
func (*Session) MessageCount ¶
MessageCount returns the number of items that contain a message.
type SizeCheck ¶ added in v1.42.0
type SizeCheck struct {
Passed bool `json:"passed"`
Actual string `json:"actual"`
Expected string `json:"expected"`
}
SizeCheck contains the result of the response size check.
type Store ¶
type Store interface {
// === Core session operations ===
AddSession(ctx context.Context, session *Session) error
GetSession(ctx context.Context, id string) (*Session, error)
GetSessions(ctx context.Context) ([]*Session, error)
GetSessionSummaries(ctx context.Context) ([]Summary, error)
DeleteSession(ctx context.Context, id string) error
UpdateSession(ctx context.Context, session *Session) error // Updates metadata only (not messages/items)
SetSessionStarred(ctx context.Context, id string, starred bool) error
// AddMessage adds a message to a session at the next position.
// Returns the ID of the created message item.
AddMessage(ctx context.Context, sessionID string, msg *Message) (int64, error)
// UpdateMessage updates an existing message by its ID.
// This is used to finalize streaming messages with complete content.
UpdateMessage(ctx context.Context, messageID int64, msg *Message) error
// AddSubSession creates a sub-session and links it to the parent.
// The sub-session is stored as a separate session row with parent_id set.
AddSubSession(ctx context.Context, parentSessionID string, subSession *Session) error
// AddSummary adds a summary item to a session at the next position.
// firstKeptEntry is the index of the first message kept verbatim during compaction.
AddSummary(ctx context.Context, sessionID, summary string, firstKeptEntry int) error
// UpdateSessionTokens updates only token/cost fields
UpdateSessionTokens(ctx context.Context, sessionID string, inputTokens, outputTokens int64, cost float64) error
// UpdateSessionTitle updates only the title
UpdateSessionTitle(ctx context.Context, sessionID, title string) error
// Close releases any resources held by the store (e.g., database connections).
Close() error
}
Store defines the interface for session storage
func NewInMemorySessionStore ¶
func NewInMemorySessionStore() Store
func NewSQLiteSessionStore ¶
NewSQLiteSessionStore creates a new SQLite session store
type Summary ¶
Summary contains lightweight session metadata for listing purposes. This is used instead of loading full Session objects with all messages.
type ToolCallsCheck ¶ added in v1.42.0
ToolCallsCheck contains the result of the tool calls F1 score check.