compact

package
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultSummarizerPrompt = `` /* 928-byte string literal not displayed */

DefaultSummarizerPrompt is the default system prompt for the summarizer.

Variables

This section is empty.

Functions

func CountTokens

func CountTokens(messages []message.Message) int

CountTokens estimates the token count of messages using cl100k_base. Returns the raw count — callers apply a safety margin.

func Prune

func Prune(messages []message.Message) []message.Message

Prune reduces token count before summarization: 1. All tool result contents replaced with placeholder. 2. For read_file calls, the last read of each path is restored. 3. Restored outputs truncated if over maxOutputChars.

Types

type Config

type Config struct {
	SummarizerClient modelclient.Summarizer
	ContextWindow    int
	SummarizerPrompt string
}

Config holds parameters for a compaction run.

type Result

type Result struct {
	Summary         string
	SummarizerModel string
	SummarizerRef   coremodel.ModelRef
}

Result is the output of a successful compaction.

func Run

func Run(ctx context.Context, messages []message.Message, cfg Config) (Result, error)

Run prunes messages and produces a summary, using single-shot or iterative summarization depending on whether the pruned conversation fits in the summarizer's context window.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL