You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: ls tracking baseline should compare against ls not ls -la #561
rtk ls internally runs ls -la to get file metadata for grouping/filtering, then compresses the output. The savings % is tracked against the ls -la output, not plain ls (which is what the agent would have run without RTK).
This inflates the reported savings. Example from user report:
ls = 332 tokens
ls -la = 4173 tokens
rtk ls = 993 tokens
Reported: 76.2% savings (vs ls -la)
Actual: -199% vs plain ls
Fix
Track against the baseline command the agent would have run (ls), not the internal enriched command (ls -la).
In src/ls.rs line 113-118, change the tracking input from the ls -la raw output to a plain ls capture (or estimate).
I am implementing this against current develop after the inactive PR #760 was closed. I will add an explicit tracking baseline to the shared runner, capture the exact user-facing ls invocation separately, and keep the enriched ls -la output only for filtering and display guards.
Independent reproduction — still present on master @ b34be37 and in v0.45.0, on macOS arm64.
I hit this while benchmarking RTK inside a coding harness and arrived at the same root cause before finding this issue. Adding fresh numbers since the report is from March.
The unconditional -la is at src/cmds/system/ls.rs:53, and the tracked baseline is the synthesised command at ls.rs:87 (&format!("-la {}", target_display)):
letmut cmd = resolved_command("ls");
cmd.env("LC_ALL","C");
cmd.arg("-la");// always, whatever the user asked for
Note the flag filter below it strips only l, a, and h, so other flags survive and combine with the injected -la. That means the effect is not limited to plain ls — it also applies to ls -R, where the enrichment is much more expensive:
$ ls -R src | wc -c # 6,926 what the agent would have run
$ ls -la -R src | wc -c # 33,692 what RTK runs internally
$ rtk ls -R src | wc -c # 8,956 what RTK returns
So RTK reports 73.4% saved while returning 29% more than the agent's own command. Two further details worth noting:
original_cmd is recorded as ls -la src — the synthesised command, not the ls -R src that was actually issued — so the row cannot be reconciled against the agent's transcript after the fact.
Activity
pszymkowiak commentedon Mar 20, 2026
🔍 Automated Triage
bugmediumSummary
ls savings baseline uses
ls -lainstead ofls, inflating reported savings; fix is localized to src/ls.rs and PR #760 is already in progress.📁 Relevant files
src/ls.rsTriaged automatically by wshm · This is an automated analysis, not a human review.
fix: ls -R hierarchy + tracking baseline + incompatible flags (#714, #…
fix: ls -R hierarchy + tracking baseline + incompatible flags (rtk-ai…
lntutor commentedon Jul 19, 2026
I am implementing this against current develop after the inactive PR #760 was closed. I will add an explicit tracking baseline to the shared runner, capture the exact user-facing ls invocation separately, and keep the enriched ls -la output only for filtering and display guards.
randomparity commentedon Aug 24, 2026
Independent reproduction — still present on
master@b34be37and inv0.45.0, on macOS arm64.I hit this while benchmarking RTK inside a coding harness and arrived at the same root cause before finding this issue. Adding fresh numbers since the report is from March.
The unconditional
-lais atsrc/cmds/system/ls.rs:53, and the tracked baseline is the synthesised command atls.rs:87(&format!("-la {}", target_display)):Note the flag filter below it strips only
l,a, andh, so other flags survive and combine with the injected-la. That means the effect is not limited to plainls— it also applies tols -R, where the enrichment is much more expensive:Recorded by RTK for that invocation:
So RTK reports 73.4% saved while returning 29% more than the agent's own command. Two further details worth noting:
original_cmdis recorded asls -la src— the synthesised command, not thels -R srcthat was actually issued — so the row cannot be reconciled against the agent's transcript after the fact.saved_tokensis computed withsaturating_subonusizeand floors to zero. I filed that separately asrtk gaincannot represent a regression: saturating_sub floors negative savings to zero #3702; fixing this issue alone would still not letrtk gainshow the negative cases.Happy to test a patch against my fixture if that's useful.