Skip to content

feat: rename search_and_replace tool to edit with new parameter structure#11296

Open
hannesrudolph wants to merge 5 commits intomainfrom
feat/rename-search-and-replace-to-edit
Open

feat: rename search_and_replace tool to edit with new parameter structure#11296
hannesrudolph wants to merge 5 commits intomainfrom
feat/rename-search-and-replace-to-edit

Conversation

@hannesrudolph
Copy link
Collaborator

@hannesrudolph hannesrudolph commented Feb 7, 2026

Summary

Renames the search_and_replace tool to edit with a new flat parameter structure (file_path, old_string, new_string, replace_all), replacing the old batch operations array. Keeps search_and_replace as a backward-compatible alias so models like MiniMax that reference it in includedTools continue to work without changes.

Changes

  • New edit tool definition (src/core/prompts/tools/native-tools/edit.ts) with file_path, old_string, new_string, replace_all parameters
  • New EditTool execution handler (src/core/tools/EditTool.ts) with replace_all support and uniqueness checking
  • Alias system: Added search_and_replace: "edit" to TOOL_ALIASES — models with includedTools: ["search_and_replace"] (e.g., MiniMax) get the edit tool renamed as search_and_replace
  • Parser updates: NativeToolCallParser.ts handles both "edit" and "search_and_replace" tool names with the new parameter structure
  • Execution routing: presentAssistantMessage.ts routes both tool names to EditTool
  • Alias resolution in validation: isToolAllowedForMode now resolves aliases when checking customTools, ensuring search_and_replace in includedTools correctly maps to edit
  • Backward compat wrapper: SearchAndReplaceTool.ts reduced to a 2-line re-export from EditTool
  • Types: Added "edit" to toolNames, "replace_all" to toolParamNames, updated NativeToolArgs
  • Tests: 16 new EditTool tests covering basic replacement, replace_all, uniqueness errors, no-match errors, approval flow

Test Results

  • 7 targeted test files: 105/105 passing
  • Full src/ suite: 341 passed (29 pre-existing failures from missing @ai-sdk/amazon-bedrock — unrelated)
  • packages/types: 170/170 passing

Important

Renames search_and_replace tool to edit with new parameters, adds EditTool class, and maintains backward compatibility with aliasing.

  • Behavior:
    • Renames search_and_replace tool to edit with parameters file_path, old_string, new_string, replace_all.
    • Keeps search_and_replace as alias for backward compatibility.
  • Implementation:
    • Adds EditTool class in EditTool.ts with support for replace_all and uniqueness checking.
    • Updates NativeToolCallParser.ts to handle both tool names with new parameters.
    • Modifies presentAssistantMessage.ts to route both tool names to EditTool.
    • Updates validateToolUse.ts to resolve tool aliases.
  • Testing:
    • Adds 16 new tests for EditTool covering various scenarios.
    • Verifies alias re-export in searchAndReplaceTool.spec.ts.
  • Misc:
    • Updates tool.ts to include edit in toolNames and toolParamNames.
    • Adjusts HistoryPreview.spec.tsx for test consistency.

This description was created by Ellipsis for 52ad6f3. You can customize this summary. It will automatically update as commits are pushed.

@dosubot dosubot bot added size:XXL This PR changes 1000+ lines, ignoring generated files. Enhancement New feature or request labels Feb 7, 2026
@roomote
Copy link
Contributor

roomote bot commented Feb 7, 2026

Rooviewer Clock   See task

All previously flagged issues have been resolved. No new issues found in the latest commits (orphaned file deletion, XML false-positive fix, test stabilization for CI).

  • Delete orphaned src/core/prompts/tools/native-tools/search_and_replace.ts (old parameter schema, no longer imported)
  • containsXmlToolMarkup false-positive risk: "edit" in the tool-name list matches <editor>, <editable>, etc. after lowercasing -- fixed with hasTagReference boundary checking
Previous reviews

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph force-pushed the feat/rename-search-and-replace-to-edit branch from 01335c6 to 0a1377c Compare February 8, 2026 00:32
…ture

- Add new 'edit' tool with file_path, old_string, new_string, replace_all params
- Keep search_and_replace as backward-compatible alias via TOOL_ALIASES
- Create EditTool execution handler with replace_all and uniqueness checking
- Update NativeToolCallParser for both edit and search_and_replace names
- Update presentAssistantMessage routing for both tool names
- Add alias resolution to isToolAllowedForMode for customTools validation
- Reduce SearchAndReplaceTool.ts to re-export wrapper from EditTool
- Add 16 new EditTool tests, update searchAndReplaceTool tests
- MiniMax includedTools: ['search_and_replace'] continues to work via alias
@hannesrudolph hannesrudolph force-pushed the feat/rename-search-and-replace-to-edit branch from 52ad6f3 to 285a161 Compare February 8, 2026 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant