RTK Token Saver
RTK (Result Token Kompressor) is lina-router's built-in middleware that automatically compresses tool_result content before it reaches the AI model — saving 20–40% tokens on every request.
What is a tool_result?
When AI coding tools run shell commands — git diff, grep, ls, file reads — the output gets sent back to the model as a tool_result message. These can be massive.
A single git diff on a medium-sized change can produce 3,000–8,000 tokens. Most of that verbosity doesn't add value — the model understands a compressed version just as well.
Request flow with RTK
Before vs After
RTK strips redundant whitespace, trims excessive context lines, removes binary blob representations, and normalizes repetitive patterns — while preserving all semantically important information.
| Tool output | Before RTK | After RTK | Saved |
|---|---|---|---|
| git diff (medium PR) | 4,200 tok | 2,580 tok | -38% |
| ls -la (large dir) | 800 tok | 480 tok | -40% |
| grep output (50 matches) | 1,600 tok | 1,040 tok | -35% |
| File read (500 lines) | 6,000 tok | 3,900 tok | -35% |
Configuration
RTK is enabled by default for all requests routed through lina-router. No configuration required.
To disable RTK (not recommended), go to Dashboard → Settings → RTK Token Saver → Off.
You can also control RTK aggressiveness (compression level) in the same settings panel. Default is "Balanced" — best savings without ever confusing the model.
tool_result blocks before forwarding to the provider.