Repository navigation
Description
Summary
rtk gain reports Total exec time and a derived average. Any long-running
interactive command wrapped by rtk — e.g. launching a TUI as rtk claude —
records its entire session lifetime into exec_time_ms. Those rows filter
nothing (input_tokens = 0), but they completely dominate the time aggregate.
rtk 0.49.0, macOS arm64, 90-day window:
reported: Total exec time: 92607m0s (avg 9m5s)
Split by row kind:
| kind | rows | input_tok | saved_tok | minutes |
|---|---|---|---|---|
rtk fallback: … |
4,608 | 0 | 0 | 92,499 |
| real (filtered) commands | 5,590 | 21,145,470 | 11,049,817 | 107 |
Within the fallback class, 131 rows of rtk fallback: claude alone account for
92,358 minutes — 99.7% of the reported total — averaging 11.75 h each, max 75.4 h
(a session left open over a weekend).
Actual filtering work is 107 minutes across 5,590 commands, avg 1.15 s. The
reported avg 9m5s is an 865x overstatement, and Total exec time is really
measuring how long the TUI was open.
Reproduce
-- against a COPY of history.db
SELECT CASE WHEN rtk_cmd LIKE 'rtk fallback%' THEN 'fallback' ELSE 'real' END AS kind,
COUNT(*) AS rows_,
SUM(input_tokens) AS input_tok,
SUM(exec_time_ms)/60000 AS minutes
FROM commands GROUP BY kind;
-- the offenders
SELECT rtk_cmd, COUNT(*) n, SUM(exec_time_ms)/60000 minutes, MAX(exec_time_ms)/60000 max_min
FROM commands WHERE rtk_cmd LIKE 'rtk fallback%' GROUP BY rtk_cmd ORDER BY minutes DESC LIMIT 5;Why this isn't just "don't do that"
Wrapping a TUI is a reasonable thing for a user to try, and rtk accepts it silently:
rtk claude runs, the row is recorded, no warning is emitted. The stats then become
unreadable with no indication why.
Worth noting the hook is not involved — rtk hook check "claude" correctly
returns No rewrite for: claude. This is the direct rtk <cmd> path, and
[hooks] exclude_commands in config.toml has no effect on it.
Suggested fix
Any one of these would be sufficient:
- Exclude zero-token rows from the time aggregate. A row with
input_tokens = 0
did no filtering work, so its duration isn't rtk's to report. This also fixes the
command count, which is inflated 10,198 → 5,590 on this install. - Cap or flag outlier durations. Anything past a threshold (~60 s) is almost
certainly an interactive or long-running process, not a filter operation. - Report median duration beside the mean, consistent with
gain: add median and concentration to the summary — means alone hide what the tool is actually doing #3507. - Optionally, warn when rtk is asked to wrap a known interactive TUI.
Related
Same family of accounting defects, but a different aggregate — none of these cover
the time column:
gain: savings are counted without a context ceiling — reported figure ~184x the real one on my install #3508 — savings counted with no context ceiling (this install: top 1 row = 52.7%
of lifetime savings, a singlegit diff HEAD --binaryat 11.7M input tokens)gain: add median and concentration to the summary — means alone hide what the tool is actually doing #3507 — mean-only summary hides median and concentration (this install: median
savings 0.0%, top 100 rows = 97.2% of lifetime savings)rtk hook claude: option to fall back tortk proxyso unfiltered commands are measured (in=0/out=0 is 23.5% of history.db) #3522 — zero-token fallback rows (this install: 4,608 of 10,198 rows, 45%)
Activity
rtk-wshm-sync-bot commentedon Sep 12, 2026
🔍 Automated Triage
bugmediumSummary
gain's Total exec time aggregate is dominated by interactive TUI session durations (zero-token fallback rows); exclude zero-token rows or cap outlier durations in the time aggregate, and report median alongside mean
Triaged automatically by wshm · This is an automated analysis, not a human review.
fix(gain): exclude zero-input rows from exec time totals
fix(gain): exclude zero-input rows from exec time totals
chore(upstream): merge 341 commits from rtk-ai/rtk develop (2 Novembe…
chore(upstream): record rtk-ai/rtk develop 22812af as merged so the n…
chadalanlester commentedon Nov 18, 2026
Thank you!