Skip to content

Commit 3ee6072

Browse files
roomote[bot]roomote-agenthannesrudolph
authored
fix: Clearify codebase_search path parameter optional and clarify tool descriptions (#6877)
* fix: make search_files path parameter optional and clarify tool descriptions - Made path parameter optional in search_files tool (defaults to workspace root) - Updated search_files description with clearer examples - Improved codebase_search description to clarify when to use path parameter - Updated test snapshots to reflect the changes This addresses confusion where LLMs were unnecessarily specifying paths when searching from project root * revert: remove search_files changes, keep only codebase_search improvements - Reverted all changes to src/core/prompts/tools/search-files.ts - Reverted all changes to src/core/tools/searchFilesTool.ts - Updated test snapshots to reflect the reverted search_files tool - Kept the codebase_search tool description improvements as intended * Update codebase-search.ts Simplify codebase_search tool documentation - Condensed description to eliminate repetitive explanations about user wording - Reduced from 2 examples to 1 comprehensive example showing optional path usage - Streamlined parameter descriptions to remove redundancy - Maintained all critical requirements (English queries, semantic search, path optionality) - Reduced documentation size by ~40% while preserving clarity * fix: add workspace directory context to codebase_search path parameter - Added ToolArgs import and parameter to getCodebaseSearchDescription function - Updated path parameter description to include '(relative to the current workspace directory ${args.cwd})' - Updated index.ts to pass args to getCodebaseSearchDescription - Maintains consistency with other tool descriptions like list_files and search_files --------- Co-authored-by: Roo Code <[email protected]> Co-authored-by: Hannes Rudolph <[email protected]>
1 parent cda67a8 commit 3ee6072

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,23 @@
1-
export function getCodebaseSearchDescription(): string {
1+
import { ToolArgs } from "./types"
2+
3+
export function getCodebaseSearchDescription(args: ToolArgs): string {
24
return `## codebase_search
3-
Description: Find files most relevant to the search query.\nThis is a semantic search tool, so the query should ask for something semantically matching what is needed.\nIf it makes sense to only search in a particular directory, please specify it in the path parameter.\nUnless there is a clear reason to use your own search query, please just reuse the user's exact query with their wording.\nTheir exact wording/phrasing can often be helpful for the semantic search query. Keeping the same exact question format can also be helpful.\nIMPORTANT: Queries MUST be in English. Translate non-English queries before searching.
5+
Description: Find files most relevant to the search query using semantic search. Searches based on meaning rather than exact text matches. By default searches entire workspace. Reuse the user's exact wording unless there's a clear reason not to - their phrasing often helps semantic search. Queries MUST be in English (translate if needed).
6+
47
Parameters:
5-
- query: (required) The search query to find relevant code. You should reuse the user's exact query/most recent message with their wording unless there is a clear reason not to.
6-
- path: (optional) The path to the directory to search in relative to the current working directory. This parameter should only be a directory path, file paths are not supported. Defaults to the current working directory.
8+
- query: (required) The search query. Reuse the user's exact wording/question format unless there's a clear reason not to.
9+
- path: (optional) Limit search to specific subdirectory (relative to the current workspace directory ${args.cwd}). Leave empty for entire workspace.
10+
711
Usage:
812
<codebase_search>
913
<query>Your natural language query here</query>
10-
<path>Path to the directory to search in (optional)</path>
14+
<path>Optional subdirectory path</path>
1115
</codebase_search>
1216
13-
Example: Searching for functions related to user authentication
17+
Example:
1418
<codebase_search>
1519
<query>User login and password hashing</query>
16-
<path>/path/to/directory</path>
20+
<path>src/auth</path>
1721
</codebase_search>
1822
`
1923
}

src/core/prompts/tools/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ const toolDescriptionMap: Record<string, (args: ToolArgs) => string | undefined>
3939
attempt_completion: (args) => getAttemptCompletionDescription(args),
4040
use_mcp_tool: (args) => getUseMcpToolDescription(args),
4141
access_mcp_resource: (args) => getAccessMcpResourceDescription(args),
42-
codebase_search: () => getCodebaseSearchDescription(),
42+
codebase_search: (args) => getCodebaseSearchDescription(args),
4343
switch_mode: () => getSwitchModeDescription(),
4444
new_task: (args) => getNewTaskDescription(args),
4545
insert_content: (args) => getInsertContentDescription(args),

0 commit comments

Comments
 (0)