# trim-1: 1.2 MB 모델로 에이전트의 입력 줄이기
# trim-1: a 1.2 MB model that keeps only the lines an agent needs

- Site: https://select1.dev/2026-10-15 (English), https://select1.dev/ko/2026-10-15 (Korean)
- Entry: 005
- Published: 2026-10-15 (KST). Launch date: 2026-10-14
- Pick: trim-1 <https://github.com/caveman-ai/trim-1> (source: GitHub)
- Verified: ran
- What: trim-1 은 에이전트의 입력을 줄이는 오픈소스 프로덕트다. 긴 문맥을 줄 단위로 나눠 지금 질의에 필요하면 남기고 아니면 지운다. 모델은 1.2 MB 이고 Go 프로그램 하나에 들어 있으며, 의존성이 없다.
- What (en): trim-1 is an open-source product that keeps only the lines of a long context that an agent needs for its current query. Its 1.2 MB model is built into a single Go program with no dependencies.
- Why: 오늘의 픽으로 선정한 이유는 1.2 MB 트리 모델로 로그와 문서에서 필요 없는 줄만 지우고, 요약과 달리 원문을 바꾸지 않아서다.
- Why (en): It is today's pick because a 1.2 MB tree model deletes only the unneeded lines from logs and documents, and unlike a summary it never changes the original text.
- Verdict: 작동한다. 코드 41 KB 를 질의 하나로 65% 줄이면서 답이 있는 줄은 남겼다.
- Verdict (en): It works. One query cut 41 KB of code by 65% and kept the lines that held the answer.
- Tags: agent, context, small-model, go, local-first, ai-built

## Checked against the README

- [pass] 출력의 줄은 전부 입력의 줄 그대로이고 순서도 그대로다 — 코드 41 KB 와 HN 스레드 35 KB 의 출력을 입력과 줄 단위로 대조. 표시줄(… N lines …) 32개와 7개 외에는 모두 입력의 줄이고 순서가 보존됨
- [pass] 같은 입력과 질의는 같은 출력을 낸다 — 같은 명령 4회의 sha256 이 동일
- [pass] 입력이 2,000 바이트 미만이거나, 자신의 출력을 다시 받았거나, 10% 를 줄이지 못하면 입력을 그대로 반환한다 — 1,800 B 로그 → unchanged (context below the minimum size). 출력 재입력 → unchanged (cut below the minimum). 35 KB 스레드 balanced → unchanged
- [fail] 질의가 비어 있으면 입력을 그대로 반환한다 — CLI 에 --query "" 를 전달하자 종료 코드 2 와 사용법만 출력되고 stdout 은 0 바이트. 라이브러리 동작과 다름

## Measured

- 호출 1회 경과 시간(35 KB·약 8,700 토큰 입력, 프로세스 시작 포함, 10회): 23~34 ms (date +%s%N 으로 trim 실행 전후 차이. 41 KB 는 41~58 ms, 245 KB 는 94~121 ms. 모델 카드의 in-process 수치(5,000 토큰 7.2 ms)와 방법이 다름)

## Progress (days after launch; full history https://select1.dev/2026-10-15/progress)

- day 3 (checked 2026-10-17) [active] commits since launch 4, stars 117, releases 1, contributors 2, last commit 2026-10-14
  - Input is now capped before it is read into memory, so a very large input cannot exhaust memory. An outside contributor sent the fix.
- day 7 (checked 2026-10-21) [quiet] commits since launch 4, stars 171, releases 1, contributors 2, last commit 2026-10-14

## 한국어

## 무엇이 문제인가

에이전트는 로그와 도구 결과, 긴 문서를 전부 읽는다. README 의 첫 이미지가 그 예다. 오류 하나를 찾으려고 로그 전체를 읽는다. 읽는 분량만큼 토큰을 쓰고, 문맥 한도도 그만큼 빨리 찬다.

코딩 에이전트 Claude Code 도 이 문제를 두 가지 방법으로 다룬다. 공식 문서에 따르면 대화가 문맥 한도에 가까워지면 지난 대화를 요약해 압축한다. 무엇을 남길지 지시할 수는 있지만 결국 요약이라 원문의 세부가 빠질 수 있고, 압축 자체도 큰 요청이다. 문서에는 훅 예시도 있다. 훅이 로그를 `grep ERROR` 로 걸러 그 결과만 에이전트에게 전달한다. 이 방법은 모델 호출이 필요 없지만, 답이 있어도 그 줄에 키워드가 없으면 빠진다. 제작자는 README 에서 요약과 `| tail -20` 을 비교 대상으로 든다.

## 어떻게 해결했나

trim-1 은 지우기만 한다. 문맥을 줄 단위로 나누고, 각 줄이 지금 질의에 얼마나 필요한지 점수로 계산해 기준보다 낮으면 지운다. 줄의 내용과 순서는 바꾸지 않고, 줄을 지우면, 지운 줄 대신 "… 25 lines …" 같은 표시줄을 삽입한다. README 에는 질의가 비어 있으면 라이브러리가 입력을 그대로 반환한다고 적혀 있다. 입력이 2,000 바이트 미만이거나 지워도 10% 를 줄이지 못할 때도 입력을 그대로 반환한다.

## 무엇이 다른가

점수는 신경망이 아니라 결정 트리 712개가 산출한다. 모델 카드에 따르면 줄마다 질의와 비교해 수치 특징 67개를 계산한다. 어휘 일치, 줄의 종류(오류·경로·스택 프레임), 위치와 들여쓰기, 이웃 줄의 점수다. 트리라서 모델이 1.2 MB 이고, CPU 한 코어에서 밀리초 단위로 처리되며, 무작위성이 없어 결과가 결정적이다. 트레이드오프도 모델 카드에 적혀 있다. 줄 단위로만 지우므로 긴 줄 하나를 짧게 만들지는 못하고, 후속 근거는 질의와 단어가 겹치지 않으면 찾지 못한다. 코딩 에이전트의 도구 출력은 짧고 밀도가 높아서 기본 설정에서 1.9% 만 줄어들고, 본래 용도는 긴 문서 검색이다. 그 용도에서는 토큰 88.9% 를 지우면서 근거를 94.4% 유지했다고 적혀 있다.

## 어떻게 만들었나

- 커밋은 2026-10-13 과 14 이틀 동안 4개이고, 그중 2개에 Claude Opus 5.5 가 Co-authored-by 로 적혀 있다. 외부 컨트리뷰터의 PR 도 1개 있다. 입력 크기에 상한을 두어 메모리 고갈을 막는다.
- 코드는 Go 1,788줄이다. features.go 가 특징을 계산하고 model.go 가 트리를 평가하며, model.bin 은 go:embed 로 바이너리에 포함한다. 테스트는 2개다. 예측값이 학습 라이브러리와 비트 단위로 같은지, 샘플 로그의 출력이 고정값과 같은지 확인한다.
- 제작자 Julius Brussee 는 Caveman 도 만들었다. Caveman 은 에이전트의 토큰을 줄이고, trim-1 은 Caveman 안에서 모델로 사용된다.
- 모델 카드에 따르면 학습 데이터는 모두 공개 데이터이고 상업 이용이 허용된다. 벤치마크 수치는 한 번만 실행해 얻었다.

## 실행해 보니

빌드한 뒤 아래 순서로 시험했다.

1. 빌드와 테스트. `go build` 는 9.7초에 완료됐고 바이너리는 4.2 MB 다. 의존성은 표준 라이브러리뿐이고, 테스트 2개가 0.166초에 통과했다. 모델 파일의 머리글에는 특징 67개, 트리 712개가 적혀 있었다.
2. 코드 41 KB. 이 사이트의 스크립트 10개를 하나로 합쳐 "how are visits fetched from Vercel analytics" 로 질의했다. 1,092줄 중 785줄이 지워져 14 KB 가 됐고, 방문 집계 스크립트의 API 주소와 토큰 변수는 그대로 유지됐다.
3. HN 스레드 35 KB. 스레드를 덤프해 "did the PS2 recompiler use AI generated code" 로 질의했다. 기본 설정에서는 10% 를 줄이지 못해 한 줄도 지우지 않았다(unchanged). 설정을 aggressive 로 변경하자 150줄 중 93줄을 지우고 15 KB 를 반환했다.
4. 출력 대조. 두 출력의 줄을 입력과 대조하니 표시줄 외에는 전부 입력의 줄이었고 순서도 같았다. 같은 명령을 4회 실행하자 해시가 모두 같았다.
5. 작은 입력과 재입력. 1,800 바이트 로그는 크기가 작다는 안내와 함께 그대로 반환됐다. 출력을 다시 입력해도 그대로 반환됐다.
6. 빈 질의. 이 경우만 README 와 다르게 동작했다. 라이브러리는 입력을 그대로 반환한다고 적혀 있지만, CLI 는 `--query ""` 를 받으면 종료 코드 2 를 반환하고 사용법만 표시했으며, stdout 은 비어 있었다. 파이프라인에서 출력을 리다이렉트로 받으면 빈 파일이 생성된다.
7. 처리 시간. 프로세스 시작까지 포함해 35 KB 입력이 23~34 ms, 스레드 덤프 7개를 이어 붙인 245 KB 입력이 94~121 ms 였다. 모델 카드의 7.2 ms(5,000 토큰)는 프로세스 안에서 측정해 방법이 다르다.

```
$ trim --query "how are visits fetched from Vercel analytics" scripts.txt
trim: kept 307 lines, removed 785, 41396 -> 14462 bytes
$ trim --query "did the PS2 recompiler use AI generated code" hn-threads.txt
trim: unchanged (cut below the minimum)
$ trim --query "" hn-threads.txt; echo exit=$?
usage: trim --query QUERY [--point POINT] [FILE]   (reads stdin without FILE)
exit=2
```

## 확인하지 못한 것

- 모델 카드의 벤치마크 수치. 긴 문서로 시험하지 않아 88.9% 와 94.4% 는 확인할 수 없었다.
- 실제 에이전트 루프에서 효과가 있는지. Caveman 이 어느 시점에 trim-1 을 호출하는지 다음에 그 저장소에서 확인하자.
- 한국어 입력. 영어로만 학습했다고 적혀 있어 한국어 로그로는 시험하지 않았다.

## 판정

작동한다. 코드 41 KB 를 질의 하나로 65% 줄이면서 답이 있는 줄은 남겼다. 다만 HN 스레드 덤프는 기본 설정에서 그대로 반환했다. 에이전트에게 긴 로그나 문서를 전부 전달하고 있고, 요약하면 원문이 바뀌어서 곤란한 경우에 써 볼 만하다. 도구 출력처럼 짧고 밀도가 높은 문맥을 줄이려면 이 프로덕트는 적합하지 않다. 모델 카드에도 기본 설정에서 2% 만 줄어든다고 적혀 있다.

## 얻어갈 것

- 에이전트에게 긴 문맥을 전달해야 한다면, 요약하기 전에 필요 없는 줄부터 지워 보자. 오늘 trim-1 의 출력은 표시줄을 빼면 전부 입력의 줄 그대로였다.
- 작은 모델을 사용할 때는 결과가 결정적인지부터 확인하면 된다. 같은 명령을 4회 실행해 sha256 이 모두 같았다.
- 입력이 비어 있으면 라이브러리와 CLI 가 똑같이 동작하게 맞추자. 오늘 CLI 는 빈 질의를 받자 종료 코드 2 를 반환했고, stdout 에는 아무것도 출력하지 않았다.
- 도구가 자신의 출력을 다시 받으면 어떻게 동작할지도 정해 두자. trim-1 은 입력에 자신의 표시줄이 있으면 그대로 반환했다.

### 용어

- 코딩 에이전트: 개발자 대신 코드를 읽고 고치고 명령을 실행하는 AI 프로그램. Claude Code, Codex 등이 있다.
- 훅: 정해진 시점에 자동으로 실행되도록 등록해 둔 스크립트. Git 은 커밋이나 푸시 직전에 훅을 실행한다.

## English

## The problem

Agents read logs, tool results and long documents in full. The first image in the README shows an example. An agent reads a whole log to find one error. Every line that an agent reads costs tokens and fills the context window sooner.

Claude Code, a coding agent, handles the same problem in two ways. Its documentation says that it summarizes earlier history to free space when a conversation nears the context limit. You can say what to preserve, but the summary can still lose details of the original. Compacting is itself a large request. The documentation also gives a hook that filters a log with `grep ERROR` before passing it on. That needs no model call. The filter drops the answer if its line lacks the keyword. The maker's READMEs compare trim-1 with summarizing and with `| tail -20`.

## How it solves it

trim-1 only removes lines. It splits the context into lines and scores each line for relevance to the current query. It drops the lines that score below a threshold. Kept lines are the original text in the original order, and a marker line such as "… 25 lines …" stands where lines were removed. The README says that the library returns the input unchanged when the query is empty. trim-1 also returns the input unchanged when the input is under 2,000 bytes or the cut would save less than 10%.

## What is different

trim-1 scores the lines with 712 decision trees, not a neural network. The model card says that trim-1 compares each line with the query and computes 67 numeric features. They include lexical matches such as BM25 and query-term coverage. Other features are the kind of line (error, test result, path, heading, stack frame), position, length, indent and the scores of neighbouring lines. Because the model uses trees, it is 1.2 MB and finishes in milliseconds on one CPU core. It is also deterministic. The model card also says that trim-1 works on whole lines, so it cannot shorten a long line. It drops later evidence that shares no words with the query. It was trained on English only. The default setting cuts only 1.9% from short, dense coding-agent tool outputs. The intended use is long-document retrieval. For that use, the card reports that it removes 88.9% of tokens and keeps the evidence in 94.4% of cases.

## How it was built

- The repository has four commits from 2026-10-13 and 2026-10-14. Two of them list Claude Opus 5.5 in a Co-authored-by trailer. One pull request from an outside contributor caps the input size to prevent exhausting memory.
- 1,788 lines of Go. features.go computes the features. model.go evaluates the trees and embeds model.bin with go:embed. There are two tests: a bit-for-bit parity check against the training library's predictions, and a golden-output test on a sample log.
- The maker, Julius Brussee, also makes Caveman, a tool that reduces an agent's token use. trim-1 is the model inside Caveman. The model card on Hugging Face is tagged LightGBM.
- The model card says that all training data is public and licensed for commercial use. The benchmark numbers come from a single run.

## Running it

1. Build and tests. `go build` finished in 9.7 seconds and the binary is 4.2 MB. The dependency list contains only this module and the standard library. The two tests passed in 0.166 seconds. The model file's header lists 67 features and 712 trees.
2. 41 KB of code. I combined this site's ten scripts into one file and queried it with "how are visits fetched from Vercel analytics". 785 of 1,092 lines were removed, and 14 KB remained. The analytics script's API address and token variable were kept.
3. 35 KB of HN threads. I queried a thread dump with "did the PS2 recompiler use AI generated code". At the default setting it could not save 10%, so nothing was removed (unchanged). The aggressive setting removed 93 of 150 lines and returned 15 KB.
4. Comparing outputs. I compared both outputs with their inputs line by line. Every output line except the markers was an input line, in the same order. Four runs of the same command gave the same hash.
5. Small input and output fed back in. A 1,800-byte log came back unchanged with a note about its size. When I fed an output back in, it also came back unchanged.
6. Blank query. This is the one case that differed from the README. The README says that the library returns the input unchanged. With `--query ""`, the CLI exited with code 2. It printed only the usage text and left stdout empty. A pipeline that redirects stdout gets an empty file.
7. Timing. The 35 KB input took 23–34 ms. I also joined seven copies of the thread dump into a 245 KB input, and it took 94–121 ms. Both times include process start. The model card's 7.2 ms for 5,000 tokens was measured in-process. That is a different method.

```
$ trim --query "how are visits fetched from Vercel analytics" scripts.txt
trim: kept 307 lines, removed 785, 41396 -> 14462 bytes
$ trim --query "did the PS2 recompiler use AI generated code" hn-threads.txt
trim: unchanged (cut below the minimum)
$ trim --query "" hn-threads.txt; echo exit=$?
usage: trim --query QUERY [--point POINT] [FILE]   (reads stdin without FILE)
exit=2
```

## Not checked

- The model card's benchmark numbers. No long document was tried, so the 88.9% and 94.4% could not be confirmed.
- The effect inside a real agent loop. The next step is to read the Caveman repository and find where it calls trim-1.
- Korean input. The card says English only, so no Korean log was tried.

## Verdict

It works. One query cut 41 KB of code by 65% and kept the lines that held the answer. On the HN thread dump, though, the default setting removed nothing. It is worth a try when an agent reads long logs or documents in full and the original text has to stay unchanged. If the goal is to shrink short, dense contexts such as tool outputs, this product is not the right choice. The model card itself puts the saving there at 2%.

## What to take away

- If an agent has to read a long context, try deleting the unneeded lines before summarizing it. Today every line of trim-1's output except the markers was an input line.
- Check that a small model is deterministic before adopting it. Four runs of the same command gave the same sha256.
- Make the blank-query behaviour the same in the library and the CLI. The CLI exited with code 2 and left stdout empty for a blank query.
- Decide what a tool does when fed its own output. trim-1 left input containing its own markers unchanged.

### Terms

- coding agent: An AI program that reads and edits code and runs commands for a developer. Claude Code and Codex are examples.
- hook: A script registered to run automatically at a set moment. Git, for example, runs hooks right before a commit or a push.

## Launches the same day

- Blumify People <https://blumify.io/people> (Show HN, 115): AI 업계 인물들의 발언을 영상과 팟캐스트에서 모아, 생각이 어떻게 바뀌는지 추적한다.
- Museum of Ages <https://museumofages.org/w/vinci> (Show HN, 85): 레오나르도 다빈치 가상 박물관. Three.js 와 WebGPU 로 만들었고, 정거장 17곳에 기계 15대를 코드로 재구성했다.
- Jevcrawl <https://github.com/RayenMlayeh/jevcrawl> (Show HN, 19): 에이전트용 크롤러. 작은 결정 모델이 링크와 문단을 고르고 LLM 은 답만 읽는다. Jev API 키가 필요하다.
- T0 <https://github.com/theforecastingcompany/tfc-t0> (Show HN, 11): 시계열 예측 모델. 가중치를 공개했고 파라미터 수는 256M 이다. CPU 에서도 제로샷으로 작동한다.
- Chiplab <https://veecle.ai/chiplab> (Show HN, 7): MCP 서버. 에이전트에게 가상 보드를 주고, 임베디드 펌웨어를 실물 없이 빌드하고 시험한다.
- Everything <https://github.com/HeyPuter/everything> (GitHub, 712): 모노레포. Office, Slack, Photoshop 의 대체 앱을 처음부터 다시 만들어 MIT 로 공개한다. 어떻게 만들었는지는 README 에 적혀 있지 않다.
- Graphicle <https://github.com/Graphicle-AI/graphicle> (GitHub, 101): 코드 그래프와 프로젝트 기억을 Rust 프로그램 하나에 담고, MCP 로 코딩 에이전트에 준다. 엔진은 Graphify 의 Rust 포팅이다.
- trim-1 <https://github.com/caveman-ai/trim-1> (GitHub, 65): 1.2 MB 트리 모델로 문맥에서 필요한 줄만 남긴다. 모델은 Go 프로그램에 들어 있고 의존성이 없다.
- Pancake <https://www.producthunt.com/products/pancake> (Product Hunt, 469): AI 도구. 영업과 마케팅 작업을 Vercel 처럼 배포한다고 소개한다.
- Inferock <https://www.producthunt.com/products/inferock> (Product Hunt, 334): 서버리스 추론 서비스. 호출이 실패하면 크레딧을 돌려준다.
- 바이브마트 VibeMart <https://disquiet.io/products/vibemart> (Disquiet): 웹앱 진열 사이트. 바이브코딩 웹앱을 직접 사용해 보고 골라서 일반 방문자에게 진열한다.
- Trade Paper AI <https://disquiet.io/products/trade-paper-ai> (Disquiet): 문서 도구. 수출 인보이스와 패킹 리스트를 작성하고 PDF 로 이메일까지 보낸다.

## Getting started

- Steps: git clone https://github.com/caveman-ai/trim-1 && cd trim-1 ; go build -o trim ./cmd/trim ; ./trim --query "why does the build fail" build.log > build.trimmed.log
- Needs: Go 1.23 이상, API 키, GPU, 네트워크 불필요. 모델이 바이너리에 들어 있다
- Cost: Apache-2.0, 무료. 모델도 Apache-2.0 이다. 가격 페이지는 없다.
- Note: go install github.com/caveman-ai/trim-1/cmd/trim@latest 로도 설치된다. --point 로 conservative, balanced, aggressive 를 선택한다. 기본은 balanced 다.
