[#82] fix(discover): use substring matching for plain keyword filters#83
Merged
Merged
Conversation
Previously keyword filtering used fnmatch glob matching exclusively, requiring wildcards (e.g. *user*) for fuzzy matching. Plain keywords like "user" would only match exact field values, making the filter unintuitive for agents. Now plain keywords without glob characters (*, ?, [) use case-insensitive substring matching, while keywords with glob characters retain fnmatch behavior for backward compatibility. Also adds debug logging when a resource is filtered out by keyword. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jerryshao
approved these changes
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
Improve the keyword matching algorithm in the discover handler to use substring matching for plain keywords (without glob characters), while retaining fnmatch glob matching for patterns with wildcards.
Changes:
_has_glob_chars()helper to detect glob special characters (*,?,[)_ci_glob_match()to use substring matching when no glob chars are presentlogger.debug()in_matches_keyword()when a resource is filtered outWhy are the changes needed?
The current glob-only matching with
fnmatchrequires explicit wildcards (e.g.,*user*) for fuzzy matching. Plain keywords likeuseronly match if the entire field value equals "user", which is unintuitive for AI agents. Agents typically pass plain keywords without wildcards, causing the discover keyword filter to return empty results unexpectedly.Closes #82
Does this PR introduce any user-facing change?
Yes. Plain keyword searches in
adp.discovernow perform substring matching instead of exact glob matching. For example,keyword="user"will now match resources with IDs likeuser_profilesor descriptions containing "user". Keywords with glob wildcards (*,?,[) continue to use fnmatch as before.How was this patch tested?
TestDiscoverHandlerKeywordFilter