feat: Add a way to limit the number of results from search_files tool #2294
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.
Context
Currently search_files will produce up to 300 results (an arbitrary number). In cortain cases this is too large number because only first few occurrences are wanted. Unfortunately if too generic search pattern is selected, lots of results will be returned to the LLM and this will reduce remaining context significantly and require more time to process than would be otherwise necessary.
Implementation
To address this, an explicit optional max_results parameter has been added to the search_files tool. Its explanation is simple and it does not increase the Roo Code prompt size too much.
If the max_results parameter is not supplied, code works exactly as before.
Screenshots
Not applicable.
How to Test
Unfortunately there are no existing unit or integration tests for this functionality. The change has been tested manually.