Skip to content

fix(grep): wire up 'count' output mode#30

Open
T0mSIlver wants to merge 1 commit into
microsoft:mainfrom
T0mSIlver:fix/grep-count-mode
Open

fix(grep): wire up 'count' output mode#30
T0mSIlver wants to merge 1 commit into
microsoft:mainfrom
T0mSIlver:fix/grep-count-mode

Conversation

@T0mSIlver

Copy link
Copy Markdown

Problem

The Grep schema advertises output_mode enum ["content", "files_with_matches", "count"] and both the schema description and grep.md tell the model that "count" shows match counts. But run_rg only checks elif output_mode == "count_matches" — a value the model can never send. Selecting count matched no branch, so no --count-matches flag was added and ripgrep silently fell back to printing matching lines.

Fix

Match the branch against the advertised enum value "count", and add tests/test_grep_count.py asserting that count mode emits per-file match counts (not content).

Paper reference

Confirmed by the paper's canonical tool schema: output_mode is "One of content, files_with_matches, or count", so "count" is the correct enum value the code must match. — FastContext paper (arXiv:2606.14066), Appendix E "FastContext Explorer: Tool Schemas", p. 19

The schema advertises output_mode enum ['content', 'files_with_matches',
'count'] but run_rg only matched the string 'count_matches', which the
model can never send. Selecting 'count' silently fell through to content
mode instead of emitting --count-matches. Match the advertised enum value
and add a regression test.
@T0mSIlver T0mSIlver closed this Jun 27, 2026
@T0mSIlver T0mSIlver deleted the fix/grep-count-mode branch June 27, 2026 11:31
@T0mSIlver T0mSIlver restored the fix/grep-count-mode branch June 27, 2026 11:56
@T0mSIlver T0mSIlver reopened this Jun 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant