Repository navigation
Description
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 viartk config recall)- Invoked through the Claude Code
PreToolUsehook (rtk hook claude)
Reproduction
$ seq 1 250 | grep -v zzz
1
2
...
200
[rtk] output capped at 200 resultsThen 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:
- Feature request: lossless-only mode + honest account of silent failures truncation causes in agent contexts #1313 — lossless-only mode and the silent-failure account for agent contexts. This report is a concrete instance of the problem described there.
- rtk grep -r silently truncates matched lines and caps per-file results, contradicting --help's "prints the whole matching line" behavior #2988 —
rtk grep -rsilently truncates and caps per-file results. Different path (per-file cap on structured output); this one is the global 200-line cap applied to flat output piped intogrep. - bug(tsc): informational output (--showConfig, --listFiles, --init, --help) is replaced by "TypeScript: No errors found" and is unrecoverable #3750 — tsc informational output is replaced and unrecoverable.
- gcloud: generic TOML filter truncates silently and saves almost nothing on the common commands #3963 — gcloud generic TOML filter truncates silently.
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
- Route the
output capped at N resultspath through the same retriever used by the grep/rg filters, so the elided tail is stored and addressable by hash. - Include the original total in the hint (
200 of 250), so a reader can judge the loss ratio without re-running anything. - 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
rtk-wshm-sync-bot commentedon Sep 17, 2026
🔍 Automated Triage
bugmediumSummary
The flat-list
output capped at N resultstruncation 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.rssrc/recall/mod.rssrc/filter/grep.rsTriaged automatically by wshm · This is an automated analysis, not a human review.
lindicaphxag-tech commentedon Sep 19, 2026
PR #4107 keeps the existing live cap output, adds a final
showing N of Msummary, and archives the complete matches through the existing recall hint when recall is enabled. It also leavesRTK_RECALL=0/RTK_TEE=0behavior unchanged. Could a maintainer assign the issue or confirm this recovery path?