fix: allow enumerating deferred tools - #40243
Open
masamorishita wants to merge 1 commit into
Open
Conversation
teknium1
reviewed
Jul 14, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for addressing deferred-tool catalog enumeration. The underlying gap is still present on current main: tools/tool_search.py:612-614 rejects an empty query, and the bridge schema at tools/tool_search.py:459-469 has no pagination field.
Problems
tools/tool_search.py:650-652cannot signal another keyword-search page.search_catalog(..., limit=limit + offset)returns at most that many rows, so a full page makesoffset + len(page) == len(hits)and setsnext_offsettonulleven if more catalog entries match.website/docs/user-guide/features/tool-search.md:29-35still documentstool_search(query, limit?); it needs the wildcard,offset, andnext_offsetcontract.
Suggested changes
- Retrieve a sentinel result beyond the requested page (or rank all matches), then test a multi-page keyword query through completion.
- Update the Tool Search feature documentation alongside the schema change.
Automated hermes-sweeper review.
|
|
||
| hits = search_catalog(catalog, query, limit=limit + offset) | ||
| page = hits[offset:offset + limit] | ||
| next_offset = offset + len(page) if (offset + len(page)) < len(hits) else None |
Contributor
There was a problem hiding this comment.
hits is capped at limit + offset on the preceding line, so a full keyword-search page makes this condition false and returns next_offset: null even when later matches exist. Fetch a sentinel result (or rank all matches) before deriving the continuation.
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.
Summary
query='*'offsetpagination andnext_offsetso catalogs larger than the per-call limit can be walked completelyTests
uv run --with pytest --with pytest-timeout python -m pytest tests/tools/test_tool_search.py -q