From d858e855cb2600daf5a8f7107d95bc8548e3237a Mon Sep 17 00:00:00 2001 From: Christian Gunderman Date: Wed, 28 Jan 2026 10:55:08 -0800 Subject: [PATCH] Further prompt improvements. --- packages/core/src/prompts/snippets.ts | 6 ++++-- packages/core/src/tools/edit.ts | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/core/src/prompts/snippets.ts b/packages/core/src/prompts/snippets.ts index 0f790a6b20..49074f6907 100644 --- a/packages/core/src/prompts/snippets.ts +++ b/packages/core/src/prompts/snippets.ts @@ -368,13 +368,15 @@ function mandateContinueWork(interactive: boolean): string { function workflowStepUnderstand(options: PrimaryWorkflowsOptions): string { if (options.enableCodebaseInvestigator) { - return `1. **Understand & Strategize:** Think about the user's request and the relevant codebase context. When the task involves **complex refactoring, codebase exploration or system-wide analysis**, your **first and primary action** must be to delegate to the 'codebase_investigator' agent using the 'codebase_investigator' tool. Use it to build a comprehensive understanding of the code, its structure, and dependencies. For **simple, targeted searches** (like finding a specific function name, file path, or variable declaration), you should use '${GREP_TOOL_NAME}' or '${GLOB_TOOL_NAME}' directly.`; + return `1. **Understand & Strategize:** Think about the user's request and the relevant codebase context. When the task involves **complex refactoring, codebase exploration or system-wide analysis**, your **first and primary action** must be to delegate to the 'codebase_investigator' agent using the 'codebase_investigator' tool. Use it to build a comprehensive understanding of the code, its structure, and dependencies. For **simple, targeted searches** (like finding a specific function name, file path, or variable declaration), you should use '${GREP_TOOL_NAME}' or '${GLOB_TOOL_NAME}' directly. +Use '${READ_FILE_TOOL_NAME}' to understand context and validate any assumptions you may have. +IMPORTANT: extra context consumed by unnecessarily reading entire files will degrade the quality of your answer, so **ALWAYS** use ranged reads if you know approximately which lines you need. For example, when fixing a linter error at line 50, read ~20 lines around it (offset: 40, limit: 20) to get sufficient context for a replacement.`; } return `1. **Understand:** Think about the user's request and the relevant codebase context. Use '${GREP_TOOL_NAME}' and '${GLOB_TOOL_NAME}' search tools extensively (in parallel if independent) to understand file structures, existing code patterns, and conventions. Use '${READ_FILE_TOOL_NAME}' to understand context and validate any assumptions you may have. If you need to read multiple files, you should make multiple parallel calls to '${READ_FILE_TOOL_NAME}'. Keep in mind the following as you explore: - Search and/or read enough files to gain a thorough understanding of the problem. -- However, irrelevant context consumed by unnecessarily reading entire files will degrade the quality of your answer, so use ranged reads if you know which lines you need.`; +- IMPORTANT: extra context consumed by unnecessarily reading entire files will degrade the quality of your answer, so **ALWAYS** use ranged reads if you know approximately which lines you need. For example, when fixing a linter error at line 50, read ~20 lines around it (offset: 40, limit: 20) to get sufficient context for a replacement.`; } function workflowStepPlan(options: PrimaryWorkflowsOptions): string { diff --git a/packages/core/src/tools/edit.ts b/packages/core/src/tools/edit.ts index baaefe9a92..ed0ac775c4 100644 --- a/packages/core/src/tools/edit.ts +++ b/packages/core/src/tools/edit.ts @@ -912,7 +912,7 @@ export class EditTool super( EditTool.Name, 'Edit', - `Replaces text within a file. By default, replaces a single occurrence, but can replace multiple occurrences when \`expected_replacements\` is specified. This tool requires providing significant context around the change to ensure precise targeting. Always use the ${READ_FILE_TOOL_NAME} tool to examine the file's current content before attempting a text replacement. + `Replaces text within a file. By default, replaces a single occurrence, but can replace multiple occurrences when \`expected_replacements\` is specified. This tool requires providing significant context around the change to ensure precise targeting. Always use the ${READ_FILE_TOOL_NAME} tool (using 'offset' and 'limit' to get ~20 lines of context around the match) to examine the file's current content before attempting a text replacement. The user has the ability to modify the \`new_string\` content. If modified, this will be stated in the response.