Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SerializeMessages ¶
SerializeMessages converts a slice of messages into a compactable text representation. Tool outputs are truncated to maxToolOutputChars to keep the summary lean.
func SplitMessages ¶
func SplitMessages(messages []types.Message, keepTokens int, estimateFn func(string) int) (head []types.Message, recent []types.Message)
SplitMessages divides messages into a "head" (to summarize) and "recent" (to keep verbatim). The split point is determined by walking backwards from the end until keepTokens worth of content is accumulated.
Types ¶
type Compactor ¶
type Compactor struct {
// contains filtered or unexported fields
}
Compactor manages automatic session compaction. It monitors token usage against model context limits and generates structured summaries when usage exceeds the threshold.
func (*Compactor) Compact ¶
func (c *Compactor) Compact(ctx context.Context, messages []types.Message, p provider.LLMProvider, modelID string) (*Result, error)
Compact generates a structured summary of old messages and returns a new message list with the old messages replaced by the summary. Uses the LLM provider to generate the summary.
func (*Compactor) LastResult ¶
LastResult returns the most recent compaction result, or nil if no compaction has been performed.