Skip to content

fix(tools): clarify search_code path: vs filename: (#2343)#2365

Open
beejak wants to merge 1 commit into
github:mainfrom
beejak:fix/search-code-path-filename-hint-2343
Open

fix(tools): clarify search_code path: vs filename: (#2343)#2365
beejak wants to merge 1 commit into
github:mainfrom
beejak:fix/search-code-path-filename-hint-2343

Conversation

@beejak
Copy link
Copy Markdown

@beejak beejak commented Apr 22, 2026

Summary

  • Extend the \search_code\ query schema description so \path:\ (directory prefix) vs \ ilename:\ (file name) is explicit.
  • When GitHub returns zero code results and the query uses \path:\ with a file-like token (contains ., no path separators), append a second text content block pointing agents at \ ilename:.

Context

Addresses the confusion described in #2343 (silent empty results when \path:\ is used like a filename filter).

Test plan

  • \go test ./pkg/github -run 'Test_SearchCode|TestPathQualifier' -count=1\
  • \UPDATE_TOOLSNAPS=true go test ./pkg/github -run '^Test_SearchCode$' -count=1\ (schema snap updated)

Fixes #2343

Document path: (directory prefix) vs filename: in the query schema. When GitHub returns zero code results and the query uses path: with a file-like token, append a second text block so agents see why results may be empty.

Made-with: Cursor
@beejak beejak requested a review from a team as a code owner April 22, 2026 13:56
Copy link
Copy Markdown

@jluocsa jluocsa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for tackling #2343 — the description tweak plus a runtime nudge is a nice belt-and-braces approach.

A few observations on pathQualifierLooksLikeFilename that may be worth addressing before merge:

1. False positives on legitimate top-level paths. The heuristic is "no separator + contains a dot", which fires for real paths that happen to be dotted top-level files. For example:

  • path:setup.py
  • path:Makefile.am
  • path:.gitignore
  • path:requirements.txt

These are all valid path: qualifier values that match top-level files in many repos. When they legitimately return zero results (e.g., the file truly doesn't exist in any matched repo), the user gets a misleading hint telling them to switch to filename:. The hint message is only opt-in on zero-result queries, so the user-visible impact is bounded, but it's worth deciding whether the heuristic should also require something file-extension-shaped (e.g. an extension from a small allowlist, or "no leading dot").

2. Quoted multi-word path tokens get split. strings.Fields splits on whitespace, so a query like path:"some name.cs" becomes two tokens: path:"some and name.cs". The first happens to have no separator but no dot either, so it doesn't fire — but path:"foo.bar baz" does: the first token path:"foo.bar has a dot and no separator, triggering the hint on what was actually a valid quoted path. GitHub does support quoted qualifier values; consider stripping surrounding quotes or skipping tokens that begin a quoted span.

3. Polish — include the offending token in the hint. The hint currently always shows the generic WaitUtils.cs example. If you echo the user's actual token (e.g. did you mean filename:%s?), the message becomes directly actionable for agents that route on substrings.

Toolsnap update and unit test coverage both look good. The runtime-only message (i.e. not changing the schema for behavior) keeps the contract clean.

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.

search_code tool: path: qualifier silently returns 0 results when used as a filename filter — no error or warning shown

3 participants