Repository navigation
Conversation
- In TagAndDescriptionWordMatchStrategy, slicing sorted_tools[:limit] with limit=0 returned an empty list instead of all matching tools as specified by ToolSearchStrategy. - Update slice to return all tools when limit == 0: sorted_tools[:limit] if limit > 0 else sorted_tools. - Update search_tools docstrings in TagAndDescriptionWordMatchStrategy and UtcpClientImplementation to document limit=0 as no limit. - Add comprehensive unit test suite in core/tests/implementations/test_tag_search.py verifying limit=0, positive limits, negative limits, and tag filtering.
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 3 files
Reply with feedback, questions, or to request a fix.
View guided diff | Re-trigger cubic
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.
Fixes an issue where calling
search_tools(query, limit=0)returned an empty list[]instead of returning all matching tools without limit.Problem
The
ToolSearchStrategyinterface specifies thatlimit=0means "no limit / return all tools". However,TagAndDescriptionWordMatchStrategyused direct Python list slicingsorted_tools[:limit]. In Python,[:0]slices to an empty list[], causing queries withlimit=0to return zero results.Solution
TagAndDescriptionWordMatchStrategy.search_toolsto return all tools whenlimit == 0:sorted_tools[:limit] if limit > 0 else sorted_toolsTagAndDescriptionWordMatchStrategyandUtcpClientImplementationto explicitly documentlimit: 0 for no limit.core/tests/implementations/test_tag_search.pyverifyinglimit=0,limit > 0,limit < 0, scoring weights,and tag filtering.Tests
core/tests/implementations/test_tag_search.py(all passing).Summary by cubic
Fixes
search_tools(query, limit=0)so it returns all matching tools instead of an empty list, matching theToolSearchStrategycontract where0means no limit.TagAndDescriptionWordMatchStrategyno longer slices to an empty list whenlimitis0.TagAndDescriptionWordMatchStrategyandUtcpClientImplementationnow document0as no limit.limit=0, positive limits, negative limits (raises error), scoring, and tag filtering.Written for commit 389f3ce. Summary will update on new commits.