fix(core): return all tools when search_tools limit is 0
SO
2d ago+104+104+012345678901234567890123456789-4-4-0123456789
Fixes an issue where calling search_tools(query, limit=0) returned an empty list [] instead of returning all matching tools without limit.
Problem
The ToolSearchStrategy interface specifies that limit=0 means "no limit / return all tools". However,TagAndDescriptionWordMatchStrategy used direct Python list slicing sorted_tools[:limit]. In Python, [:0] slices to an empty list [], causing queries with limit=0 to return zero results.
Solution
- Updated
TagAndDescriptionWordMatchStrategy.search_toolsto return all tools whenlimit == 0:sorted_tools[:limit] if limit > 0 else sorted_tools - Updated docstrings in
TagAndDescriptionWordMatchStrategyandUtcpClientImplementationto explicitly documentlimit: 0 for no limit. - Added unit tests in
core/tests/implementations/test_tag_search.pyverifyinglimit=0,limit > 0,limit < 0, scoring weights,and tag filtering.
Tests
- 5 new unit tests in
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 the ToolSearchStrategy contract where 0 means no limit.
TagAndDescriptionWordMatchStrategyno longer slices to an empty list whenlimitis0.- Docstrings in
TagAndDescriptionWordMatchStrategyandUtcpClientImplementationnow document0as no limit. - Adds unit tests covering
limit=0, positive limits, negative limits (raises error), scoring, and tag filtering.