Every agent has the same enemy: a single tool call that dumps 200KB of logs into context and blows up cost, latency, and focus for the rest of the session.

RTK first: shrink
Before anything reaches the model, the output passes through RTK — a small reduction pipeline that removes noise instead of content:
- Strip. ANSI colors, control characters, and trailing whitespace go first — pure formatting weight with zero information.
- Dedup. Repeated identical lines (progress bars, heartbeat logs, retried output) collapse into one line plus a repeat count.
- Smart-truncate. If the output is still oversized, RTK keeps the head and the tail — where the setup and the actual error usually live — and marks exactly what was cut.
Most outputs end here: smaller, readable, and complete enough to act on.

Still big? Offload to file
Some outputs can't be shrunk enough — a full test log, a big search result, a long build trace. Those go to disk instead of context. What the agent sees is a preview: the first 100 lines, the last 100 lines, and a footer with the full output path.
The contract is simple: context stays small and predictable, while nothing is lost — the complete output is one path away whenever it matters.

Agent reads back only what it needs
The preview is usually enough to decide the next step. When it isn't, the agent reads a targeted slice of the file — a line range around the failure, a filtered section — instead of pulling the whole thing into context.
The full file never returns to context. The agent pays for the slice it actually uses, not the 200KB it might have needed.
The short version
RTK shrinks every tool output first, and anything still over the limit (50KB or 2000 lines) is offloaded to a private 0600 file with a head-plus-tail preview, cleaned up automatically after 7 days or past a 500MB cache cap. Small context, full output, no work lost. That is the whole trick — shrink by default, offload when big, and read back only the slice that matters.