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
search_file_contents wastes tokens on multi-line result formatting #766
Found 12 matches:
source/foo.ts:42
const x = 1
source/bar.ts:11
const y = 2
The extra newline, the 2-space indent, and the blank line between matches are all formatting the model does not need.
Fix
Standard grep format, one line per match:
source/foo.ts:42:const x = 1
source/bar.ts:11:const y = 2
Shorter, equally parseable, and it matches what models have seen most in training. Saves roughly 3-4 tokens per match, so about 100 tokens on a default 30-result search (DEFAULT_SEARCH_RESULTS, source/constants.ts:48).
Small on its own, but it is free and completely lossless.
Note contextLines is supported (source/tools/search-file-contents.tsx:75), so whatever format is chosen needs to still read clearly when context lines are present. Standard grep uses - as the separator for context lines rather than :, which would work here too.
Notes for a first-time contributor
Single function, one loop. Tests in source/tools/search-file-contents.spec.tsx will need their expected output updated. Run with pnpm run test:ava source/tools/search-file-contents.spec.tsx.
Activity
will-lamerton commentedon Aug 3, 2026
Part of #772.
fix: format search_file_contents results grep-style, one line per match
fix: drop blank separator between context-free search matches