usage

package
v1.0.2 Latest Latest
Warning

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

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

Documentation

Overview

Package usage defines the Usage value object — an immutable accumulator of token counts produced during assistant Events.

Usage is a commutative monoid under Add: it has an identity element (Zero) and an associative, commutative binary operation (Add).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Usage

type Usage struct {
	Input         int64
	Output        int64
	CacheRead     int64
	CacheCreation int64
}

Usage holds token counts accumulated during a single assistant Event or a sum of many Events. It is an immutable value object; Add never mutates the receiver.

func Zero

func Zero() Usage

Zero returns the identity element of the Usage monoid. Zero.Add(a) == a and a.Add(Zero) == a for any Usage a.

func (Usage) Add

func (u Usage) Add(other Usage) Usage

Add returns a new Usage whose counters are the element-wise sum of u and other. Neither u nor other is modified.

func (Usage) IsZero

func (u Usage) IsZero() bool

IsZero reports whether u is the zero value (identity element). Useful for distinguishing real assistant events from content-split duplicates whose usage has been zeroed at the JSONL adapter level.

Jump to

Keyboard shortcuts

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