refactor: rename search tool for clarity and consistency

- Updated the tool name from "search" to "search_files" across multiple files to better reflect its functionality.
- Adjusted related documentation and descriptions to ensure clarity in usage and expected behavior.
- Enhanced the toolset definitions and mappings to incorporate the new naming convention, improving overall consistency in the codebase.
This commit is contained in:
teknium1 2026-02-20 02:43:57 -08:00
parent ba8b80a163
commit f9eb5edb96
6 changed files with 31 additions and 29 deletions

View file

@ -332,7 +332,7 @@ class ToolContext:
Dict with search results
"""
result = handle_function_call(
"search", {"query": query, "path": path}, task_id=self.task_id
"search_files", {"pattern": query, "path": path}, task_id=self.task_id
)
try:
return json.loads(result)

View file

@ -177,7 +177,7 @@ TOOLSET_REQUIREMENTS = {
"env_vars": [], # Uses terminal backend, no additional requirements
"check_fn": check_file_requirements,
"setup_url": None,
"tools": ["read_file", "write_file", "patch", "search"],
"tools": ["read_file", "write_file", "patch", "search_files"],
},
"tts": {
"name": "Text-to-Speech",
@ -880,13 +880,15 @@ def get_file_tool_definitions() -> List[Dict[str, Any]]:
{
"type": "function",
"function": {
"name": "search",
"name": "search_files",
"description": (
"Search for content inside files or find files by name. Preferred over 'grep' or 'find' "
"in the terminal because it uses ripgrep (fast) with automatic fallback to grep, handles "
"pagination, and returns structured results sorted by modification time (newest first).\n\n"
"**Content search (target='content'):** Regex-powered search inside files with optional "
"file type filtering and context lines. Three output modes: full matches with line numbers, "
"The primary tool for searching code and files. Always use this instead of "
"running grep, rg, find, fd, or ack in the terminal — it's faster (ripgrep-backed), "
"returns structured results with line numbers, and handles pagination automatically.\n\n"
"Use for: finding function/class definitions, searching for error strings, locating "
"config files, finding all files of a type, checking where a variable is used.\n\n"
"**Content search (target='content'):** Regex search inside files with optional "
"file type filtering and context lines. Output modes: full matches with line numbers, "
"file paths only, or match counts per file.\n\n"
"**File search (target='files'):** Find files by glob pattern (e.g., '*.py', '*config*'). "
"Results sorted by modification time so recently changed files appear first."
@ -1167,7 +1169,7 @@ def get_all_tool_names() -> List[str]:
# File manipulation tools (use terminal backend)
if check_file_requirements():
tool_names.extend([
"read_file", "write_file", "patch", "search"
"read_file", "write_file", "patch", "search_files"
])
# Text-to-speech tools
@ -1247,7 +1249,7 @@ TOOL_TO_TOOLSET_MAP = {
"read_file": "file_tools",
"write_file": "file_tools",
"patch": "file_tools",
"search": "file_tools",
"search_files": "file_tools",
# Cross-channel messaging
"send_message": "messaging_tools",
# Planning & task management
@ -1438,7 +1440,7 @@ def get_tool_definitions(
"rl_stop_training", "rl_get_results",
"rl_list_runs", "rl_test_inference"
],
"file_tools": ["read_file", "write_file", "patch", "search"],
"file_tools": ["read_file", "write_file", "patch", "search_files"],
"tts_tools": ["text_to_speech"]
}
legacy_tools = legacy_map.get(toolset_name, [])
@ -1492,7 +1494,7 @@ def get_tool_definitions(
"rl_stop_training", "rl_get_results",
"rl_list_runs", "rl_test_inference"
],
"file_tools": ["read_file", "write_file", "patch", "search"],
"file_tools": ["read_file", "write_file", "patch", "search_files"],
"tts_tools": ["text_to_speech"]
}
legacy_tools = legacy_map.get(toolset_name, [])
@ -2013,7 +2015,7 @@ def handle_file_function_call(
task_id=tid
)
elif function_name == "search":
elif function_name == "search_files":
return search_tool(
pattern=function_args.get("pattern", ""),
target=function_args.get("target", "content"),
@ -2274,7 +2276,7 @@ def handle_function_call(
return handle_rl_function_call(function_name, function_args)
# Route file manipulation tools
elif function_name in ["read_file", "write_file", "patch", "search"]:
elif function_name in ["read_file", "write_file", "patch", "search_files"]:
return handle_file_function_call(function_name, function_args, task_id)
# Route code execution sandbox (programmatic tool calling)
@ -2381,7 +2383,7 @@ def get_available_toolsets() -> Dict[str, Dict[str, Any]]:
},
"file_tools": {
"available": check_file_requirements(),
"tools": ["read_file", "write_file", "patch", "search"],
"tools": ["read_file", "write_file", "patch", "search_files"],
"description": "File manipulation tools: read/write files, search content/files, patch with fuzzy matching",
"requirements": ["Terminal backend available (local/docker/ssh/singularity/modal)"]
},

View file

@ -839,7 +839,7 @@ def _build_tool_preview(tool_name: str, args: dict, max_len: int = 40) -> str:
"read_file": "path",
"write_file": "path",
"patch": "path",
"search": "pattern",
"search_files": "pattern",
"browser_navigate": "url",
"browser_click": "ref",
"browser_type": "text",
@ -1463,7 +1463,7 @@ class AIAgent:
if tool_name == "patch":
return f"┊ 🔧 patch {_path(args.get('path', ''))} {dur}"
if tool_name == "search":
if tool_name == "search_files":
pattern = _trunc(args.get("pattern", ""), 35)
target = args.get("target", "content")
verb = "find" if target == "files" else "grep"
@ -2965,7 +2965,7 @@ class AIAgent:
tool_emoji_map = {
'web_search': '🔍', 'web_extract': '📄', 'web_crawl': '🕸️',
'terminal': '💻', 'process': '⚙️',
'read_file': '📖', 'write_file': '✍️', 'patch': '🔧', 'search': '🔎',
'read_file': '📖', 'write_file': '✍️', 'patch': '🔧', 'search_files': '🔎',
'browser_navigate': '🌐', 'browser_snapshot': '📸',
'browser_click': '👆', 'browser_type': '⌨️',
'browser_scroll': '📜', 'browser_back': '◀️',

View file

@ -40,7 +40,7 @@ SANDBOX_ALLOWED_TOOLS = frozenset([
"web_extract",
"read_file",
"write_file",
"search",
"search_files",
"patch",
"terminal",
])
@ -88,8 +88,8 @@ _TOOL_STUBS = {
'"""Write content to a file (always overwrites). Returns dict with status."""',
'{"path": path, "content": content}',
),
"search": (
"search",
"search_files": (
"search_files",
'pattern: str, target: str = "content", path: str = ".", file_glob: str = None, limit: int = 50',
'"""Search file contents (target="content") or find files (target="files"). Returns dict with "matches"."""',
'{"pattern": pattern, "target": target, "path": path, "file_glob": file_glob, "limit": limit}',
@ -553,7 +553,7 @@ EXECUTE_CODE_SCHEMA = {
" Lines are 1-indexed. Returns {\"content\": \"...\", \"total_lines\": N}\n"
" write_file(path: str, content: str) -> dict\n"
" Always overwrites the entire file.\n"
" search(pattern: str, target=\"content\", path=\".\", file_glob=None, limit=50) -> dict\n"
" search_files(pattern: str, target=\"content\", path=\".\", file_glob=None, limit=50) -> dict\n"
" target: \"content\" (grep) or \"files\" (find). Returns {\"matches\": [...]}\n"
" patch(path: str, old_string: str, new_string: str, replace_all: bool = False) -> dict\n"
" Replaces old_string with new_string in the file.\n"

View file

@ -176,7 +176,7 @@ FILE_TOOLS = [
{"name": "read_file", "function": read_file_tool},
{"name": "write_file", "function": write_file_tool},
{"name": "patch", "function": patch_tool},
{"name": "search", "function": search_tool}
{"name": "search_files", "function": search_tool}
]

View file

@ -104,7 +104,7 @@ TOOLSETS = {
"file": {
"description": "File manipulation tools: read, write, patch (with fuzzy matching), and search (content + files)",
"tools": ["read_file", "write_file", "patch", "search"],
"tools": ["read_file", "write_file", "patch", "search_files"],
"includes": []
},
@ -171,7 +171,7 @@ TOOLSETS = {
# Terminal + process management
"terminal", "process",
# File manipulation
"read_file", "write_file", "patch", "search",
"read_file", "write_file", "patch", "search_files",
# Vision
"vision_analyze",
# Image generation
@ -213,7 +213,7 @@ TOOLSETS = {
# Terminal + process management
"terminal", "process",
# File manipulation
"read_file", "write_file", "patch", "search",
"read_file", "write_file", "patch", "search_files",
# Web tools
"web_search", "web_extract",
# Vision - analyze images sent by users
@ -251,7 +251,7 @@ TOOLSETS = {
# Terminal + process management
"terminal", "process",
# File manipulation
"read_file", "write_file", "patch", "search",
"read_file", "write_file", "patch", "search_files",
# Web tools
"web_search", "web_extract",
# Vision - analyze images sent by users
@ -291,7 +291,7 @@ TOOLSETS = {
# Terminal + process management
"terminal", "process",
# File manipulation
"read_file", "write_file", "patch", "search",
"read_file", "write_file", "patch", "search_files",
# Vision
"vision_analyze",
# Image generation
@ -327,7 +327,7 @@ TOOLSETS = {
# Terminal + process management
"terminal", "process",
# File manipulation
"read_file", "write_file", "patch", "search",
"read_file", "write_file", "patch", "search_files",
# Web tools
"web_search", "web_extract",
# Vision - analyze images sent by users