AI product Open source

trim-1

trim-1 is a small model, Go library, and command-line tool that selects the lines of a context an AI agent needs for a query. It accepts tool output, files, logs, or chats and returns the selected lines in their original order, inserting a marker where lines were removed rather than rewriting or summarizing them.

View repository Mentioned in 1 video ↓

Overview

The embedded 1.2 MB model uses 712 gradient-boosted trees rather than a neural network. It runs deterministically in milliseconds on one CPU core, with no GPU, network call, or external dependencies. The CLI supports conservative, balanced, and aggressive cutting modes; the Go API also exposes per-line keep probabilities through trim.Score.

trim-1 is implemented in pure Go using the standard library and requires Go 1.23 or newer. It fails closed for blank or unsuitable contexts, including contexts below 2,000 bytes, above 8 MiB or 200,000 lines, contexts already containing a removal marker, or cuts that would remove less than 10% of the bytes. The repository is licensed under Apache-2.0, with copied Go math.Exp code separately covered by the BSD license noted in LICENSE-go.

What trim-1 is used for

1 use taken from transcripts — each links to the moment in the video.

  • A tiny model that decides which lines of a context an AI agent actually needs for its current question. Written in pure Go and running on 712 gradient-boosted trees in about a megabyte, it keeps useful lines in their original order and marks wherever something was cut.

Videos mentioning trim-1

1 in the library.