agent: Enrich grep
tool output with syntax information (#29601)
The `grep` tool used to include 4 lines of context around the match, but the lines included would often be unhelpful. This PR improves this behavior by using the range of the parent syntax node that contains the full line(s) matched. The match headers will also now include symbol breadcrumbs so that the model can already gather code structure before/without reading files. ````md ### impl GitRepository for RealGitRepository › fn compare_checkpoints › L1278-1284 ```rust let result = git .run(&[ "diff-tree", "--quiet", &left.commit_sha.to_string(), &right.commit_sha.to_string(), ]) ``` ```` This positively impacts the `add_arg_to_trait_method` eval example with better diff output, fewer tool failures, and reduced total turns. Note: We have some plans to use a an "elision" approach where we would combine all matches for a given file, skipping lines between them while keeping symbol declaration lines. The theory is that this would be map more closely to the expected input for edits. For now, this PR is a significant improvement. Release Notes: - Agent: Enrich `grep` tool output with syntax information
This commit is contained in:
parent
5507958327
commit
fd17f2d8ae
3 changed files with 411 additions and 86 deletions
|
@ -387,6 +387,7 @@ impl Response {
|
|||
cx.assert_some(result, format!("called `{}`", tool_name))
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub fn tool_uses(&self) -> impl Iterator<Item = &ToolUse> {
|
||||
self.messages.iter().flat_map(|msg| &msg.tool_use)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue