Skip to content

rtk git diff/show --max-lines may inflate savings same way as #1045 #1561

Closed as not planned

Description

@ousamabenyounes

Context

Follow-up flagged by @pszymkowiak in PR #1076 review.

#1045 was about rtk read counting user-requested line truncation as RTK token savings. The same pattern likely exists in:

  • src/cmds/git/git.rs:200 — git diff tracking
  • src/cmds/git/git.rs:314 — git show tracking

Both currently track against the compacted output. compact_diff itself is real RTK compression so that part is legitimate — but when a user passes --max-lines N to rtk git diff / rtk git show, the truncated portion gets counted as savings same as the original bug.

Reproduce (likely)

rtk git diff --max-lines 5  # large diff
rtk gain --history          # check if the saved-tokens row for this command is suspiciously high

Suggested fix

Apply the same pattern as #1076:

  1. Extract a pick_tracking_output(pre_truncation: Option<&str>, rtk_output: &str) -> &str helper (already lives in src/cmds/system/read.rs after fix(read): don't count --max-lines truncation as token savings (#1045) #1076 merges — could be promoted to src/core/utils.rs).
  2. Capture the post-compact / pre-truncation content via std::mem::take when --max-lines is active.
  3. Pass the pre-truncation slice to timer.track() instead of the windowed output.

Out of scope here

cc @pszymkowiak — opening as you suggested.

Activity

  1. added
    bug
    effort-small
    filter-quality
    good first issue
    on Apr 27, 2026
  2. pszymkowiak commented on Apr 27, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟢 Priority low
    🎯 Confidence 91%

    Summary

    rtk git diff/show --max-lines incorrectly counts user-requested truncation as RTK token savings; fix in progress via PR #2107

    This looks like a simple fix that could be auto-resolved. Repo maintainers can use /wshm fix to attempt it.

    📁 Relevant files
    • src/cmds/git/git.rs
    • src/cmds/system/read.rs
    • src/core/utils.rs

    Triaged automatically by wshm · This is an automated analysis, not a human review.

  3. maxmilian commented on May 26, 2026

    @maxmilian
    Contributor

    Picking this up.

    Re-read the prior attempt at #1573 — the close reason wasn't a technical rejection, it was procedural: the CLA bot flagged :x: github-actions[bot] as an unsigned committer (likely because the branch had a release-please auto-commit pulled in along with manual Cargo.toml / CHANGELOG.md / release-please-manifest.json edits), and after 9 days with no human review SAY-5 closed citing "triage feedback" — but the only triage was @pszymkowiak's wshm bot summary which actually said low risk + tests present. So the approach was sound, just blocked on plumbing.

    Plan for this attempt:

    • Branch off upstream/develop HEAD, no Cargo.toml / CHANGELOG.md / release-please-manifest.json edits (release-please owns those).
    • Surgical changes in src/cmds/git/git.rs only.
    • Keep the design from @pszymkowiak's suggested fix: factor RTK's compression budget (the 500-line compact_diff default — legitimate savings) away from user-supplied --max-lines truncation (not savings), track against the pre-truncation slice via timer.track(... &content_before_user_truncation, ...).
    • Unit tests pinning both rows: rtk-side compression still counts, user --max-lines does not.
    • Out of scope (per the issue itself): polluted historical data in the local DB.

    Draft PR incoming.

  4. Yohjisakamoto commented on Jul 22, 2026

    @Yohjisakamoto

    This inflated git savings case reinforces why end-to-end agent outcomes matter more than compressed text alone: DeepSWE found Tura cuts coding-agent rounds by 89% and total token cost by 80%; would you evaluate the methodology? https://turaai.net/docs#benchmark-current-test-set-record

  5. KuSh commented on Oct 31, 2026

    @KuSh
    Collaborator

    Closing: rtk git diff and rtk git show have no --max-lines option, so there is no user-requested truncation to count as savings. rtk git diff --max-lines 5 passes the flag to git, which rejects it with unknown option 'max-lines'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clibugeffort-smallfilter-qualitygood first issuepriority:low

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions