Model tends to misuse Grep tool #1975

Closed
opened 2026-02-16 17:33:31 -05:00 by yindo · 12 comments
Owner

Originally created by @agladysh on GitHub (Oct 6, 2025).

Originally assigned to: @thdxr on GitHub.

Grep *.ts (path=packages/minimal-cli/src/main.ts, pattern=lint)

No files found

The path argument seems to be for directories only, or something (the file is there, and contains the pattern).

Update:

Strangely enough, not specifying the path argument often fails as well:

Grep packages/minimal-cli/src/main.ts (pattern=reviewHowto)

No files found

Grep packages/minimal-cli/src/main.ts (pattern=review-howto)

No files found

Grep reviewHowto

Found 10 matches
/Users/<redacted>/packages/minimal-cli/src/main.ts:
  Line 715:   reviewHowto?: string;
  Line 761:       result.reviewHowto = args[++i];
  Line 864:   reviewHowto: { title: string; value: string },
  Line 878:   contexts.push(`<context># ${reviewHowto.title}\n\n${reviewHowto.value}</context>`);
  Line 891:   reviewHowto: { title: string; value: string },
  Line 898:   const contexts = buildContexts(guideline, howto, reviewHowto, projectRoot, allFiles, readFile);
  Line 1062:     const reviewHowtoPath = cliArgs.reviewHowto || 'review/howto-review-common.yaml';
  Line 1063:     const reviewHowto = loadHowtoYaml(reviewHowtoPath);
Originally created by @agladysh on GitHub (Oct 6, 2025). Originally assigned to: @thdxr on GitHub. ``` Grep *.ts (path=packages/minimal-cli/src/main.ts, pattern=lint) No files found ``` The `path` argument seems to be for directories only, or something (the file is there, and contains the pattern). Update: Strangely enough, not specifying the path argument often fails as well: ``` Grep packages/minimal-cli/src/main.ts (pattern=reviewHowto) No files found Grep packages/minimal-cli/src/main.ts (pattern=review-howto) No files found Grep reviewHowto Found 10 matches /Users/<redacted>/packages/minimal-cli/src/main.ts: Line 715: reviewHowto?: string; Line 761: result.reviewHowto = args[++i]; Line 864: reviewHowto: { title: string; value: string }, Line 878: contexts.push(`<context># ${reviewHowto.title}\n\n${reviewHowto.value}</context>`); Line 891: reviewHowto: { title: string; value: string }, Line 898: const contexts = buildContexts(guideline, howto, reviewHowto, projectRoot, allFiles, readFile); Line 1062: const reviewHowtoPath = cliArgs.reviewHowto || 'review/howto-review-common.yaml'; Line 1063: const reviewHowto = loadHowtoYaml(reviewHowtoPath); ```
yindo closed this issue 2026-02-16 17:33:31 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Oct 6, 2025):

This issue might be a duplicate of existing issues. Please check:

  • #2375: Glob/grep Tool Max Lines (Limit output of all tools?) - discusses safety issues and potential problems with grep/glob tool functionality

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Oct 6, 2025): This issue might be a duplicate of existing issues. Please check: - #2375: Glob/grep Tool Max Lines (Limit output of all tools?) - discusses safety issues and potential problems with grep/glob tool functionality Feel free to ignore if none of these address your specific case.
Author
Owner

@rekram1-node commented on GitHub (Oct 6, 2025):

hm will look into it

@rekram1-node commented on GitHub (Oct 6, 2025): hm will look into it
Author
Owner

@rekram1-node commented on GitHub (Oct 6, 2025):

@agladysh path is for directories only:

    path: z.string().optional().describe("The directory to search in. Defaults to the current working directory."),
@rekram1-node commented on GitHub (Oct 6, 2025): @agladysh `path` is for directories only: ``` path: z.string().optional().describe("The directory to search in. Defaults to the current working directory."), ```
Author
Owner

@rekram1-node commented on GitHub (Oct 7, 2025):

I think there is a simple fix here tho I have something working

@rekram1-node commented on GitHub (Oct 7, 2025): I think there is a simple fix here tho I have something working
Author
Owner

@rekram1-node commented on GitHub (Oct 7, 2025):

should be fixed in next release

@rekram1-node commented on GitHub (Oct 7, 2025): should be fixed in next release
Author
Owner

@agladysh commented on GitHub (Oct 8, 2025):

Seems much better, thank you!

@agladysh commented on GitHub (Oct 8, 2025): Seems much better, thank you!
Author
Owner

@lockie commented on GitHub (Jan 11, 2026):

Error: Found multiple matches for oldString. Provide more surrounding lines in oldString to identify the correct match

Noticing this all the time

@lockie commented on GitHub (Jan 11, 2026): > Error: Found multiple matches for oldString. Provide more surrounding lines in oldString to identify the correct match Noticing this all the time
Author
Owner

@DavMelchi commented on GitHub (Jan 16, 2026):

Same for me all time

Image
@DavMelchi commented on GitHub (Jan 16, 2026): Same for me all time <img width="682" height="271" alt="Image" src="https://github.com/user-attachments/assets/31dc4068-0732-4425-a78e-69187c9be40a" />
Author
Owner

@eparreno commented on GitHub (Jan 26, 2026):

Same here. Is quite annoying :(

@eparreno commented on GitHub (Jan 26, 2026): Same here. Is quite annoying :(
Author
Owner

@turningpointusa300-crypto commented on GitHub (Jan 31, 2026):

did you fix this Found multiple matches for oldString. Provide more surrounding lines in oldString to identify the correct match.
Found multiple matches for oldString. Provide more surrounding lines in oldString to identify the correct match.

@turningpointusa300-crypto commented on GitHub (Jan 31, 2026): did you fix this Found multiple matches for oldString. Provide more surrounding lines in oldString to identify the correct match. Found multiple matches for oldString. Provide more surrounding lines in oldString to identify the correct match.
Author
Owner

@rekram1-node commented on GitHub (Jan 31, 2026):

I think you all are referring to edit tool instead? Probably best mentioned in a fresh issue w/ the model and provider you are using.

Some models are much better than others

@rekram1-node commented on GitHub (Jan 31, 2026): I think you all are referring to edit tool instead? Probably best mentioned in a fresh issue w/ the model and provider you are using. Some models are much better than others
Author
Owner

@turningpointusa300-crypto commented on GitHub (Feb 1, 2026):

yes that why i am tell you so yall can fix it or do i need to run gethub

@turningpointusa300-crypto commented on GitHub (Feb 1, 2026): yes that why i am tell you so yall can fix it or do i need to run gethub
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#1975