From f9eb5edb965369618ae02e88180754b6790664c3 Mon Sep 17 00:00:00 2001 From: teknium1 Date: Fri, 20 Feb 2026 02:43:57 -0800 Subject: [PATCH] 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. --- environments/tool_context.py | 2 +- model_tools.py | 30 ++++++++++++++++-------------- run_agent.py | 6 +++--- tools/code_execution_tool.py | 8 ++++---- tools/file_tools.py | 2 +- toolsets.py | 12 ++++++------ 6 files changed, 31 insertions(+), 29 deletions(-) diff --git a/environments/tool_context.py b/environments/tool_context.py index a9c783c8f..52be54239 100644 --- a/environments/tool_context.py +++ b/environments/tool_context.py @@ -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) diff --git a/model_tools.py b/model_tools.py index 591c303dc..caef4a224 100644 --- a/model_tools.py +++ b/model_tools.py @@ -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)"] }, diff --git a/run_agent.py b/run_agent.py index 3823187b1..0f01f9e5e 100644 --- a/run_agent.py +++ b/run_agent.py @@ -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': '◀️', diff --git a/tools/code_execution_tool.py b/tools/code_execution_tool.py index 0bbecd345..d9acc6441 100644 --- a/tools/code_execution_tool.py +++ b/tools/code_execution_tool.py @@ -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" diff --git a/tools/file_tools.py b/tools/file_tools.py index 4ee7a592c..9fc24e55d 100644 --- a/tools/file_tools.py +++ b/tools/file_tools.py @@ -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} ] diff --git a/toolsets.py b/toolsets.py index f5c689e28..838f3a8c3 100644 --- a/toolsets.py +++ b/toolsets.py @@ -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