Bash tool: large rg/grep outputs have long tokens lossily rewritten in tool results
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported.
- [x] This is a single bug report.
- [x] I am on the latest Claude Desktop app (
1.24012.9, 2026-07-24), which reports itself up to date. Note: it bundles Claude Code 2.1.197; the standalone CLI is at 2.1.220, but the desktop app manages the embedded version on its own release cadence and can't be upgraded to it independently.
What's Wrong?
When the Bash tool runs a search (rg / grep) that produces a large, multi-file, multi-match result, long identifier tokens in the output returned to the model are lossily rewritten/truncated — a long token collapses to a short fragment. Line numbers and file paths survive; the matched content degrades. This makes the model misread code (it "sees" a function named n where the real name is much longer) unless it re-runs a narrower search or uses the Read tool.
What Should Happen?
Large Bash tool output should reach the model verbatim, or be cleanly cut with an explicit [output truncated] marker — never silently rewritten mid-token.
Error Messages/Logs
Illustrative (synthetic) — real long identifiers replaced by fragments:
real: return self.resolve_remote_configuration_payload(client)
returned: return self.n(client)
real: def normalize_incoming_request_metadata_guess_schema(self, cfg):
returned: def ln_guess_schema(self, cfg):
Steps to Reproduce
- In a large monorepo, run a broad search via the Bash tool, e.g.
rg -n "<common_pattern>"matching many files, often piped throughhead/sed. - Observe long identifiers in the returned result collapsed to fragments (
n,ln...). - Note contrast: a minimal single-file
rg PATTERN file, and a plainprintfof the same tokens, both return clean.
Is this a regression?
Unknown (unable to easily test older/newer embedded versions from within the desktop app).
Claude Code Version
2.1.197 (Claude Code) — bundled in Claude Desktop app 1.24012.9 (2026-07-24). Standalone CLI latest at time of filing: 2.1.220.
Platform
Anthropic API
Operating System
macOS (darwin), Apple Silicon.
Terminal/Shell
Running Claude Code inside the Claude Desktop app (not a standalone terminal). Underlying shell as invoked by the Bash tool: zsh 5.9, non-interactive login (so ~/.zshrc is not sourced).
Additional Information
Ruled out from inside a session:
RIPGREP_CONFIG_PATHempty; no rg config.type rg→/opt/homebrew/bin/rg(bare binary, no alias/function). ripgrep 15.1.0.- Non-interactive shell →
~/.zshrcnever sourced. - Passing the pattern via
-f patternfilevs. bareword made no difference. - Plain
printfof the same tokens: clean. Minimal single-filerg PATTERN file: clean.
Corruption only reproduced on large, real-repo searches → suspected layer is lossy rendering/compression of large tool outputs, not rg/shell. Given the embedded version (2.1.197) trails the CLI (2.1.220), worth confirming against latest.