Documentation
¶
Overview ¶
Package whittle carves agent tool outputs down to what matters — and never cuts what doesn't come back.
Whittle is a content-aware compressor for the text an AI agent reads: tool outputs, file reads, logs, JSON, terminal streams. It routes each input to a type-specific strategy and holds one hard line: structural compression is LOSSLESS or CLEARLY MARKED, code never reaches a lossy model, and any anomaly fails open to the original bytes.
The deterministic strategies (JSON columnar reshaping, log selection with omission markers, terminal CR-overwrite collapse, ANSI stripping) work with no dependencies. The optional ML prose path (LLMLingua-2, see model/) activates only when Options.ModelURL (or WHITTLE_MODEL_URL) points at a running model sidecar.
eng := whittle.New(whittle.Options{})
res := eng.Compress(ctx, toolOutput)
if res.Action == "compressed" {
use(res.Output) // res.SkipReason explains any skip
}
Index ¶
Constants ¶
This section is empty.
Variables ¶
var SidecarFS embed.FS
SidecarFS carries the Python model sidecar inside the binary so that `go install .../cmd/whittle@latest` is a complete installation: `whittle setup` materializes these files to ~/.whittle/model and builds a venv there.
Functions ¶
func EstimateTokens ¶
EstimateTokens is whittle's calibrated token estimator (MAE ~8% vs tiktoken o200k_base) — the same accounting the engine's accept gates use.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is a reusable, concurrency-safe compressor.
type Options ¶
type Options struct {
// ModelURL enables the ML prose path (an LLMLingua sidecar, see model/).
// Empty = prose and doc-read content pass through untouched.
ModelURL string
// MinTokens skips inputs shorter than this (default 64; compression isn't
// worth it below that). Use -1 to keep the default; 0 disables the floor.
MinTokens int
// MaxChars is the global safety ceiling; larger inputs skip before
// classification (default 256 KiB).
MaxChars int
// ProseMaxChars caps only the ML prose path (default 4500 — a latency
// budget, not a correctness bound).
ProseMaxChars int
// Logger receives pipeline diagnostics (nil = silent).
Logger compress.Logger
}
Options configures an Engine. The zero value is production-safe: deterministic compressors only, default gates.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
whittle
command
Command whittle is the CLI: compress files or stdin, or run the HTTP service.
|
Command whittle is the CLI: compress files or stdin, or run the HTTP service. |
|
Package compress is the content-aware tool-output compressor library: a gate decides whether content is safe to compress, a router classifies it, and a pipeline dispatches to specialized compressors.
|
Package compress is the content-aware tool-output compressor library: a gate decides whether content is safe to compress, a router classifies it, and a pipeline dispatches to specialized compressors. |
|
compressors
Package compressors holds the concrete Compressor implementations and wires the default per-type chains.
|
Package compressors holds the concrete Compressor implementations and wires the default per-type chains. |
|
Package server is whittle's HTTP front door.
|
Package server is whittle's HTTP front door. |