compaction

package
v0.3.34 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewPipeline added in v0.2.1

func NewPipeline(_ struct{}, deps PipelineDeps) (compaction.Service, error)

NewPipeline registers compaction/pipeline: Run inner compaction services in order as one unit.

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 PipelineDeps added in v0.2.1

type PipelineDeps struct {
	Chain    compaction.Chain     `json:"chain"`
	Services []compaction.Service `json:"services"`
}

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 {
	Chain compaction.Chain `json:"chain"`
	// Services run only once the threshold is crossed, with Force set.
	Services []compaction.Service `json:"services"`
}

Jump to

Keyboard shortcuts

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