Versions in this module Expand all Collapse all v0 v0.2.0 Nov 29, 2026 Changes in this version + var ErrBudget = errors.New("context budget: required history does not fit") + var ErrConfig = errors.New("context budget: invalid configuration") + var ErrEstimate = errors.New("context budget: counting or estimation failed") + var ErrLimit = errors.New("context budget: resource limit exceeded") + var ErrNative = errors.New("context budget: native history selection unsupported") + type Budget struct + MaxTokens int + MinimumTurns int + ReserveTokens int + type Counter struct + func NewCounter(enc Encoding) (*Counter, error) + func (c *Counter) Count(ctx context.Context, text string) (int, error) + func (c *Counter) Estimator(perMessage, perToolCall int) (EstimateFunc, error) + type Encoding string + const Cl100kBase + const O200kBase + type EstimateFunc func(context.Context, agent.Message) (int, error) + type Selection struct + DroppedTurns int + EstimatedHistoryTokens int + KeptTurns int + Messages []agent.Message + ReservedTokens int + func Select(ctx context.Context, history []agent.Message, b Budget, estimate EstimateFunc) (Selection, error)