compaction

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KindSummary = "summary"
	KindPrune   = "prune"
)

Variables

This section is empty.

Functions

func ApplyAll

func ApplyAll(ctx context.Context, services []Service, req Request) ([]agentkit.ModelMessage, int, error)

ApplyAll runs compaction services in order, returning the latest message view and how many services reported Applied.

func PruneToolResults

func PruneToolResults(messages []agentkit.ModelMessage, maxBytes int) []agentkit.ModelMessage

PruneToolResults truncates oversized tool result text deterministically.

func RetryCall

func RetryCall(
	ctx context.Context,
	policy RetryPolicy,
	isRetryable func(error) bool,
	call func() error,
	callbacks *SummarizationRetryCallbacks,
) error

RetryCall runs call with bounded retries. isRetryable classifies transient failures; when nil, only context cancellation is treated as non-retryable.

func TruncateToolResult

func TruncateToolResult(result agentkit.ToolResult, maxBytes int) agentkit.ToolResult

TruncateToolResult truncates oversized tool result content after execution.

Types

type EventData

type EventData struct {
	BeforeSeq agentkit.EventSeq     `json:"beforeSeq"`
	Summary   agentkit.ModelMessage `json:"summary"`
	Kind      string                `json:"kind"`
}

type Request

type Request struct {
	SessionID agentkit.SessionID
	AgentID   agentkit.AgentID
	Session   agentkit.Session
	Messages  []agentkit.ModelMessage
	// Force skips automatic thresholds such as minMessages (manual /compact).
	Force bool
}

type Result

type Result struct {
	Applied  bool
	Event    agentkit.SessionEvent
	Messages []agentkit.ModelMessage
}

type RetryConfig

type RetryConfig struct {
	Enabled     *bool `json:"enabled"`
	MaxRetries  int   `json:"maxRetries"`
	BaseDelayMs int   `json:"baseDelayMs"`
}

RetryConfig controls bounded retries with exponential backoff for compaction LLM calls.

type RetryPolicy

type RetryPolicy struct {
	Enabled     bool
	MaxRetries  int
	BaseDelayMs int
}

RetryPolicy is the resolved retry configuration.

func ResolveRetrySettings

func ResolveRetrySettings(cfg *RetryConfig) RetryPolicy

ResolveRetrySettings applies defaults aligned with agent-level auto retry.

type Service

type Service interface {
	Compact(context.Context, Request) (Result, error)
}

type SummarizationRetryCallbacks

type SummarizationRetryCallbacks struct {
	OnScheduled func(attempt, maxAttempts, delayMs int, errorMessage string)
	OnFinished  func(success bool, attempt int, finalError string)
}

SummarizationRetryCallbacks are optional hooks for compaction summarization retries.

Jump to

Keyboard shortcuts

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