contextlimit

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// GatewayResultTier matches internal/conversation/flow's gateway prune for
	// tool-result content.
	GatewayResultTier = Tier{
		MaxBytes:  textprune.DefaultMaxBytes,
		MaxLines:  textprune.DefaultMaxLines,
		HeadBytes: 6 * 1024,
		TailBytes: 2 * 1024,
		HeadLines: 180,
		TailLines: 50,
		Marker:    textprune.DefaultMarker,
	}

	// GatewayArgsTier matches internal/conversation/flow's gateway prune for
	// tool-call arguments.
	GatewayArgsTier = Tier{
		MaxBytes:  textprune.DefaultMaxBytes,
		MaxLines:  textprune.DefaultMaxLines,
		HeadBytes: 4 * 1024,
		TailBytes: 2 * 1024,
		HeadLines: 180,
		TailLines: 50,
		Marker:    textprune.DefaultMarker,
	}
)

Functions

func EncodedExceeds

func EncodedExceeds(value any, limit ToolOutputLimit) bool

func LimitError

func LimitError(err error, label string, limit ToolOutputLimit) error

func LimitString

func LimitString(text, label string, limit ToolOutputLimit) string

func LimitToolOutput

func LimitToolOutput(output any, label string, limit ToolOutputLimit) any

func MarshalString

func MarshalString(value any) string

Types

type Tier

type Tier struct {
	MaxBytes  int
	MaxLines  int
	HeadBytes int
	TailBytes int
	HeadLines int
	TailLines int
	Marker    string
}

Tier is a named layered truncation policy: MaxBytes/MaxLines are the outer ceiling that decides whether truncation engages at all; HeadBytes/TailBytes and HeadLines/TailLines are the retained head/tail split once it does.

func (Tier) LimitString

func (t Tier) LimitString(s, label string) string

LimitString truncates s to this tier's head/tail budget, UTF-8 safely, once s exceeds the tier's ceiling.

type ToolOutputLimit

type ToolOutputLimit struct {
	MaxBytes int
	MaxLines int
}

func NormalizedLimit

func NormalizedLimit(limit ToolOutputLimit) ToolOutputLimit

Jump to

Keyboard shortcuts

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