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: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyAll

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

func EstimateMessagesTokens

func EstimateMessagesTokens(messages []agentkit.ModelMessage) int

EstimateMessagesTokens sums token estimates for a message slice.

func EstimateTokens

func EstimateTokens(msg agentkit.ModelMessage) int

EstimateTokens approximates message size with a chars/4 heuristic (Pi-compatible).

func FindCutPoint

func FindCutPoint(messages []capscompaction.IndexedMessage, startIndex, endIndex, keepRecentTokens int) capscompaction.CutPointResult

FindCutPoint walks backward until keepRecentTokens is reached, then cuts at the nearest valid cut point. Tool messages are never cut points (Pi-compatible).

func Prepare

func Prepare(indexed []capscompaction.IndexedMessage, boundaryStart int, keepRecentTokens int, previousSummary string, tokensBefore int) *capscompaction.Preparation

Prepare builds a compaction plan from indexed messages. boundaryStart is the first index eligible for summarization (after any previous compaction summary).

func PruneToolResults

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

PruneToolResults truncates oversized tool result text deterministically.

func ResolveRetrySettings

func ResolveRetrySettings(cfg *capscompaction.RetryConfig) capscompaction.RetryPolicy

ResolveRetrySettings applies defaults aligned with agent-level auto retry.

func RetryCall

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

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

func SerializeConversation

func SerializeConversation(messages []agentkit.ModelMessage) string

SerializeConversation formats messages as plain text for summarization (Pi-style).

func TruncateToolResult

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

TruncateToolResult truncates oversized tool result content after execution.

Types

This section is empty.

Jump to

Keyboard shortcuts

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