# agent: Enrich \`grep\` tool output with syntax information \(\#29601\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/fd17f2d8ae0b32a8fd475f9d1b25951963266c5e)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: fd17f2d8ae0b32a8fd475f9d1b25951963266c5e

Requested commit: fd17f2d8ae0b32a8fd475f9d1b25951963266c5e

Commit: fd17f2d8ae0b32a8fd475f9d1b25951963266c5e

Tree: cf4dcaccf5151bbcdd0ed3ca6d0eb18ab0890937

Author: Agus Zubiaga

Committer: GitHub

## Message

`````
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
`````

## Parents

- [55079583270fe7f8344ed0c47cdb96a6fee64a08](https://git.cafe/gitcafe/zed/commit/55079583270fe7f8344ed0c47cdb96a6fee64a08?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/fd17f2d8ae0b32a8fd475f9d1b25951963266c5e?format=markdown)
