Documentation
¶
Index ¶
- func ApplyAll(ctx context.Context, services []capscompaction.Service, ...) ([]agentkit.ModelMessage, int, error)
- func EstimateMessagesSendTokens(messages []agentkit.ModelMessage) int
- func EstimateMessagesTokens(messages []agentkit.ModelMessage) int
- func EstimateSendTokens(msg agentkit.ModelMessage) int
- func EstimateTokens(msg agentkit.ModelMessage) int
- func FindCutPoint(messages []capscompaction.IndexedMessage, ...) capscompaction.CutPointResult
- func Prepare(indexed []capscompaction.IndexedMessage, boundaryStart int, ...) *capscompaction.Preparation
- func PruneToolResults(messages []agentkit.ModelMessage, maxBytes int) []agentkit.ModelMessage
- func PruneToolResultsReport(messages []agentkit.ModelMessage, maxBytes int) ([]agentkit.ModelMessage, bool)
- func ResolveRetrySettings(cfg *capscompaction.RetryConfig) capscompaction.RetryPolicy
- func RetryCall(ctx context.Context, policy capscompaction.RetryPolicy, ...) error
- func SerializeConversation(messages []agentkit.ModelMessage) string
- func TruncateOversizedMessageTexts(messages []agentkit.ModelMessage, maxChars int) ([]agentkit.ModelMessage, bool)
- func TruncateToolResult(result agentkit.ToolResult, maxBytes int) agentkit.ToolResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyAll ¶
func ApplyAll(ctx context.Context, services []capscompaction.Service, req capscompaction.Request) ([]agentkit.ModelMessage, int, error)
ApplyAll runs compaction services in order, returning the latest message view and how many services reported Applied.
func EstimateMessagesSendTokens ¶ added in v0.3.31
func EstimateMessagesSendTokens(messages []agentkit.ModelMessage) int
EstimateMessagesSendTokens sums send-size estimates for a message slice.
func EstimateMessagesTokens ¶
func EstimateMessagesTokens(messages []agentkit.ModelMessage) int
EstimateMessagesTokens sums token estimates for a message slice.
func EstimateSendTokens ¶ added in v0.3.31
func EstimateSendTokens(msg agentkit.ModelMessage) int
EstimateSendTokens approximates request size as actually sent: full text plus full part URLs (inline data: payloads counted at real size), unlike EstimateTokens which ignores non-text parts. The pre-send guard uses it because underestimating there means a provider 400. ContentPart.Source is excluded: it is a workspace path for persistence, never sent to providers.
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 PruneToolResultsReport ¶ added in v0.3.31
func PruneToolResultsReport(messages []agentkit.ModelMessage, maxBytes int) ([]agentkit.ModelMessage, bool)
PruneToolResultsReport is PruneToolResults plus whether any content was actually truncated, so callers can report Applied honestly.
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 TruncateOversizedMessageTexts ¶ added in v0.3.31
func TruncateOversizedMessageTexts(messages []agentkit.ModelMessage, maxChars int) ([]agentkit.ModelMessage, bool)
TruncateOversizedMessageTexts truncates text content of messages that alone exceed maxChars, keeping the head plus a marker. It is the last-resort bound for retained history so post-compaction context stays under budget; durable session events keep the full text, only the model-visible view is cut.
func TruncateToolResult ¶
func TruncateToolResult(result agentkit.ToolResult, maxBytes int) agentkit.ToolResult
TruncateToolResult truncates oversized tool result content after execution.
Types ¶
This section is empty.