compact

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package compact implements conversation history summarization.

Mirrors src/services/compact/compact.ts. Makes a secondary API call to a fast model asking it to summarize the conversation, then replaces the history with a single user message containing the summary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	// Summary is the extracted summary text.
	Summary string
	// NewHistory is the replacement conversation history (one user message).
	NewHistory []api.Message
}

Result is the output of a successful compaction.

func Compact

func Compact(ctx context.Context, client *api.Client, messages []api.Message, customInstructions string) (*Result, error)

Compact summarizes messages using the Anthropic API and returns a Result. The caller should replace their history with Result.NewHistory.

Jump to

Keyboard shortcuts

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