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
This commit is contained in:
parent
0e477e7db9
commit
99df1190a9
5 changed files with 209 additions and 46 deletions
|
@ -27,13 +27,14 @@ If appropriate, use tool calls to explore the current project, which contains th
|
|||
- `{{root_name}}`
|
||||
{{/each}}
|
||||
|
||||
- Bias towards not asking the user for help if you can find the answer yourself.
|
||||
- When providing paths to tools, the path should always begin with a path that starts with a project root directory listed above.
|
||||
- Before you read or edit a file, you must first find the full path. DO NOT ever guess a file path!
|
||||
{{# if (has_tool 'grep') }}
|
||||
- When looking for symbols in the project, prefer the `grep` tool.
|
||||
- As you learn about the structure of the project, use that information to scope `grep` searches to targeted subtrees of the project.
|
||||
- Bias towards not asking the user for help if you can find the answer yourself.
|
||||
{{! TODO: Only mention tools if they are enabled }}
|
||||
- The user might specify a partial file path. If you don't know the full path, use `find_path` (not `grep`) before you read the file.
|
||||
- Before you read or edit a file, you must first find the full path. DO NOT ever guess a file path!
|
||||
{{/if}}
|
||||
|
||||
## Fixing Diagnostics
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue