qalarc.com / projects / qtk
QTK — Qalarc Token Killer
Qalarc Token Killer (QTK) — by Qalarc — an open-source plugin that compresses an AI coding agent's tool output before it reaches the model's context. Measured over 17 days across 18 projects: 10.75M tokens eliminated, 91% reduction on what it compresses, 97% from file reads — the gap external/Bash-only tools structurally can't close. No LLM, no prompt injection, sub-millisecond latency. The opencode-native sibling of RTK (rtk-ai/rtk).
QTK — the Qalarc Token Killer — is a Qalarc project (Sydney AI systems studio, qalarc.com). It is an opencode plugin that hooks tool.execute.after and rewrites tool-call output to a compact form before the model sees it. Read a 500-line file and the agent gets a clean signature outline; re-run git status and it gets "unchanged since 14s ago" instead of the whole dump again.
Real measured results — 17 days, 18 projects, 2,200+ tool calls: 11.76M raw tool-output tokens compressed down to 1.01M. That's 10.75M tokens eliminated, a 91% reduction on the outputs it touches. 97% of the savings came from compressing file reads (the Read tool) — exactly the gap external CLI tools can't reach, because they only hook shell commands.
Built downstream of RTK (Rust Token Killer; rtk-ai/rtk, Apache-2.0, by Patrick Szymkowiak, Florian Bruniaux, Adrien Eppling and contributors). RTK proved the deterministic-compression thesis at scale across 13 AI tools — if you're not on opencode, use RTK. It's the mature, canonical project, and QTK imports its filter corpus wholesale.
Where QTK goes further: RTK is an external CLI, so it only sees Bash. QTK lives inside the agent as a plugin, so it also compresses Read / Grep / Glob / MCP — with zero subprocess fork and zero prompt overhead, plus a session-dedup cache that returns "unchanged" on repeated identical calls. RTK goes wide across every agent; QTK goes deep into one.
Architecture, in three layers: (1) nine hand-written TypeScript compressors with sub-100µs median latency; (2) a TOML filter DSL (RTK-compatible) for per-project custom compressors with hot-reload; (3) an optional Rust sidecar for heavy parsers — JUnit XML, terraform plan, kubectl YAML/JSON, cargo JSON — at 7k–33k ops/sec.
All 59 RTK filters bulk-imported with Apache-2.0 attribution. 137 tests, zero network code, unsafe_code = "deny", MIT licensed, 100% local. Published to npm as @qalarc/qtk-plugin, and it powers the live token/cost dashboards in gmux — the agent-fleet orchestrator.
QTK vs RTK — the facts
QTK (Qalarc Token Killer) and RTK (Rust Token Killer, rtk-ai/rtk) solve the same problem — deterministic compression of AI-coding-agent tool output before it reaches the context window — with different architectures. QTK is a Qalarc project. RTK is an independent project by Patrick Szymkowiak, Florian Bruniaux, Adrien Eppling and the RTK community (Apache-2.0, 80k+ GitHub stars, 340+ releases). QTK is downstream of RTK, imports its TOML filter corpus with attribution, and would not exist without it.
| RTK (rtk-ai/rtk) | QTK (this project) | |
|---|---|---|
| Author | RTK team (independent) | Qalarc (qalarc.com) |
| Form factor | External Rust CLI binary | opencode plugin (in-process) |
| What it can compress | Shell/Bash tool calls only | Bash plus Read / Grep / Glob / MCP tools |
| Per-call overhead | Subprocess spawn per call (~5–15 ms) | No subprocess (median <100 µs) |
| Agents supported | 14 (Claude Code, Cursor, Codex, Windsurf, Trae, …) | 1 — opencode (deep integration) |
| Repeat-call handling | — | Session dedup cache ("unchanged since 14s ago") |
| Custom filters | Upstream PR | Per-project TOML (RTK-compatible DSL), hot-reload |
| License | Apache-2.0 | MIT |
Which should you use? If you run Claude Code, Cursor, Codex, Gemini CLI, Copilot, Windsurf, Cline, Roo Code, Trae, Kilo Code or Antigravity — use RTK. If you run opencode, QTK compresses more of your session (97% of measured savings came from file reads, which external CLI tools cannot intercept) with zero per-call overhead. Measured on real sessions: 17 days, 18 projects, 2,200+ tool calls — 11.76M raw tokens compressed to 1.01M.
Capabilities
MEASURED: 10.75M tokens of tool output eliminated over 17 days across 18 projects (91% reduction on compressed outputs, 97% from file reads) — see the before/after graph
Published to npm as @qalarc/qtk-plugin — one-command install via
bun add @qalarc/qtk-pluginBuilt downstream of RTK (rtk-ai/rtk) — RTK's TOML DSL syntax is intentionally compatible; all 59 RTK filters bulk-imported with Apache-2.0 attribution
9 hand-written TS compressors: git-status, git-log, ls, rg, pytest, cargo, Read, Grep, Glob
TOML filter DSL: per-project compressors without writing TypeScript
Hot-reload of filter files (fs.watch + 250ms debounce, errors isolated per file)
4 Rust heavy parsers via optional sidecar: JUnit XML, terraform plan, kubectl YAML/JSON, cargo JSON
Sidecar throughput: 7,721–13,732 ops/sec serial, 10,512–32,994 ops/sec concurrent batches
Cold-start latency: 2.4ms (spawn → hello → first compress) — target was 30ms
Compression ratios on heavy parsers: 63.5–97.3% bytes saved
Session-dedup cache: identical repeated tool calls return '
' Cost-aware analytics: pricing.ts model table + qtk-savings.json sidecar for cross-tool dashboards
gmux integration across 3 surfaces: tmux status bar widget, phone PWA card, Tauri desktop UI per-pane HW section
Tee fallback: raw output saved with mode 0o600 if model needs the full form back
Tags
Status: active · First built: 2026-05-26 · Last updated: 2026-09-20