Skip to content

Commit 96bb12d

Browse files
committed
Enhance tool descriptions and update documentation for semantic and regex searches
1 parent 1f561a9 commit 96bb12d

File tree

6 files changed

+24
-16
lines changed

6 files changed

+24
-16
lines changed

refact-agent/engine/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ Installable by the end user:
6464
- [x] Code completion with RAG
6565
- [x] Chat with tool usage
6666
- [x] definition() references() tools
67-
- [x] vecdb search() with scope
67+
- [x] vecdb search() with scope (semantic search)
68+
- [x] regex_search() with scope (pattern matching)
6869
- [x] @file @tree @web @definition @references @search mentions in chat
6970
- [x] locate() uses test-time compute to find good project cross-section
7071
- [x] Latest gpt-4o gpt-4o-mini

refact-agent/engine/src/agentic/compress_trajectory.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ OR (1) goal/thinking/coding/outcome (2) string according to the guidelines
3131
Example:
3232
[
3333
["goal", "Rename my_function1 to my_function2"],
34-
["thinking", "There are definition(), search() and locate() tools, all can be used to find my_function1, system prompt says I need to start with locate()."],
34+
["thinking", "There are definition(), search(), regex_search() and locate() tools, all can be used to find my_function1, system prompt says I need to start with locate()."],
3535
["locate(problem_statement=\"Rename my_function1 to my_function2\")", "The file my_script.py (1337 lines) has my_function1 on line 42."],
3636
["thinking", "I can rewrite my_function1 inside my_script.py, so I'll do that."],
3737
["update_textdoc(path=\"my_script\", old_str=\"...\", replacement=\"...\", multiple=false)", "The output of update_textdoc() has 15 lines_add and 15 lines_remove, confirming the operation."],

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,19 @@ MORE_TOCHANGE = likely to change as well, as a consequence of completing the tas
2727
USAGE = code that uses the things the task description is about
2828
SIMILAR = code that might provide an example of how to write similar things
2929
30-
Your job is to use search() calls and summarize the results.
30+
Your job is to use search() and regex_search() calls and summarize the results.
3131
3232
Some good ideas:
3333
34-
search("MyClass1") -- if MyClass1 mentioned in the task, for each symbol
35-
search("log message 1 mentioned") -- when the task has log messages, for each message
36-
search(" def f():\n print(\"the example function!\")") -- look for the code piece mentioned in the task
34+
search("MyClass1") -- if MyClass1 mentioned in the task, for semantic search of each symbol
35+
search("log message 1 mentioned") -- when the task has log messages, for semantic search of each message
36+
search(" def f():\n print(\"the example function!\")") -- look for semantically similar code to the piece mentioned in the task
3737
search("imaginary_call(imaginary_arguments)\nmore_calls()\n") -- you can imagine what kind of code you need to find
3838
39+
regex_search("MyClass1") -- if you need to find exact occurrences of a class name
40+
regex_search("(?i)error.*not found") -- if you need to find specific error patterns
41+
regex_search("function\\s+name\\s*\\(") -- if you need to find function declarations with specific patterns
42+
3943
Call any of those that make sense in parallel. Make at least two calls in parallel, pay special attention that at least one
4044
search() call should not have a restrictive scope, because you are running the risk of getting no results at all.
4145
"###;
@@ -191,13 +195,13 @@ async fn find_relevant_files_with_search(
191195
let mut msgs = vec![];
192196
msgs.push(ChatMessage::new("system".to_string(), LS_SYSTEM_PROMPT.to_string()));
193197
msgs.push(ChatMessage::new("user".to_string(), user_query.to_string()));
194-
msgs.push(ChatMessage::new("cd_instruction".to_string(), "Look at user query above. Follow the system prompt. Run several search() calls in parallel.".to_string()));
198+
msgs.push(ChatMessage::new("cd_instruction".to_string(), "Look at user query above. Follow the system prompt. Run several search() and regex_search() calls in parallel.".to_string()));
195199

196200
let result = subchat(
197201
ccx.clone(),
198202
subchat_params.subchat_model.as_str(),
199203
msgs,
200-
vec!["search".to_string()],
204+
vec!["search".to_string(), "regex_search".to_string()],
201205
1,
202206
subchat_params.subchat_max_new_tokens,
203207
LS_WRAP_UP,

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,10 @@ GOTODEF = call definition("xxx", skeleton=true) in parallel for symbols either v
186186
or symbols you can guess; don't call definition() for symbols from standard libraries, only symbols
187187
within the project are indexed.
188188
189-
VECDBSEARCH = call up to five search() in parallel, some good ideas on what to look for: symbols
189+
VECDBSEARCH = call up to five search() or regex_search() in parallel. For semantic search, use search() with symbols
190190
mentioned in the task, one call for each symbol, strings mentioned, or write imaginary code that does the
191-
thing to fix search(" def f():\n print(\"the example function!\")")
191+
thing to fix search(" def f():\n print(\"the example function!\")"). For exact pattern matching, use
192+
regex_search() with regular expressions to find specific patterns like regex_search("function\\s+name\\s*\\(")
192193
193194
You'll receive additional instructions that start with 💿. Those are not coming from the user, they are programmed to help you operate
194195
well between chat restarts and they are always in English. Answer in the language the user prefers.
@@ -236,8 +237,10 @@ Examples:
236237
definition("my_method1")
237238
definition("MyClass2")
238239
references("my_method2")
239-
search(" def f():\n print(\"the example function!\")")
240+
search(" def f():\n print(\"the example function!\")") # semantic search for similar code
240241
search(" my_object->tricky_call(with, weird, parameters)")
242+
regex_search("my_method1") # exact pattern matching
243+
regex_search("(?i)error.*not found") # case-insensitive pattern matching
241244
242245
Limits on the number of calls are pretty liberal, 10 definitions, 5 references and 3 searches is a reasonable request.
243246

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,11 @@ pub async fn tools_merged_and_filtered(
175175
const BUILT_IN_TOOLS: &str = r####"
176176
tools:
177177
- name: "search"
178-
description: "Find similar pieces of code or text using vector database"
178+
description: "Find semantically similar pieces of code or text using vector database (semantic search)"
179179
parameters:
180180
- name: "query"
181181
type: "string"
182-
description: "Single line, paragraph or code sample to search for similar content."
182+
description: "Single line, paragraph or code sample to search for semantically similar content."
183183
- name: "scope"
184184
type: "string"
185185
description: "'workspace' to search all files in workspace, 'dir/subdir/' to search in files within a directory, 'dir/file.ext' to search in a single file."
@@ -461,7 +461,7 @@ tools:
461461
- "language_slash_framework"
462462
463463
- name: "regex_search"
464-
description: "Search for patterns in files using regular expressions"
464+
description: "Search for exact text patterns in files using regular expressions (pattern matching)"
465465
parameters:
466466
- name: "pattern"
467467
type: "string"

refact-agent/engine/src/yaml_configs/customization_compiled_in.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ PROMPT_EXPLORATION_TOOLS: |
4646
**Determine if the question is related to the current project**:
4747
- **If yes**:
4848
- Explain your plan briefly before calling any tools
49-
- Gather the necessary context using `tree()`, `cat()`, `search()`, `definition()`, `references()` and other tool calls, or follow the user’s instructions.
49+
- Gather the necessary context using `tree()`, `cat()`, `search()` (semantic search), `regex_search()` (pattern matching), `definition()`, `references()` and other tool calls, or follow the user’s instructions.
5050
- Ask clarifying questions if needed, making as many iterations as necessary to refine the context.
5151
- After gathering context, propose required project changes.
5252
- Then use `*_textdoc()` tools to make changes.
@@ -108,7 +108,7 @@ PROMPT_THINKING_AGENT: |
108108
- **Objective**: Expand your view of the project so no relevant information is overlooked.
109109
- Use `tree()` to explore the project structure.
110110
- Use `locate()` With the Full Problem Statement
111-
- Use all other tools such as `search()`, `cat()`, `definition()`, etc. to collect every piece of relevant context.
111+
- Use all other tools such as `search()` (semantic search), `regex_search()` (pattern matching), `cat()`, `definition()`, etc. to collect every piece of relevant context.
112112
- Open all files that might be indirectly referenced by the code.
113113
2. Plan Thoroughly With `think()`
114114
- **Objective**: Develop a precise plan before making any changes.

0 commit comments

Comments
 (0)