# agent: Include grep-related instructions in the prompt only if the tool is available \(\#29536\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 99df1190a9e72b32e840de991dbbbe1c59d1f5d4

Requested commit: 99df1190a9e72b32e840de991dbbbe1c59d1f5d4

Commit: 99df1190a9e72b32e840de991dbbbe1c59d1f5d4

Tree: db0efbb30e2ae313a4404f86f1e82d6983488640

Author: Oleksiy Syvokon

Committer: GitHub

## Message

```
agent: Include grep-related instructions in the prompt only if the tool is available (#29536)

This change updates the system prompt to conditionally include
`grep`-related instructions based on whether the `grep` tool is enabled.

Implementation details:
1. Add a `has_tool` handlebars helper.
2. Pass the `model` to all locations where the prompt is built.
3. Use `{{#if has_tool "grep"}}` in the system prompt to gate
`grep`-specific instructions.

Testing:
- Unit tests for the `hasTool` helper.
- Unit tests to verify that `grep`-related instructions are included /
omitted from the prompt as appropriate.
- Manual agent evaluation:
- Setup: Asked the Agent "List all impls of MyTrait in the project"
using a custom "No tools" profile (all tools disabled).
- Before the change: The Agent attempted to call `grep`, encountered an
error, then realized the tool was unavailable.
- After the change: The Agent immediately asked to enable a search tool.

Note: in principle, `grep`/`read_file` tool descriptions alone might be
enough, but to confirm this we need more evaluation. If it turns out to
be true, we'll be able to remove grep-specific instructions from the
system prompt and undo this change.

Release Notes:

- N/A
```

## Parents

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

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