11# Squeez
22
3+ <p align =" center " >
4+ <img src =" https://github.com/KRLabsOrg/squeez/blob/main/assets/squeez_mascot.png?raw=true " alt =" Squeez Logo " width =" 300 " />
5+ <br ><em >Squeeze out the juice, leave the pulp behind.</em >
6+ </p >
7+
38Squeeze verbose LLM agent tool output down to only the relevant lines.
49
510[ ![ PyPI] ( https://img.shields.io/pypi/v/squeez )] ( https://pypi.org/project/squeez/ )
@@ -12,6 +17,116 @@ LLM coding agents waste **80-95% of context tokens** on irrelevant tool output.
1217
1318Squeez trains a small (2-3B) generative model to identify and extract only the lines that matter for the task at hand — compressing tool output by ~ 86% on average.
1419
20+ ## Example
21+
22+ Task: * "Fix the CSRF validation bug in the referer check"*
23+
24+ <table >
25+ <tr >
26+ <th >Before — 42 lines, ~1,200 tokens</th >
27+ <th >After — 8 lines, ~150 tokens</th >
28+ </tr >
29+ <tr >
30+ <td >
31+
32+ ``` python
33+ class CsrfViewMiddleware (MiddlewareMixin ):
34+ def _check_referer (self , request ):
35+ referer = request.META .get(' HTTP_REFERER' )
36+ if referer is None :
37+ raise RejectRequest(' No referer' )
38+ good_referer = request.get_host()
39+ if not same_origin(referer, good_referer):
40+ raise RejectRequest(' Bad referer' )
41+
42+ def process_view (self , request , callback , ...):
43+ if getattr (request, ' csrf_processing_done' , False ):
44+ return None
45+ csrf_token = request.META .get(' CSRF_COOKIE' )
46+ if csrf_token is None :
47+ return self ._reject(request, ' No CSRF cookie' )
48+ return self ._accept(request)
49+
50+ class SessionMiddleware (MiddlewareMixin ):
51+ def process_request (self , request ):
52+ session_key = request.COOKIES .get(... )
53+ request.session = self .SessionStore(session_key)
54+
55+ def process_response (self , request , response ):
56+ if request.session.modified:
57+ request.session.save()
58+ return response
59+
60+ class CommonMiddleware (MiddlewareMixin ):
61+ def process_request (self , request ):
62+ host = request.get_host()
63+ if settings.PREPEND_WWW and ... :
64+ return redirect(... )
65+
66+ def process_response (self , request , response ):
67+ if settings.USE_ETAGS :
68+ response[' ETag' ] = hashlib.md5(... )
69+ return response
70+
71+ class SecurityMiddleware (MiddlewareMixin ):
72+ def process_request (self , request ):
73+ if settings.SECURE_SSL_REDIRECT and ... :
74+ return redirect(... )
75+ ```
76+
77+ </td >
78+ <td >
79+
80+ ``` python
81+ class CsrfViewMiddleware (MiddlewareMixin ):
82+ def _check_referer (self , request ):
83+ referer = request.META .get(' HTTP_REFERER' )
84+ if referer is None :
85+ raise RejectRequest(' No referer' )
86+ good_referer = request.get_host()
87+ if not same_origin(referer, good_referer):
88+ raise RejectRequest(' Bad referer' )
89+ ```
90+
91+ ** 87% compression** — only the CSRF referer logic survives. Session, Common, and Security middleware are irrelevant to the task and get dropped.
92+
93+ </td >
94+ </tr >
95+ </table >
96+
97+ ``` bash
98+ $ cat django/middleware.py | squeez " Fix the CSRF validation bug in the referer check"
99+ ```
100+
101+ <details >
102+ <summary ><b >Another example — filtering git log</b ></summary >
103+
104+ Task: * "Find the commit that changed the authentication timeout"*
105+
106+ ** Before** — 25 commits of noise:
107+ ```
108+ a1b2c3d Fix typo in README
109+ e4f5g6h Update CI pipeline
110+ i7j8k9l Bump version to 2.3.1
111+ m0n1o2p Add docker-compose.yml
112+ q3r4s5t Refactor database migrations
113+ u6v7w8x Change auth timeout from 30m to 1h
114+ y9z0a1b Fix linting warnings
115+ c2d3e4f Update dependencies
116+ ...
117+ ```
118+
119+ ** After** — the one commit that matters:
120+ ```
121+ u6v7w8x Change auth timeout from 30m to 1h
122+ ```
123+
124+ ``` bash
125+ $ git log --oneline -25 | squeez " find the commit that changed the authentication timeout"
126+ ```
127+
128+ </details >
129+
15130## Installation
16131
17132``` bash
@@ -52,15 +167,41 @@ The model returns JSON: `{"relevant_lines": ["line1", "line2", ...]}` and the `e
52167
53168### Configuration
54169
55- By default, squeez connects to a vLLM server. Configure with:
170+ Backend is resolved in order: CLI args > env vars > config file (` squeez.yaml ` or ` configs/default.yaml ` ).
171+
172+ ``` yaml
173+ # squeez.yaml
174+ model_path : " ./output/squeez_qwen" # local transformers
175+ # base_url: "https://api.groq.com/openai/v1" # or remote API
176+ ```
56177
57178``` bash
58- # Environment variable
59- export TOE_BASE_URL=http://localhost:8000/v1
179+ # Or via environment variables
180+ export SQUEEZ_MODEL_PATH=./output/squeez_qwen
181+ export SQUEEZ_BASE_URL=https://api.groq.com/openai/v1
182+ export SQUEEZ_API_KEY=gsk_...
183+ ```
184+
185+ ### Use with Claude Code
186+
187+ Add this to your project's ` CLAUDE.md ` (or ` ~/.claude/CLAUDE.md ` for global):
60188
61- # Or pass directly
62- extractor = ToolOutputExtractor(base_url=" http://my-server:8000/v1" )
63189```
190+ Always when you invoke a shell command, pipe it through `squeez` and tell exactly what you want to know.
191+
192+ Examples:
193+ - `bun test 2>&1 | squeez "did the tests pass?"`
194+ - `git log --oneline -50 | squeez "find the commit that broke CSRF"`
195+ - `cat src/auth/middleware.py | squeez "find the referer validation logic"`
196+
197+ Do NOT use squeez when:
198+ - You need exact, uncompressed output (e.g. writing a patch)
199+ - The command is interactive
200+ ```
201+
202+ This saves context tokens by replacing verbose tool output with only the relevant lines.
203+
204+ Also works with other coding agents (Codex CLI, OpenCode, etc.) via their equivalent instruction files.
64205
65206## Training
66207
0 commit comments