contextbudget

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Overview

Package contextbudget states and checks a budget for one model call's context. Limits holds a byte cap and an event-count cap; it does no I/O and keeps no state beyond the two caps.

Map: contextbudget.go = Limits, Validate, Fits. Rationale: ../docs/plans/contextbudget.md. Contribution rules: ../AGENTS.md.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Limits

type Limits struct {
	MaxBytes  int
	MaxEvents int
}

Limits caps one model call's context by byte count and event count. A zero MaxBytes means no byte cap; a zero MaxEvents means no event-count cap. Both zero means the budget is uncapped.

func (Limits) Fits

func (l Limits) Fits(bytes, events int) bool

Fits reports whether bytes and events both stay at or under their respective caps. A zero cap always reports fit for its own dimension. Fits takes the candidate totals the caller already has; it keeps no running total of its own. Fits does not call Validate; a caller that skips Validate and passes a negative cap gets whatever comparison bytes <= cap produces for that cap.

func (Limits) Validate

func (l Limits) Validate() error

Validate reports an error when MaxBytes or MaxEvents is negative. A zero or positive value in either field passes. When both fields are negative, Validate checks MaxBytes first and returns only the MaxBytes error.

Jump to

Keyboard shortcuts

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