contextmon

package
v0.13.1 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package contextmon provides context size monitoring and warnings

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	MaxChars            int     `yaml:"max_chars"`            // Maximum context size in characters
	WarningThreshold    float64 `yaml:"warning_threshold"`    // Percentage to trigger warning (0.0-1.0)
	CriticalThreshold   float64 `yaml:"critical_threshold"`   // Percentage to trigger critical warning
	TruncationThreshold float64 `yaml:"truncation_threshold"` // Percentage to auto-truncate
}

Config holds context monitoring configuration

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig returns the default context monitoring configuration

type Level

type Level int

Level represents the severity level of context size

const (
	LevelOK Level = iota
	LevelWarning
	LevelCritical
	LevelTruncate
)

func (Level) String

func (l Level) String() string

String returns the string representation of the level

type Monitor

type Monitor struct {
	// contains filtered or unexported fields
}

Monitor tracks and reports context size

func NewMonitor

func NewMonitor(cfg *Config) *Monitor

NewMonitor creates a new context monitor with the given configuration

func (*Monitor) Check

func (m *Monitor) Check(size int) Status

Check evaluates the given context size and returns the status

func (*Monitor) Config

func (m *Monitor) Config() Config

Config returns the current configuration (read-only)

func (*Monitor) LastStatus

func (m *Monitor) LastStatus() *Status

LastStatus returns the last checked status (may be nil)

func (*Monitor) RecommendedHistoryCount

func (m *Monitor) RecommendedHistoryCount(currentSize, avgMsgLen int) int

RecommendedHistoryCount returns the recommended number of history messages based on current context size and average message length

func (*Monitor) ShouldTruncate

func (m *Monitor) ShouldTruncate(size int) bool

ShouldTruncate returns true if the context should be truncated

func (*Monitor) UpdateConfig

func (m *Monitor) UpdateConfig(cfg *Config)

UpdateConfig updates the monitor configuration

type Status

type Status struct {
	CurrentSize int     // Current size in characters
	MaxSize     int     // Maximum allowed size
	Percentage  float64 // Usage percentage (0.0-1.0)
	Level       Level   // Current warning level
}

Status represents the current context size status

func (Status) FormatWarning

func (s Status) FormatWarning() string

FormatWarning returns a formatted warning message for display

func (Status) String

func (s Status) String() string

String returns a human-readable status string

Jump to

Keyboard shortcuts

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