aminghadersohi opened a new pull request, #45149:
URL: https://github.com/apache/superset/pull/45149

   ### SUMMARY
   `search_tools` ranks tools with BM25 over each tool's name, description and 
parameter text. The tool name is a handful of words inside a document that can 
be hundreds of words long, so a tool with a long definition can land at the 
edge of the result limit, or past it, even when the query spells out every word 
of its name. For example, with the default `max_results` of 5, `get dataset 
info execute sql` returns `query_dataset`, `execute_sql`, `get_chart_sql` and 
other tools that mention datasets or SQL in their descriptions, with 
`get_dataset_info` last or missing depending on the exact catalog. Searching 
for the exact name `get_dataset_info` already works (#44682).
   
   This change adds a second name-based promotion step for the BM25 strategy. 
After BM25 ranking, multi-word tool names whose words all appear in the query 
are moved ahead of the remaining matches, longest names first and upstream rank 
as the tiebreaker. Exact-name promotion keeps priority.
   
   Design notes:
   - Top-k is unchanged: the result never exceeds `max_results`, and no 
multi-intent query is guaranteed to return every tool it mentions.
   - Only caller-visible tools (after permission filtering and excluding pinned 
`always_visible` tools) are considered, so promotion cannot surface tools the 
caller cannot see.
   - The regex strategy is unchanged because its queries are patterns, not 
natural language.
   - No size or byte limits are changed.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   N/A
   
   ### TESTING INSTRUCTIONS
   ```
   pytest tests/unit_tests/mcp_service/test_tool_search_transform.py
   ```
   New tests run `search_tools` ranking against the registered tool catalog for 
`get dataset info execute sql` and several multi-intent and single-intent 
queries, and check that partial name matches do not promote tools, that longer 
names come first, that the result limit holds when more tools qualify, and that 
regex search is unaffected. The existing exact-name, permission, and 
pinned-tool tests still pass.
   
   ### ADDITIONAL INFORMATION
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in 
[SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to