discover: add output-size logging to fallback path for accurate missed-savings estimates
Aperta il 27 mag 2026
Descrizione
Problem
rtk discover estimates missed savings by matching command names against known RTK handlers. This produces false positives for commands that RTK handles but can't profitably compress — because the output is already small.
Example: 91 git push calls were flagged as ~5.8K tokens saveable. In practice, git push output is typically 1-3 lines (Everything up-to-date, or a brief ref update). RTK correctly falls back with 0% savings. No tokens were actually wasted.
The core issue: discover has no way to distinguish:
grepthat returned 3 lines (no real savings possible)grepthat returned 3,000 lines (real savings missed)
Proposed fix
Add output-size logging to the fallback path. When RTK decides not to compress a command result, record the output token/byte count alongside the fallback event.
rtk discover (or a new rtk discover --accurate mode) could then surface only fallbacks where output exceeded a meaningful threshold — these are the genuine missed opportunities where context is being wasted.
What this enables
A reliable answer to: "are there commands producing large output that RTK isn't compressing?" — the actual question users care about. The current heuristic answers a different question ("does RTK have a handler for this command name?") that doesn't map to real context waste.
Current workaround
None. Users have to manually test commands or check rtk gain --history to identify false positives after the fact.