Skip to content

output capped at N results: elided lines are unrecoverable and the hint has no recovery path #4098

Open

Description

@theSprog

Summary

When output is truncated with [rtk] output capped at N results, the elided lines are not stored in the recall database and the hint contains no recovery path — no total count, no content hash, no command. The output is silently and permanently lost.

This contradicts the behavior promised in the instructions RTK installs for assistant CLIs (RTK.md):

Truncated results state their recovery path in their own output.

Other truncation paths honor this contract. Only this one does not.

Environment

  • rtk 0.49.0
  • Linux 6.6.87 (WSL2), zsh
  • recall mode: sqlite (default, verified via rtk config recall)
  • Invoked through the Claude Code PreToolUse hook (rtk hook claude)

Reproduction

$ seq 1 250 | grep -v zzz
1
2
...
200
[rtk] output capped at 200 results

Then check whether the 50 elided lines were stored:

$ rtk recall --list
HASH           COMMAND                      LINES  HIDDEN      ORIG  EXIT TRUNC
fc2dc90f2751   grep_skipped                   341     341     67.2K     -
edbf76907014   grep_14_ills_linux_kernel…      29      25      6.3K     -

No new entry is created for the capped command. Lines 201-250 are unrecoverable; the only option is re-running the original command.

Actual vs expected

Actual hint:

[rtk] output capped at 200 results

It states neither how much was hidden nor how to get it back.

Expected, matching the quality of the working path:

[rtk] capped: showing 200 of 250 · recover: rtk recall <hash> --full

Contrast: the grep/rg path gets this right

Running rg -n "..." agents -g '*.md' on the same machine produces exactly the right thing:

  +25 more in agents/public-skills/linux-kernel-daily/SKILL.md [+25 hidden: rtk recall edbf76907014]
+19 more files [+341 hidden: rtk recall fc2dc90f2751]

Hidden count, content hash, and a ready-to-paste command — and the entries do land in the recall DB. The output capped at N results path appears to bypass the retriever entirely.

The two paths seem to diverge on output shape: structured file:line:content output goes through the recoverable grep filter, while flat list output piped through grep falls back to this non-recoverable cap.

Why this matters

RTK's primary consumer is an LLM agent, and a hint with no recovery path is worse than a verbose output. In our case the agent ran git ls-tree -r --name-only HEAD | grep -E ... against a repository, silently received only the first 200 of ~850 paths, concluded several top-level directories did not exist, and had to re-run the query after the gap was noticed by chance. The cap itself was correct; the missing recovery path is what turned a compression into a data loss, and cost more tokens than it saved.

The agent-facing instructions explicitly tell the model to trust truncated output because recovery is always available. As long as one path silently violates that, the instruction itself becomes unsafe to follow.

Related issues

This looks like the same failure mode surfacing on yet another code path, rather than an isolated bug:

The common thread is that the recall/retriever mechanism exists and works well where it is wired up, but several filters bypass it and emit a dead-end hint. A shared helper that every capping site must call would prevent the next instance of this.

Suggested fix

  1. Route the output capped at N results path through the same retriever used by the grep/rg filters, so the elided tail is stored and addressable by hash.
  2. Include the original total in the hint (200 of 250), so a reader can judge the loss ratio without re-running anything.
  3. Emit the recovery command inline, as the grep path already does.

If storing the tail is not desirable for this path (e.g. unbounded stdin), even just capped at 200 (total unknown) · re-run with 'rtk proxy <cmd>' for full output would be a strict improvement over the current hint.

Activity

  1. added
    bug
    help wanted
    on Sep 17, 2026
  2. rtk-wshm-sync-bot commented on Sep 17, 2026

    @rtk-wshm-sync-bot

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 87%

    Summary

    The flat-list output capped at N results truncation path bypasses the recall retriever entirely, giving no total count and no recovery command, unlike the working grep/rg path; wire this cap site into the same retriever.

    📁 Relevant files
    • src/filter/cap.rs
    • src/recall/mod.rs
    • src/filter/grep.rs

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

  3. lindicaphxag-tech commented on Sep 19, 2026

    @lindicaphxag-tech
    Contributor

    PR #4107 keeps the existing live cap output, adds a final showing N of M summary, and archives the complete matches through the existing recall hint when recall is enabled. It also leaves RTK_RECALL=0/RTK_TEE=0 behavior unchanged. Could a maintainer assign the issue or confirm this recovery path?

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:clibughelp wantedpriority:medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions