Documentation
¶
Index ¶
- Constants
- func ApplyAll(ctx context.Context, services []Service, req Request) ([]agentkit.ModelMessage, int, error)
- func EstimateIndexedTokens(indexed []IndexedMessage) int
- func EstimateMessagesTokens(messages []agentkit.ModelMessage) int
- func EstimateTokens(msg agentkit.ModelMessage) int
- func PreviousSummaryText(data EventData) string
- func PruneToolResults(messages []agentkit.ModelMessage, maxBytes int) []agentkit.ModelMessage
- func RetryCall(ctx context.Context, policy RetryPolicy, isRetryable func(error) bool, ...) error
- func SerializeConversation(messages []agentkit.ModelMessage) string
- func TruncateToolResult(result agentkit.ToolResult, maxBytes int) agentkit.ToolResult
- type CutPointResult
- type EventData
- type IndexedMessage
- type Preparation
- type Request
- type Result
- type RetryConfig
- type RetryPolicy
- type Service
- type SummarizationRetryCallbacks
Constants ¶
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 EstimateIndexedTokens ¶ added in v0.1.9
func EstimateIndexedTokens(indexed []IndexedMessage) int
func EstimateMessagesTokens ¶ added in v0.1.9
func EstimateMessagesTokens(messages []agentkit.ModelMessage) int
EstimateMessagesTokens sums token estimates for a message slice.
func EstimateTokens ¶ added in v0.1.9
func EstimateTokens(msg agentkit.ModelMessage) int
EstimateTokens approximates message size with a chars/4 heuristic (Pi-compatible).
func PreviousSummaryText ¶ added in v0.1.9
PreviousSummaryText extracts prior summary body from a compaction event.
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 SerializeConversation ¶ added in v0.1.9
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 ¶
type CutPointResult ¶ added in v0.1.9
CutPointResult is the compaction cut point in an indexed message list.
func FindCutPoint ¶ added in v0.1.9
func FindCutPoint(messages []IndexedMessage, startIndex, endIndex, keepRecentTokens int) CutPointResult
FindCutPoint walks backward until keepRecentTokens is reached, then cuts at the nearest valid cut point. Tool messages are never cut points (Pi-compatible).
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
MemoryCutoffSeq returns the highest event seq dropped from hot memory.
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.
func Prepare ¶ added in v0.1.9
func Prepare(indexed []IndexedMessage, boundaryStart int, keepRecentTokens int, previousSummary string, tokensBefore int) *Preparation
Prepare builds a compaction plan from indexed messages. boundaryStart is the first index eligible for summarization (after any previous compaction summary).
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 ¶
RetryPolicy is the resolved retry configuration.
func ResolveRetrySettings ¶
func ResolveRetrySettings(cfg *RetryConfig) RetryPolicy
ResolveRetrySettings applies defaults aligned with agent-level auto retry.