Documentation
¶
Index ¶
- func ApplyAll(ctx context.Context, services []capscompaction.Service, ...) ([]agentkit.ModelMessage, int, error)
- func BoundOversizedIndexedMessages(indexed []capscompaction.IndexedMessage, maxChars int) ([]agentkit.ModelMessage, bool)
- func EstimateMessagesTokens(messages []agentkit.ModelMessage) int
- func EstimateTokens(msg agentkit.ModelMessage) int
- func FindCutPoint(messages []capscompaction.IndexedMessage, ...) capscompaction.CutPointResult
- func FitIndexedMessagesToBudget(indexed []capscompaction.IndexedMessage, maxChars int) ([]agentkit.ModelMessage, bool)
- 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 SerializeConversationWithBudget(messages []agentkit.ModelMessage, maxTotalChars int) 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 BoundOversizedIndexedMessages ¶ added in v0.3.32
func BoundOversizedIndexedMessages(indexed []capscompaction.IndexedMessage, maxChars int) ([]agentkit.ModelMessage, bool)
BoundOversizedIndexedMessages bounds each indexed message's model-visible size for compaction output (retained tail): oversized text is truncated, and hydratable attachment parts in messages whose logical size exceeds maxChars are replaced with a text hint, so the post-compaction view cannot re-inflate during hydration. Durable session events keep the original content.
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 FitIndexedMessagesToBudget ¶ added in v0.3.32
func FitIndexedMessagesToBudget(indexed []capscompaction.IndexedMessage, maxChars int) ([]agentkit.ModelMessage, bool)
FitIndexedMessagesToBudget is the force-compaction send budget: neutralize every hydratable part (stored attachment_ref can be tiny but hydrate into a huge data: URL), cap each message, then drop oldest messages until the total fits maxChars. Durable session events keep the original content.
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 SerializeConversationWithBudget ¶ added in v0.3.32
func SerializeConversationWithBudget(messages []agentkit.ModelMessage, maxTotalChars int) string
SerializeConversationWithBudget is SerializeConversation bounded for the summary model's window: each message is capped at summaryMaxMessageChars and when the total exceeds maxTotalChars the oldest messages are dropped with an omission marker (recent context matters more for continuation). A maxTotalChars <= 0 disables the total budget.
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.