rtk-ai/rtk

discover: add output-size logging to fallback path for accurate missed-savings estimates

Open

#2 130 ouverte le 27 mai 2026

Voir sur GitHub
 (1 commentaire) (0 réactions) (0 assignés)Rust (2 914 forks)batch import
area:clienhancementhelp wantedpriority:medium

Métriques du dépôt

Stars
 (48 085 stars)
Métriques de merge PR
 (Merge moyen 11j 1h) (45 PRs mergées en 30 j)

Description

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:

  • grep that returned 3 lines (no real savings possible)
  • grep that 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.

Guide contributeur