Documentation
¶
Index ¶
- func NewPrune(cfg PruneConfig) (compaction.Service, error)
- func NewSummary(cfg SummaryConfig, deps SummaryDeps) (capcompaction.Service, error)
- func NewTokenLimit(cfg TokenLimitConfig, deps TokenLimitDeps) (compaction.Service, error)
- type PruneConfig
- type SummaryConfig
- type SummaryDeps
- type TokenLimitConfig
- type TokenLimitDeps
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewPrune ¶
func NewPrune(cfg PruneConfig) (compaction.Service, error)
NewPrune registers compaction/prune-tool-results: Trim verbose tool results without calling a model.
Best practices:
- Cheap and lossless enough to run before compaction/summary in the same chain.
func NewSummary ¶
func NewSummary(cfg SummaryConfig, deps SummaryDeps) (capcompaction.Service, error)
NewSummary registers compaction/summary: Pi-style summary + retained tail compaction.
func NewTokenLimit ¶
func NewTokenLimit(cfg TokenLimitConfig, deps TokenLimitDeps) (compaction.Service, error)
NewTokenLimit registers compaction/token-limit: Trigger inner compaction services once the context crosses a token threshold.
Best practices:
- A decorator, not a strategy: it decides when, the services dep decides how.
- The estimate is max(character estimate, reported usage), so it errs toward compacting early.
Types ¶
type PruneConfig ¶
type PruneConfig struct {
// MaxToolResultBytes is per-result truncation limit.
MaxToolResultBytes int `json:"maxToolResultBytes"`
}
type SummaryConfig ¶
type SummaryConfig struct {
// MinMessages is an optional pre-gate when Force is false. Zero disables it.
MinMessages int `json:"minMessages"`
// KeepRecentTokens is the recent context budget kept verbatim (Pi-compatible).
KeepRecentTokens int `json:"keepRecentTokens"`
// ReserveTokens caps summarization output size.
ReserveTokens int `json:"reserveTokens"`
// KeepRecent is deprecated; use keepRecentTokens.
KeepRecent int `json:"keepRecent"`
// SummaryModel is model used for the summary; defaults to the agent's model.
SummaryModel string `json:"summaryModel"`
// SummaryPrompt overrides the built-in summarisation instruction.
SummaryPrompt string `json:"summaryPrompt"`
Retry *capcompaction.RetryConfig `json:"retry,omitempty"`
}
type SummaryDeps ¶
type SummaryDeps struct {
LLM agentkit.LLMProvider `json:"llm"`
}
type TokenLimitConfig ¶
type TokenLimitConfig struct {
// MaxTokens is absolute trigger; takes precedence over ContextWindow.
MaxTokens int `json:"maxTokens"`
// ContextWindow is model context size; the trigger becomes ContextWindow × TriggerRatio.
ContextWindow int `json:"contextWindow"`
// TriggerRatio is fraction of ContextWindow that trips compaction, default 0.7 — leaving room for the reply plus the next tool result.
TriggerRatio float64 `json:"triggerRatio"`
// CharsPerToken calibrates the fallback estimate used before the provider reports usage; default 4 (English prose), lower it for CJK.
CharsPerToken int `json:"charsPerToken"`
}
type TokenLimitDeps ¶
type TokenLimitDeps struct {
// Services run only once the threshold is crossed, with Force set.
Services []compaction.Service `json:"services"`
}
Click to show internal directories.
Click to hide internal directories.