Documentation
¶
Index ¶
- Constants
- Variables
- func EncodedExceeds(value any, limit ToolOutputLimit) bool
- func LimitError(err error, label string, limit ToolOutputLimit) error
- func LimitString(text, label string, limit ToolOutputLimit) string
- func LimitToolOutput(output any, label string, limit ToolOutputLimit) any
- func MarshalString(value any) string
- func TruncateStepToolResult(msg sdk.Message, thresholdBytes int) (out sdk.Message, ok bool)
- type Tier
- type ToolOutputLimit
Constants ¶
const StepToolResultTruncateBytes = 512
StepToolResultTruncateBytes is the content-size threshold above which an old tool-result message is replaced with a byte-count summary during step-level / mid-task pruning.
Variables ¶
var ( // PruneTier matches internal/agent/tools' pre-unification tool-output // pruning (exec stdout/stderr, etc.): the same head/tail split contextlimit // itself already defaults to. PruneTier = Tier{ MaxBytes: textprune.DefaultMaxBytes, MaxLines: textprune.DefaultMaxLines, HeadBytes: toolOutputHeadBytes, TailBytes: toolOutputTailBytes, HeadLines: toolOutputHeadLines, TailLines: toolOutputTailLines, Marker: textprune.DefaultMarker, } // 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 TruncateStepToolResult ¶
TruncateStepToolResult replaces each sdk.ToolResultPart in msg whose own encoded size exceeds thresholdBytes (falling back to StepToolResultTruncateBytes when thresholdBytes <= 0) with a "[tool result pruned: N bytes]" summary. Parallel-call batches share one tool message, so sizing is per part: small siblings survive verbatim, and every other field of the part — IsError above all — is preserved so a failed result never reads as success. ok reports whether msg was changed.
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 ¶
LimitString truncates s to this tier's head/tail budget, UTF-8 safely, once s exceeds the tier's ceiling.
type ToolOutputLimit ¶
func NormalizedLimit ¶
func NormalizedLimit(limit ToolOutputLimit) ToolOutputLimit