Skip to content

fix(grep): honor head_limit values above 100#31

Open
T0mSIlver wants to merge 1 commit into
microsoft:mainfrom
T0mSIlver:fix/grep-head-limit
Open

fix(grep): honor head_limit values above 100#31
T0mSIlver wants to merge 1 commit into
microsoft:mainfrom
T0mSIlver:fix/grep-head-limit

Conversation

@T0mSIlver

Copy link
Copy Markdown

Problem

The schema says head_limit limits output to the first N entries. The clamp was:

limit = 100
if head_limit is not None:
    if head_limit < limit and head_limit > 0:
        limit = head_limit

Because of the head_limit < limit guard, any value >= 100 was silently ignored and the cap stayed at 100 — the model could never raise the limit. (The test even passes head_limit: 200 and gets 100.) The schema also claimed unspecified means "shows all results from ripgrep", which was never true.

Fix

  • Honor any positive head_limit, including values above 100.
  • Keep a 100-line safety cap when head_limit is omitted, and update the schema description to state that accurately.
  • Add test_grep_head_limit (hermetic, 250-line file) asserting head_limit=150 is honored and an omitted value falls back to 100. This test fails against the old clamp.

Paper reference

The paper defines head_limit as "Limit output to the first N lines or entries" (FastContext paper (arXiv:2606.14066), Appendix E "FastContext Explorer: Tool Schemas", p. 19), confirming N must be honored. The paper specifies no hard cap and no "shows all results" behavior — the 100-line default applied when head_limit is omitted is an implementation choice (judgment call), not from the paper.

The head_limit clamp read 'if head_limit < limit and head_limit > 0',
so any value >= 100 was discarded and the cap stayed at 100 — the model
could never raise the limit despite the schema saying it shows all
results. Honor any positive head_limit, document that output is capped
at the first 100 lines when head_limit is omitted, and add a regression
test.
@T0mSIlver T0mSIlver closed this Jun 27, 2026
@T0mSIlver T0mSIlver deleted the fix/grep-head-limit branch June 27, 2026 11:31
@T0mSIlver T0mSIlver restored the fix/grep-head-limit 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