-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat: add query-context smart tool selection #9122
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
- Add ToolSelectionAnalyzer class for intelligent tool filtering - Analyze query complexity (simple/moderate/complex) - Detect tool mentions and group needs - Score tools based on relevance (0-1 scale) - Select 6-12 most relevant tools per query - Add configuration settings for the feature - Include comprehensive unit tests Fixes #9117
Review completed. Found 1 issue that needs to be addressed:
Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues. |
| if (userQuery && settings?.smartToolSelection !== false) { | ||
| const smartSelectionConfig: SmartToolSelectionConfig = { | ||
| enabled: settings?.smartToolSelection?.enabled ?? true, | ||
| minTools: settings?.smartToolSelection?.minTools ?? 6, | ||
| maxTools: settings?.smartToolSelection?.maxTools ?? 12, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Incorrect settings property access causes smart tool selection to always be enabled and ignores user configuration. The condition checks settings?.smartToolSelection !== false, but the settings schema defines individual properties (smartToolSelectionEnabled, smartToolSelectionMinTools, smartToolSelectionMaxTools) not a nested smartToolSelection object. This means: (1) the feature cannot be disabled even when smartToolSelectionEnabled: false, (2) the nested access on lines 151-153 returns undefined instead of configured values, and (3) the feature always uses default values.
| if (userQuery && settings?.smartToolSelection !== false) { | |
| const smartSelectionConfig: SmartToolSelectionConfig = { | |
| enabled: settings?.smartToolSelection?.enabled ?? true, | |
| minTools: settings?.smartToolSelection?.minTools ?? 6, | |
| maxTools: settings?.smartToolSelection?.maxTools ?? 12, | |
| if (userQuery && settings?.smartToolSelectionEnabled !== false) { | |
| const smartSelectionConfig: SmartToolSelectionConfig = { | |
| enabled: settings?.smartToolSelectionEnabled ?? true, | |
| minTools: settings?.smartToolSelectionMinTools ?? 6, | |
| maxTools: settings?.smartToolSelectionMaxTools ?? 12, |
Fix it with Roo Code or mention @roomote and request a fix.
$## Summary
This PR implements query-context smart tool selection to reduce context overhead and improve tool selection accuracy. The feature adds a second layer of filtering on top of mode-based tool groups, selecting only the 6-12 most relevant tools for each specific query.
Fixes #9117
Changes
Core Implementation
src/core/prompts/tools/ToolSelectionAnalyzer.ts):Integration
getToolDescriptionsForModeto use smart selection when enabledConfiguration
provider-settings.ts:smartToolSelectionEnabled(default: true)smartToolSelectionMinTools(default: 6)smartToolSelectionMaxTools(default: 12)Testing
Examples
Simple Query
Complex Query
Tool-Specific Query
Benefits
Testing
Notes
Important
Introduces smart tool selection based on query context to optimize tool usage, with configurable settings and comprehensive testing.
ToolSelectionAnalyzerinToolSelectionAnalyzer.tsfor smart tool selection based on query context.getToolDescriptionsForModeinindex.tsto apply smart selection when enabled.Task.tsfor context-aware tool selection.smartToolSelectionEnabled,smartToolSelectionMinTools, andsmartToolSelectionMaxToolstoprovider-settings.tsandtypes.ts.ToolSelectionAnalyzer.test.tsfor query analysis, tool prioritization, and configuration settings.system.tsto pass user query for prompt generation.This description was created by
for 7e456cb. You can customize this summary. It will automatically update as commits are pushed.