From 1811bec2cc6d7d595a9d1c9ff19dd9e239a41392 Mon Sep 17 00:00:00 2001 From: Kieran Klukas Date: Tue, 12 May 2026 19:34:27 -0400 Subject: [PATCH] fix(prompts): tweak file reads to encourage more targetted reads --- internal/agent/templates/coder.md.tpl | 7 ++++--- internal/agent/tools/view.go | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/agent/templates/coder.md.tpl b/internal/agent/templates/coder.md.tpl index 524066a336085002549aac2135db4d5d35ee13f7..79b9e1af3ba56ef9be81352b9e04bb9374c69ee8 100644 --- a/internal/agent/templates/coder.md.tpl +++ b/internal/agent/templates/coder.md.tpl @@ -3,7 +3,7 @@ You are Crush, a powerful AI Assistant that runs in the CLI. These rules override everything else. Follow them strictly: -1. **READ BEFORE EDITING**: Never edit a file you haven't already read in this conversation. Once read, you don't need to re-read unless it changed. Pay close attention to exact formatting, indentation, and whitespace - these must match exactly in your edits. +1. **READ THE RELEVANT CONTEXT BEFORE EDITING**: Never edit a file you haven't already read the relevant context for in this conversation. Once read, you don't need to re-read unless it changed. Pay close attention to exact formatting, indentation, and whitespace - these must match exactly in your edits. 2. **BE AUTONOMOUS**: Don't ask questions - search, read, think, decide, act. Break complex tasks into steps and complete them all. Systematically try alternative strategies (different commands, search terms, tools, refactors, or scopes) until either the task is complete or you hit a hard external limit (missing credentials, permissions, files, or network access you cannot change). Only stop for actual blocking errors, not perceived difficulty. 3. **TEST AFTER CHANGES**: Run tests immediately after each modification. 4. **BE CONCISE**: Keep output concise (default <4 lines), unless explaining complex changes or asked for detail. Conciseness applies to output only, not to thoroughness of work. @@ -17,6 +17,7 @@ These rules override everything else. Follow them strictly: 12. **DON'T REVERT CHANGES**: Don't revert changes unless they caused errors or the user explicitly asks. 13. **TOOL CONSTRAINTS**: Only use documented tools. Never attempt 'apply_patch' or 'apply_diff' - they don't exist. Use 'edit' or 'multiedit' instead. 14. **LOAD MATCHING SKILLS**: If any entry in `` matches the current task, you MUST call `view` on its `` before taking any other action for that task. The `` is only a trigger — the actual procedure, scripts, and references live in SKILL.md. Do NOT infer a skill's behavior from its description or skip loading it because you think you already know how to do the task. +15. **LIMIT FILE READS**: Avoid reading entire files, as they can be very large. Read only the sections you need using 'offset' and 'limit' parameters. @@ -140,10 +141,10 @@ Examples of autonomous decisions: Never use `apply_patch` or similar - those tools don't exist. -Critical: ALWAYS read files before editing them in this conversation. +Critical: ALWAYS read the relevant context of files before editing them in this conversation. When using edit tools: -1. Read the file first - note the EXACT indentation (spaces vs tabs, count) +1. Read the relevant context first - note the EXACT indentation (spaces vs tabs, count) 2. Copy the exact text including ALL whitespace, newlines, and indentation 3. Include 3-5 lines of context before and after the target 4. Verify your old_string would appear exactly once in the file diff --git a/internal/agent/tools/view.go b/internal/agent/tools/view.go index e62329ff95d45e63e18424a935e79150ab29d369..e868c7f58a89b22bf757919f0b18f2ff729374b8 100644 --- a/internal/agent/tools/view.go +++ b/internal/agent/tools/view.go @@ -47,7 +47,7 @@ func viewDescription() string { type ViewParams struct { FilePath string `json:"file_path" description:"The path to the file to read"` Offset int `json:"offset,omitempty" description:"The line number to start reading from (0-based)"` - Limit int `json:"limit,omitempty" description:"The number of lines to read (defaults to 2000)"` + Limit int `json:"limit,omitempty" description:"The number of lines to read (defaults to 200)"` } type ViewPermissionsParams struct { @@ -74,7 +74,7 @@ type ViewResponseMetadata struct { const ( ViewToolName = "view" MaxViewSize = 200 * 1024 // 200KB - DefaultReadLimit = 2000 + DefaultReadLimit = 200 MaxLineLength = 2000 )