compaction

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

This section is empty.

Types

type CutPointResult added in v0.1.9

type CutPointResult struct {
	FirstKeptIndex int
	TurnStartIndex int
	IsSplitTurn    bool
}

CutPointResult is the compaction cut point in an indexed message list.

type EventData

type EventData struct {
	// BeforeSeq is legacy: highest summarized seq when FirstKeptSeq is unset.
	BeforeSeq agentkit.EventSeq `json:"beforeSeq,omitempty"`
	// FirstKeptSeq is the first retained event after compaction (Pi firstKeptEntryId).
	FirstKeptSeq agentkit.EventSeq `json:"firstKeptSeq,omitempty"`
	// RetainedTail is verbatim recent history kept for the model after compaction.
	RetainedTail []agentkit.ModelMessage `json:"retainedTail,omitempty"`
	TokensBefore int                     `json:"tokensBefore,omitempty"`
	Summary      agentkit.ModelMessage   `json:"summary"`
	Kind         string                  `json:"kind"`
}

func (EventData) MemoryCutoffSeq added in v0.1.9

func (d EventData) MemoryCutoffSeq() agentkit.EventSeq

MemoryCutoffSeq returns the highest event seq dropped from hot memory.

func (EventData) PreviousSummaryText added in v0.2.1

func (d EventData) PreviousSummaryText() string

PreviousSummaryText extracts prior summary body from a compaction event.

type IndexedMessage added in v0.1.9

type IndexedMessage struct {
	Message     agentkit.ModelMessage
	Seq         agentkit.EventSeq
	IsTurnStart bool
}

IndexedMessage is a model-visible message with its primary source event seq.

type Preparation added in v0.1.9

type Preparation struct {
	FirstKeptSeq        agentkit.EventSeq
	FirstKeptIndex      int
	MessagesToSummarize []agentkit.ModelMessage
	TurnPrefixMessages  []agentkit.ModelMessage
	RetainedTail        []agentkit.ModelMessage
	PreviousSummary     string
	TokensBefore        int
	IsSplitTurn         bool
}

Preparation is the Pi-style compaction plan for one pass.

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.

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