truncate

package
v0.51.0-rc.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArrayInfo

type ArrayInfo struct {
	Path  string
	Count int
	Size  int // Character size of the array in JSON
}

ArrayInfo holds information about found arrays

type TruncationResult

type TruncationResult struct {
	TruncatedContent string `json:"truncated_content"`
	CacheKey         string `json:"cache_key,omitempty"`
	RecordPath       string `json:"record_path,omitempty"`
	TotalRecords     int    `json:"total_records,omitempty"`
	TotalSize        int    `json:"total_size"`
	CacheAvailable   bool   `json:"cache_available"`
}

TruncationResult represents the result of truncating a tool response

type Truncator

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

Truncator handles truncating large tool responses

func NewTruncator

func NewTruncator(limit int) *Truncator

NewTruncator creates a new truncator with the specified character limit

func (*Truncator) ShouldTruncate

func (t *Truncator) ShouldTruncate(content string) bool

ShouldTruncate returns true if content should be truncated

func (*Truncator) SimpleTruncateBudget

func (t *Truncator) SimpleTruncateBudget() int

SimpleTruncateBudget returns the number of content bytes the simpleTruncate path actually retains before appending its notice, or 0 when truncation is disabled (limit 0 = unlimited). Spec 084 (T031b): the TOON encoder's too-small-budget guard must match the truncator's REAL retained prefix, not the raw limit — an encoded TOON block is not valid JSON, so Truncate always falls into simpleTruncate for it, which keeps limit - messageSpace bytes (messageSpace = 200, or limit/2 when limit < 200). This mirrors simpleTruncate exactly; keep the two in sync.

func (*Truncator) Truncate

func (t *Truncator) Truncate(content, toolName string, args map[string]interface{}) *TruncationResult

Truncate analyzes and truncates a tool response if it exceeds the limit

Jump to

Keyboard shortcuts

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