tool_result.
The two lines are independent. TELOS shrinks what you pay full price for again (the prefix);
RTK shrinks what you add as new tokens each round (the tool tail). They are controlled separately
by the
TelosMode four-state switch.The four-state switch
| label | telos | rtk | Meaning |
|---|---|---|---|
none | ✗ | ✗ | Pure passthrough — the proxy does not change a single byte |
telos | ✓ | ✗ | TELOS prefix caching only (proxy default) |
rtk | ✗ | ✓ | RTK tool filtering only, no cache markers applied |
both | ✓ | ✓ | Both enabled |
telos, preserving the historical behavior from
before the switch was introduced. Switch it live:
The filters
RtkFilter— shells out to thertkbinary (rtk filter --command <cmd>reading stdin). Any failure degrades to passthrough.FallbackFilter— a dependency-free pure-Python filter: consecutive repeated lines folded into<line> (×N), head/tail truncation, pytest summary preserved. Guarantees the switch still takes effect whenrtkis not installed.CompositeFilter— runs rtk first; if it saves no bytes, falls back to the fallback filter.build_filter()— rtk available →Composite(rtk, fallback), otherwise a pureFallbackFilter.
How it’s wired into the proxy
- The
--modeCLI switch plus theX-Telos-Modeheader (sticky to the session on the first request). mode.rtkon →apply_filterruns before the TELOS pipeline.mode.telosoff → skip the pipeline and go straight to passthrough.apply_filter(raw, flt)is a pure function: it deep-copies the request, rewrites the text of everytool_result(both the string and block-list content forms), and looks up the command hint from the previous assistant message’stool_use.usage_loggains themode/compare_group/tool_output_reductionfields.
Architecture
Where RTK sits relative to the harness → bridge → engine pipeline.