From 1d9bcbd2021607b8e46fc84b3db22dfc56dda9ef Mon Sep 17 00:00:00 2001 From: LE Quoc Dat Date: Mon, 28 Jul 2025 18:46:41 +0200 Subject: [PATCH] AI: we need instruct the agent to Always use edit_tool. it doesn't do this for now. Like it prefer str_replace --- backend/agent/gemini_prompt.py | 4 ++-- backend/agent/prompt.py | 8 ++------ backend/agent/tools/agent_builder_tools/workflow_tool.py | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/backend/agent/gemini_prompt.py b/backend/agent/gemini_prompt.py index bf171c8b..678f2204 100644 --- a/backend/agent/gemini_prompt.py +++ b/backend/agent/gemini_prompt.py @@ -212,7 +212,7 @@ You have the ability to execute operations using both Python and CLI tools: ## 3.5 FILE EDITING STRATEGY - **PREFERRED FILE EDITING TOOL: `edit_file`** - - **Always prefer the `edit_file` tool for all file modifications.** It is a powerful and intelligent tool that can handle everything from simple text replacements to complex code refactoring. + - **Always use the `edit_file` tool for all file modifications.** It is a powerful and intelligent tool that can handle everything from simple text replacements to complex code refactoring. - **How to use `edit_file`:** 1. Provide a clear, natural language `instructions` parameter describing the change (e.g., "I am adding error handling to the login function"). 2. Provide the `code_edit` parameter showing the exact changes, using `// ... existing code ...` to represent unchanged parts of the file. This keeps your request concise and focused. @@ -220,7 +220,7 @@ You have the ability to execute operations using both Python and CLI tools: - **Adding a feature:** Your `code_edit` would show the new code block surrounded by `// ... existing code ...`. - **Correcting a typo:** Your `code_edit` would show the line with the typo, and then the corrected line, surrounded by `// ... existing code ...`. - **Rewriting a section:** Your `code_edit` would contain the entire new section, surrounded by `// ... existing code ...`. -- The `edit_file` tool is your primary tool for changing files. While other file writing tools exist, you should default to using `edit_file` for its flexibility and intelligence. +- The `edit_file` tool is your primary tool for changing files. You MUST use `edit_file` for ALL modifications to existing files. It is more powerful and reliable than simple string replacement. # 4. DATA PROCESSING & EXTRACTION diff --git a/backend/agent/prompt.py b/backend/agent/prompt.py index eb190a4b..cbf0c55a 100644 --- a/backend/agent/prompt.py +++ b/backend/agent/prompt.py @@ -237,15 +237,11 @@ You have the abilixwty to execute operations using both Python and CLI tools: ## 3.5 FILE EDITING STRATEGY - **PREFERRED FILE EDITING TOOL: `edit_file`** - - **Always prefer the `edit_file` tool for all file modifications.** It is a powerful and intelligent tool that can handle everything from simple text replacements to complex code refactoring. + - **Always use the `edit_file` tool for all file modifications.** It is a powerful and intelligent tool that can handle everything from simple text replacements to complex code refactoring. - **How to use `edit_file`:** 1. Provide a clear, natural language `instructions` parameter describing the change (e.g., "I am adding error handling to the login function"). 2. Provide the `code_edit` parameter showing the exact changes, using `// ... existing code ...` to represent unchanged parts of the file. This keeps your request concise and focused. - - **Examples:** - - **Adding a feature:** Your `code_edit` would show the new code block surrounded by `// ... existing code ...`. - - **Correcting a typo:** Your `code_edit` would show the line with the typo, and then the corrected line, surrounded by `// ... existing code ...`. - - **Rewriting a section:** Your `code_edit` would contain the entire new section, surrounded by `// ... existing code ...`. -- The `edit_file` tool is your primary tool for changing files. While other file writing tools exist, you should default to using `edit_file` for its flexibility and intelligence. +- The `edit_file` tool is your primary tool for changing files. You MUST use `edit_file` for ALL modifications to existing files. It is more powerful and reliable than simple string replacement. # 4. DATA PROCESSING & EXTRACTION diff --git a/backend/agent/tools/agent_builder_tools/workflow_tool.py b/backend/agent/tools/agent_builder_tools/workflow_tool.py index e728d621..7fe62154 100644 --- a/backend/agent/tools/agent_builder_tools/workflow_tool.py +++ b/backend/agent/tools/agent_builder_tools/workflow_tool.py @@ -40,7 +40,7 @@ class WorkflowTool(AgentBuilderBaseTool): tool_mapping = { 'sb_shell_tool': ['execute_command'], - 'sb_files_tool': ['create_file', 'str_replace', 'full_file_rewrite', 'delete_file', 'edit_file'], + 'sb_files_tool': ['create_file', 'edit_file', 'str_replace', 'full_file_rewrite', 'delete_file'], 'sb_browser_tool': ['browser_navigate_to', 'browser_take_screenshot'], 'sb_vision_tool': ['see_image'], 'sb_deploy_tool': ['deploy'],