Skip to content

Commit b090a89

Browse files
authored
tools improvements pack (#813)
* tools improvements pack * diff in cloud
1 parent b796e12 commit b090a89

File tree

6 files changed

+25
-17
lines changed

6 files changed

+25
-17
lines changed

refact-agent/engine/src/cloud/messages_req.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,14 @@ pub fn convert_messages_to_thread_messages(
289289
} else if msg.role == "diff" {
290290
let extra_message = match serde_json::from_str::<Vec<DiffChunk>>(&msg.content.content_text_only()) {
291291
Ok(chunks) => {
292-
chunks.iter()
293-
.filter(|x| !x.application_details.is_empty())
294-
.map(|x| x.application_details.clone())
295-
.join("\n")
292+
if chunks.is_empty() {
293+
"Nothing has changed.".to_string()
294+
} else {
295+
chunks.iter()
296+
.filter(|x| !x.application_details.is_empty())
297+
.map(|x| x.application_details.clone())
298+
.join("\n")
299+
}
296300
},
297301
Err(_) => "".to_string()
298302
};

refact-agent/engine/src/scratchpads/passthrough_convert_messages.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,14 @@ pub fn convert_messages_to_openai_format(messages: Vec<ChatMessage>, style: &Opt
5252
} else if msg.role == "diff" {
5353
let extra_message = match serde_json::from_str::<Vec<DiffChunk>>(&msg.content.content_text_only()) {
5454
Ok(chunks) => {
55-
chunks.iter()
56-
.filter(|x| !x.application_details.is_empty())
57-
.map(|x| x.application_details.clone())
58-
.join("\n")
55+
if chunks.is_empty() {
56+
"Nothing has changed.".to_string()
57+
} else {
58+
chunks.iter()
59+
.filter(|x| !x.application_details.is_empty())
60+
.map(|x| x.application_details.clone())
61+
.join("\n")
62+
}
5963
},
6064
Err(_) => "".to_string()
6165
};

refact-agent/engine/src/tools/file_edit/auxiliary.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ pub async fn str_replace(
192192
let occurrences = normalized_content.matches(&normalized_old_str).count();
193193
if occurrences == 0 {
194194
return Err(format!(
195-
"No replacement was performed, `old_str` did not appear verbatim in {:?}. Consider checking the file content using `cat()`",
195+
"No replacement was performed, `old_str` did not appear verbatim in {:?}. Check the file content using `cat()`",
196196
path
197197
));
198198
}
@@ -232,7 +232,7 @@ pub async fn str_replace_regex(
232232
let occurrences = matches.len();
233233
if occurrences == 0 {
234234
return Err(format!(
235-
"No replacement was performed, `pattern` did not appear verbatim in {:?}. Consider checking the file content using `cat()`",
235+
"No replacement was performed, `pattern` did not appear verbatim in {:?}. Check the file content using `cat()`",
236236
path
237237
));
238238
}

refact-agent/engine/src/tools/file_edit/tool_update_textdoc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ async fn parse_args(
7676
}
7777
},
7878
Some(v) => return Err(format!("Error: The 'multiple' argument must be a boolean (true/false) indicating whether to replace all occurrences, but received: {:?}", v)),
79-
None => return Err("Error: The 'multiple' argument is required. Please specify true to replace all occurrences or false to replace only the first occurrence.".to_string())
79+
None => false,
8080
};
8181

8282
Ok(ToolUpdateTextDocArgs {
@@ -210,7 +210,7 @@ impl Tool for ToolUpdateTextDoc {
210210
param_type: "boolean".to_string(),
211211
}
212212
],
213-
parameters_required: vec!["path".to_string(), "old_str".to_string(), "replacement".to_string(), "multiple".to_string()],
213+
parameters_required: vec!["path".to_string(), "old_str".to_string(), "replacement".to_string()],
214214
}
215215
}
216216
}

refact-agent/engine/src/tools/file_edit/tool_update_textdoc_regex.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ async fn parse_args(
8484
}
8585
},
8686
Some(v) => return Err(format!("Error: The 'multiple' argument must be a boolean (true/false) indicating whether to replace all occurrences, but received: {:?}", v)),
87-
None => return Err("Error: The 'multiple' argument is required. Please specify true to replace all occurrences or false to replace only the first occurrence.".to_string())
87+
None => false,
8888
};
8989

9090
Ok(ToolUpdateTextDocRegexArgs {
@@ -218,7 +218,7 @@ impl Tool for ToolUpdateTextDocRegex {
218218
param_type: "boolean".to_string(),
219219
}
220220
],
221-
parameters_required: vec!["path".to_string(), "pattern".to_string(), "replacement".to_string(), "multiple".to_string()],
221+
parameters_required: vec!["path".to_string(), "pattern".to_string(), "replacement".to_string()],
222222
}
223223
}
224224
}

refact-agent/engine/src/tools/tool_regex_search.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ async fn smart_compress_results(
158158
}
159159
if estimated_size > MAX_OUTPUT_SIZE {
160160
info!("Compressing `search_pattern` output: estimated {} bytes (exceeds 4KB limit)", estimated_size);
161-
content.push_str("\nNote: Output has been compressed. Use more specific patterns or scopes for detailed results.");
161+
content.push_str("\nNote: Output has been compressed. Use more specific pattern or scope for detailed results.");
162162
}
163163
content
164164
}
@@ -177,7 +177,7 @@ impl Tool for ToolRegexSearch {
177177
},
178178
agentic: false,
179179
experimental: false,
180-
description: "Search for files and folders whose names or paths match the given regular expression pattern, and also search for text matches inside files using the same patterns. Reports both path matches and text matches in separate sections.".to_string(),
180+
description: "Search for files and folders whose names or paths match the given regular expression pattern, and also search for text matches inside files using the same pattern. Reports both path matches and text matches in separate sections.".to_string(),
181181
parameters: vec![
182182
ToolParam {
183183
name: "pattern".to_string(),
@@ -282,7 +282,7 @@ impl Tool for ToolRegexSearch {
282282
}
283283

284284
if all_search_results.is_empty() {
285-
return Err("All pattern searches produced no results. Try adjusting your patterns or scope.".to_string());
285+
return Err("All pattern searches produced no results. Try adjusting your pattern or scope.".to_string());
286286
}
287287

288288
let mut results = vec_context_file_to_context_tools(all_search_results);

0 commit comments

Comments
 (0)