Skip to content

fix(core): return all tools when search_tools limit is 0 - #120

Open
Sooriya04 wants to merge 2 commits into
universal-tool-calling-protocol:mainfrom
Sooriya04:fix/tag-search-limit-zero
Open

Sooriya04 wants to merge 2 commits into
universal-tool-calling-protocol:mainfrom
Sooriya04:fix/tag-search-limit-zero

Conversation

@Sooriya04

@Sooriya04 Sooriya04 commented Oct 31, 2026 •

Copy link
Copy Markdown

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_tools to return all tools when limit == 0: sorted_tools[:limit] if limit > 0 else sorted_tools
  • Updated docstrings in TagAndDescriptionWordMatchStrategy and UtcpClientImplementation to explicitly document limit: 0 for no limit.
  • Added unit tests in core/tests/implementations/test_tag_search.py verifying limit=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.

  • TagAndDescriptionWordMatchStrategy no longer slices to an empty list when limit is 0.
  • Docstrings in TagAndDescriptionWordMatchStrategy and UtcpClientImplementation now document 0 as no limit.
  • Adds unit tests covering limit=0, positive limits, negative limits (raises error), scoring, and tag filtering.

Written for commit 389f3ce. Summary will update on new commits.

View guided diff

- 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.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

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.

1 participant