Skip to content
This repository was archived by the owner on May 15, 2026. It is now read-only.

Commit a08bd76

Browse files
refactor: remove legacy XML tool calling code (getToolDescription) (#10929)
- Remove getToolDescription() method from MultiSearchReplaceDiffStrategy - Remove getToolDescription() from DiffStrategy interface - Remove unused ToolDescription type from shared/tools.ts - Remove unused eslint-disable directive - Update test mocks to remove getToolDescription references - Remove getToolDescription tests from multi-search-replace.spec.ts Native tools are now defined in src/core/prompts/tools/native-tools/ using the OpenAI function format. The removed code was dead since XML-style tool calling was replaced with native tool calling.
1 parent 339f5aa commit a08bd76

7 files changed

Lines changed: 9 additions & 135 deletions

File tree

src/core/diff/strategies/__tests__/multi-search-replace.spec.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,29 +1041,6 @@ function sum(a, b) {
10411041
})
10421042
})
10431043

1044-
describe("getToolDescription", () => {
1045-
let strategy: MultiSearchReplaceDiffStrategy
1046-
1047-
beforeEach(() => {
1048-
strategy = new MultiSearchReplaceDiffStrategy()
1049-
})
1050-
1051-
it("should include the current workspace directory", async () => {
1052-
const cwd = "/test/dir"
1053-
const description = await strategy.getToolDescription({ cwd })
1054-
expect(description).toContain(`relative to the current workspace directory ${cwd}`)
1055-
})
1056-
1057-
it("should include required format elements", async () => {
1058-
const description = await strategy.getToolDescription({ cwd: "/test" })
1059-
expect(description).toContain("<<<<<<< SEARCH")
1060-
expect(description).toContain("=======")
1061-
expect(description).toContain(">>>>>>> REPLACE")
1062-
expect(description).toContain("<apply_diff>")
1063-
expect(description).toContain("</apply_diff>")
1064-
})
1065-
})
1066-
10671044
describe("line marker validation in REPLACE sections", () => {
10681045
let strategy: MultiSearchReplaceDiffStrategy
10691046

src/core/diff/strategies/multi-search-replace.ts

Lines changed: 9 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/* eslint-disable no-irregular-whitespace */
2-
31
import { distance } from "fastest-levenshtein"
42

53
import { ToolProgressStatus } from "@roo-code/types"
@@ -90,94 +88,6 @@ export class MultiSearchReplaceDiffStrategy implements DiffStrategy {
9088
this.bufferLines = bufferLines ?? BUFFER_LINES
9189
}
9290

93-
getToolDescription(args: { cwd: string; toolOptions?: { [key: string]: string } }): string {
94-
return `## apply_diff
95-
Description: Request to apply PRECISE, TARGETED modifications to an existing file by searching for specific sections of content and replacing them. This tool is for SURGICAL EDITS ONLY - specific changes to existing code.
96-
You can perform multiple distinct search and replace operations within a single \`apply_diff\` call by providing multiple SEARCH/REPLACE blocks in the \`diff\` parameter. This is the preferred way to make several targeted changes efficiently.
97-
The SEARCH section must exactly match existing content including whitespace and indentation.
98-
If you're not confident in the exact content to search for, use the read_file tool first to get the exact content.
99-
When applying the diffs, be extra careful to remember to change any closing brackets or other syntax that may be affected by the diff farther down in the file.
100-
ALWAYS make as many changes in a single 'apply_diff' request as possible using multiple SEARCH/REPLACE blocks
101-
102-
Parameters:
103-
- path: (required) The path of the file to modify (relative to the current workspace directory ${args.cwd})
104-
- diff: (required) The search/replace block defining the changes.
105-
106-
Diff format:
107-
\`\`\`
108-
<<<<<<< SEARCH
109-
:start_line: (required) The line number of original content where the search block starts.
110-
-------
111-
[exact content to find including whitespace]
112-
=======
113-
[new content to replace with]
114-
>>>>>>> REPLACE
115-
116-
\`\`\`
117-
118-
Example:
119-
120-
Original file:
121-
\`\`\`
122-
1 | def calculate_total(items):
123-
2 | total = 0
124-
3 | for item in items:
125-
4 | total += item
126-
5 | return total
127-
\`\`\`
128-
129-
Search/Replace content:
130-
\`\`\`
131-
<<<<<<< SEARCH
132-
:start_line:1
133-
-------
134-
def calculate_total(items):
135-
total = 0
136-
for item in items:
137-
total += item
138-
return total
139-
=======
140-
def calculate_total(items):
141-
"""Calculate total with 10% markup"""
142-
return sum(item * 1.1 for item in items)
143-
>>>>>>> REPLACE
144-
145-
\`\`\`
146-
147-
Search/Replace content with multiple edits:
148-
\`\`\`
149-
<<<<<<< SEARCH
150-
:start_line:1
151-
-------
152-
def calculate_total(items):
153-
sum = 0
154-
=======
155-
def calculate_sum(items):
156-
sum = 0
157-
>>>>>>> REPLACE
158-
159-
<<<<<<< SEARCH
160-
:start_line:4
161-
-------
162-
total += item
163-
return total
164-
=======
165-
sum += item
166-
return sum
167-
>>>>>>> REPLACE
168-
\`\`\`
169-
170-
Usage:
171-
<apply_diff>
172-
<path>File path here</path>
173-
<diff>
174-
Your search/replace content here
175-
You can use multi search/replace block in one diff block, but make sure to include the line numbers for each block.
176-
Only use a single line of '=======' between search and replacement content, because multiple '=======' will corrupt the file.
177-
</diff>
178-
</apply_diff>`
179-
}
180-
18191
private unescapeMarkers(content: string): string {
18292
return content
18393
.replace(/^\\<<<<<<</gm, "<<<<<<<")
@@ -350,31 +260,31 @@ Only use a single line of '=======' between search and replacement content, beca
350260
Regex parts:
351261
352262
1. (?:^|\n)
353-
  Ensures the first marker starts at the beginning of the file or right after a newline.
263+
Ensures the first marker starts at the beginning of the file or right after a newline.
354264
355265
2. (?<!\\)<<<<<<< SEARCH\s*\n
356-
  Matches the line <<<<<<< SEARCH (ignoring any trailing spaces) – the negative lookbehind makes sure it isnt escaped.
266+
Matches the line "<<<<<<< SEARCH" (ignoring any trailing spaces) – the negative lookbehind makes sure it isn't escaped.
357267
358268
3. ((?:\:start_line:\s*(\d+)\s*\n))?
359-
  Optionally matches a :start_line: line. The outer capturing group is group1 and the inner (\d+) is group2.
269+
Optionally matches a ":start_line:" line. The outer capturing group is group 1 and the inner (\d+) is group 2.
360270
361271
4. ((?:\:end_line:\s*(\d+)\s*\n))?
362-
  Optionally matches a :end_line: line. Group3 is the whole match and group4 is the digits.
272+
Optionally matches a ":end_line:" line. Group 3 is the whole match and group 4 is the digits.
363273
364274
5. ((?<!\\)-------\s*\n)?
365-
  Optionally matches the ------- marker line (group5).
275+
Optionally matches the "-------" marker line (group 5).
366276
367277
6. ([\s\S]*?)(?:\n)?
368-
  Non‐greedy match for the search content (group6) up to the next marker.
278+
Non‐greedy match for the "search content" (group 6) up to the next marker.
369279
370280
7. (?:(?<=\n)(?<!\\)=======\s*\n)
371-
  Matches the ======= marker on its own line.
281+
Matches the "=======" marker on its own line.
372282
373283
8. ([\s\S]*?)(?:\n)?
374-
  Non‐greedy match for the replace content (group7).
284+
Non‐greedy match for the "replace content" (group 7).
375285
376286
9. (?:(?<=\n)(?<!\\)>>>>>>> REPLACE)(?=\n|$)
377-
  Matches the final >>>>>>> REPLACE marker on its own line (and requires a following newline or the end of file).
287+
Matches the final ">>>>>>> REPLACE" marker on its own line (and requires a following newline or the end of file).
378288
*/
379289

380290
let matches = [

src/core/webview/__tests__/ClineProvider.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,6 @@ vi.mock("../../../api/providers/fetchers/modelCache", () => ({
315315

316316
vi.mock("../diff/strategies/multi-search-replace", () => ({
317317
MultiSearchReplaceDiffStrategy: vi.fn().mockImplementation(() => ({
318-
getToolDescription: () => "test",
319318
getName: () => "test-strategy",
320319
applyDiff: vi.fn(),
321320
})),

src/core/webview/__tests__/ClineProvider.sticky-mode.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ vi.mock("../../../integrations/workspace/WorkspaceTracker", () => ({
9898

9999
vi.mock("../../diff/strategies/multi-search-replace", () => ({
100100
MultiSearchReplaceDiffStrategy: vi.fn().mockImplementation(() => ({
101-
getToolDescription: () => "test",
102101
getName: () => "test-strategy",
103102
applyDiff: vi.fn(),
104103
})),

src/core/webview/__tests__/ClineProvider.sticky-profile.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ vi.mock("../../../integrations/workspace/WorkspaceTracker", () => ({
100100

101101
vi.mock("../../diff/strategies/multi-search-replace", () => ({
102102
MultiSearchReplaceDiffStrategy: vi.fn().mockImplementation(() => ({
103-
getToolDescription: () => "test",
104103
getName: () => "test-strategy",
105104
applyDiff: vi.fn(),
106105
})),

src/core/webview/__tests__/ClineProvider.taskHistory.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,6 @@ vi.mock("../../../shared/modes", () => ({
211211

212212
vi.mock("../diff/strategies/multi-search-replace", () => ({
213213
MultiSearchReplaceDiffStrategy: vi.fn().mockImplementation(() => ({
214-
getToolDescription: () => "test",
215214
getName: () => "test-strategy",
216215
applyDiff: vi.fn(),
217216
})),

src/shared/tools.ts

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ export type PushToolResult = (content: ToolResponse) => void
2525

2626
export type AskFinishSubTaskApproval = () => Promise<boolean>
2727

28-
export type ToolDescription = () => string
29-
3028
export interface TextContent {
3129
type: "text"
3230
content: string
@@ -342,13 +340,6 @@ export interface DiffStrategy {
342340
*/
343341
getName(): string
344342

345-
/**
346-
* Get the tool description for this diff strategy
347-
* @param args The tool arguments including cwd and toolOptions
348-
* @returns The complete tool description including format requirements and examples
349-
*/
350-
getToolDescription(args: { cwd: string; toolOptions?: { [key: string]: string } }): string
351-
352343
/**
353344
* Apply a diff to the original content
354345
* @param originalContent The original file content

0 commit comments

Comments
 (0)