tooloutput

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package tooloutput provides deterministic truncation of tool output before it is fed back into the model context. This prevents large outputs (e.g. verbose build logs) from consuming disproportionate context window space.

All processing is deterministic — no LLM-based summarization. If LLM-based output summarization is needed in the future, it must be behind a flag to avoid contaminating evaluation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Process

func Process(toolOutput string, rule Rule) string

Process applies the rule to toolOutput, truncating if necessary. Returns the original output if the rule is zero-value or output is within limits. Never returns empty for non-empty input.

func RulesFromContext

func RulesFromContext(ctx context.Context) map[string]Rule

RulesFromContext retrieves the output processing rules from ctx. Returns nil when no rules are stored.

func WithRules

func WithRules(ctx context.Context, rules map[string]Rule) context.Context

WithRules returns a context carrying per-tool output processing rules.

Types

type Rule

type Rule struct {
	MaxLines          int    // 0 = unlimited
	MaxTokens         int    // 0 = unlimited (approximate: 4 chars ≈ 1 token)
	Truncation        string // "head", "tail", "head_tail"; default "tail"
	TruncationMessage string // template with {line_count}, {token_count}
}

Rule defines truncation parameters for a specific tool's output. A zero-value Rule is a no-op: output passes through unchanged.

func RuleForTool

func RuleForTool(ctx context.Context, toolName string) Rule

RuleForTool returns the output processing rule for the named tool, or a zero-value Rule (no-op) if no rule exists.

Jump to

Keyboard shortcuts

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