Documentation
¶
Overview ¶
Package shrink compresses LLM tool descriptions before they are sent to the provider. It implements the tool-description shrink pattern GrayCode tool-description shrink pipeline:
- For each tool description, apply the shrink rules: - drop articles ("a", "an", "the") - drop filler words ("just", "really", "basically") - drop pleasantries - dictionary substitutions ("in order to" -> "to")
- Skip descriptions that mention security/destructive keywords (auto-clarity: preserve verbatim).
- Cap the result to a max length (default 200 chars).
- Report aggregate bytes/tokens saved across all tools.
The shrink is applied to descriptions only; tool names and schemas are passed through unchanged so the LLM can still invoke the tool correctly.
This is a low-level utility. Callers (typically the eyrie client) call ShrinkTools() on a []*types.Tool before passing them to the provider. Original tools are not modified.
Index ¶
Constants ¶
const MaxLen = 200
MaxLen is the default cap on a single description length.
Variables ¶
This section is empty.
Functions ¶
func ShrinkDescription ¶
ShrinkDescription returns the shrunk version of desc. Returns (desc, false) if desc contains safety keywords (caller should keep the original verbatim).
Types ¶
type Result ¶
type Result struct {
OriginalBytes int
CompressedBytes int
BytesSaved int
PercentOff float64
ToolsProcessed int
ToolsSkipped int // skipped due to security/destructive keywords
}
Result reports per-call savings.
func ShrinkTools ¶
ShrinkTools returns a new slice with each tool's description shrunk. Original tools are not modified. The Result reports aggregate savings.