Documentation
¶
Overview ¶
Package compact provides compaction strategies, types, and helpers for context-window management. See ../REFACTOR_PLAN.md.
Index ¶
- func APICompactMessages(msgs []types.EyrieMessage, cfg APICompactConfig) []types.EyrieMessage
- func AdjustIndexToPreserveAPIInvariants(msgs []types.EyrieMessage, startIdx int) int
- func BuildCompactPrompt(variant CompactVariant) string
- func BuildPrompt(variant Variant) string
- func CalculateMessagesToKeepIndex(msgs []types.EyrieMessage, cfg SessionMemoryConfig) int
- func CountClearableToolResults(msgs []types.EyrieMessage) int
- func FilterCompactBoundaries(msgs []types.EyrieMessage) []types.EyrieMessage
- func FormatCompactSummary(raw string) string
- func FormatSummary(raw string) string
- func HasTextContent(m types.EyrieMessage) bool
- func HasTimeGap(msgs []types.EyrieMessage, threshold time.Duration) bool
- func IsCompactBoundary(m types.EyrieMessage) bool
- func IsCompactableTool(name string) bool
- func MicrocompactMessages(msgs []types.EyrieMessage, cfg MicroCompactConfig) []types.EyrieMessage
- func ReadSessionMemory(sessionID string) (string, error)
- func SessionMemoryPath(sessionID string) string
- func ToolNameForResult(m types.EyrieMessage, msgs []types.EyrieMessage) string
- type APICompactConfig
- type CompactConfig
- type CompactResult
- type CompactVariant
- type CompactionTrigger
- type Config
- type FileTracker
- func (ft *FileTracker) ExtractFromMessages(messages []types.EyrieMessage)
- func (ft *FileTracker) FormatForSummary() string
- func (ft *FileTracker) Merge(other *FileTracker)
- func (ft *FileTracker) ParseFromSummary(summary string)
- func (ft *FileTracker) RecordModified(path string)
- func (ft *FileTracker) RecordRead(path string)
- type MicroCompactConfig
- type Result
- type SessionMemoryConfig
- type Variant
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func APICompactMessages ¶
func APICompactMessages(msgs []types.EyrieMessage, cfg APICompactConfig) []types.EyrieMessage
func AdjustIndexToPreserveAPIInvariants ¶
func AdjustIndexToPreserveAPIInvariants(msgs []types.EyrieMessage, startIdx int) int
func BuildCompactPrompt ¶
func BuildCompactPrompt(variant CompactVariant) string
func BuildPrompt ¶
BuildPrompt renders the compaction prompt template for the given variant.
func CalculateMessagesToKeepIndex ¶
func CalculateMessagesToKeepIndex(msgs []types.EyrieMessage, cfg SessionMemoryConfig) int
func CountClearableToolResults ¶
func CountClearableToolResults(msgs []types.EyrieMessage) int
func FilterCompactBoundaries ¶
func FilterCompactBoundaries(msgs []types.EyrieMessage) []types.EyrieMessage
func FormatCompactSummary ¶
func FormatSummary ¶
FormatSummary normalises a raw LLM summary for display.
func HasTextContent ¶
func HasTextContent(m types.EyrieMessage) bool
func HasTimeGap ¶
func HasTimeGap(msgs []types.EyrieMessage, threshold time.Duration) bool
func IsCompactBoundary ¶
func IsCompactBoundary(m types.EyrieMessage) bool
func IsCompactableTool ¶
func MicrocompactMessages ¶
func MicrocompactMessages(msgs []types.EyrieMessage, cfg MicroCompactConfig) []types.EyrieMessage
func ReadSessionMemory ¶
func SessionMemoryPath ¶
func ToolNameForResult ¶
func ToolNameForResult(m types.EyrieMessage, msgs []types.EyrieMessage) string
Types ¶
type APICompactConfig ¶
type APICompactConfig struct {
TriggerTokens int
KeepTargetTokens int
ClearToolInputs bool
ClearThinking bool
PreserveMutating bool
}
func DefaultAPICompactConfig ¶
func DefaultAPICompactConfig() APICompactConfig
func DefaultAPIConfig ¶
func DefaultAPIConfig() APICompactConfig
DefaultAPIConfig returns the default API-boundary compactor config.
type CompactConfig ¶
type CompactConfig struct {
AutoEnabled bool
ContextWindowSize int
AutoCompactBuffer int
MaxOutputTokens int
MaxFailures int
}
func DefaultCompactConfig ¶
func DefaultCompactConfig() CompactConfig
type CompactResult ¶
type CompactVariant ¶
type CompactVariant int
const ( CompactBase CompactVariant = iota CompactPartial CompactUpTo )
type CompactionTrigger ¶
type CompactionTrigger struct {
Threshold float64
WindowSize int
LastCompact time.Time
MinInterval time.Duration
}
func NewCompactionTrigger ¶
func NewCompactionTrigger(windowSize int) *CompactionTrigger
func (*CompactionTrigger) MarkCompacted ¶
func (ct *CompactionTrigger) MarkCompacted()
func (*CompactionTrigger) ShouldCompact ¶
func (ct *CompactionTrigger) ShouldCompact(currentTokens int) bool
type Config ¶
type Config = CompactConfig
Config tunes compaction behaviour.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns the default top-level compaction config.
type FileTracker ¶
func NewFileTracker ¶
func NewFileTracker() *FileTracker
func (*FileTracker) ExtractFromMessages ¶
func (ft *FileTracker) ExtractFromMessages(messages []types.EyrieMessage)
func (*FileTracker) FormatForSummary ¶
func (ft *FileTracker) FormatForSummary() string
func (*FileTracker) Merge ¶
func (ft *FileTracker) Merge(other *FileTracker)
func (*FileTracker) ParseFromSummary ¶
func (ft *FileTracker) ParseFromSummary(summary string)
func (*FileTracker) RecordModified ¶
func (ft *FileTracker) RecordModified(path string)
func (*FileTracker) RecordRead ¶
func (ft *FileTracker) RecordRead(path string)
type MicroCompactConfig ¶
type MicroCompactConfig struct {
CompactableTools map[string]bool
TimeGapMins float64
KeepRecent int
}
func DefaultMicroCompactConfig ¶
func DefaultMicroCompactConfig() MicroCompactConfig
func DefaultMicroConfig ¶
func DefaultMicroConfig() MicroCompactConfig
DefaultMicroConfig returns the default micro-compactor config.
type SessionMemoryConfig ¶
func DefaultSessionMemoryConfig ¶
func DefaultSessionMemoryConfig() SessionMemoryConfig
type Variant ¶
type Variant = CompactVariant
Variant identifies which compaction prompt variant to render.
Click to show internal directories.
Click to hide internal directories.