You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: add anti-bash-for-code-exploration guidance and support promptType+customPrompt together (#490)
- Update bash tool description to explicitly forbid code exploration (grep, cat, find, etc.)
- Add anti-bash instruction #7 to commonInstructions in getSystemMessage()
- Add anti-bash guidance to Claude and Codex native system prompts
- Support both promptType and customPrompt simultaneously: predefined prompt as base + custom wrapped in <custom-instructions> tag
- When only customPrompt is set (no promptType), don't append commonInstructions since custom prompts are self-contained
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: npm/src/agent/ProbeAgent.js
+18-9Lines changed: 18 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -2876,7 +2876,7 @@ ${searchToolDesc1}
2876
2876
- searchFiles: Find files by name patterns`;
2877
2877
2878
2878
if(this.enableBash){
2879
-
systemPrompt+=`\n- bash: Execute bash commands for system operations`;
2879
+
systemPrompt+=`\n- bash: Execute bash commands for system operations (building, running tests, git, etc.). NEVER use bash for code exploration (no grep, cat, find, head, tail) — always use search and extract tools instead, they are faster and more accurate.`;
2880
2880
}
2881
2881
2882
2882
constsearchGuidance1=this.searchDelegate
@@ -2942,7 +2942,7 @@ ${searchToolDesc2}
2942
2942
- searchFiles: Find files by name patterns`;
2943
2943
2944
2944
if(this.enableBash){
2945
-
systemPrompt+=`\n- bash: Execute bash commands for system operations`;
2945
+
systemPrompt+=`\n- bash: Execute bash commands for system operations (building, running tests, git, etc.). NEVER use bash for code exploration (no grep, cat, find, head, tail) — always use search and extract tools instead, they are faster and more accurate.`;
2946
2946
}
2947
2947
2948
2948
constsearchGuidance2=this.searchDelegate
@@ -3018,7 +3018,8 @@ Follow these instructions carefully:
3018
3018
3. You should always prefer the search tool for code-related questions.${this.searchDelegate ? ' Ask natural language questions — the search subagent handles keyword formulation and returns extracted code blocks. Use extract only to expand context or read full files.' : ' Search handles stemming and case variations automatically — do NOT try keyword variations manually. Read full files only if really necessary.'}
3019
3019
4. Ensure to get really deep and understand the full picture before answering.
3020
3020
5. Once the task is fully completed, use the attempt_completion tool to provide the final result.
3021
-
6. ${this.searchDelegate ? 'Ask clear, specific questions when searching. Each search should target a distinct concept or question.' : 'Prefer concise and focused search queries. Use specific keywords and phrases to narrow down results.'}${this.allowEdit ? `
3021
+
6. ${this.searchDelegate ? 'Ask clear, specific questions when searching. Each search should target a distinct concept or question.' : 'Prefer concise and focused search queries. Use specific keywords and phrases to narrow down results.'}
3022
+
7. NEVER use bash for code exploration (no grep, cat, find, head, tail, awk, sed) — always use search and extract tools instead. Bash is only for system operations like building, running tests, or git commands.${this.allowEdit ? `
3022
3023
7. When modifying files, choose the appropriate tool:
3023
3024
- Use 'edit' for all code modifications:
3024
3025
* PREFERRED: Use start_line (and optionally end_line) for line-targeted editing — this is the safest and most precise approach.${this.hashLines ? ' Use the line:hash references from extract/search output (e.g. "42:ab") for integrity verification.' : ''} Always use extract first to see line numbers${this.hashLines ? ' and hashes' : ''}, then edit by line reference.
@@ -3035,22 +3036,30 @@ Follow these instructions carefully:
3035
3036
// Use predefined prompts from shared module (imported at top of file)
3036
3037
letsystemMessage='';
3037
3038
3038
-
// Use custom prompt if provided
3039
-
if(this.customPrompt){
3039
+
// Build system message from predefined prompt + optional custom prompt
Copy file name to clipboardExpand all lines: npm/src/tools/common.js
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -154,7 +154,7 @@ export const searchDelegateDescription = 'Search code in the repository by askin
154
154
exportconstqueryDescription='Search code using ast-grep structural pattern matching. Use this tool to find specific code structures like functions, classes, or methods.';
155
155
exportconstextractDescription='Extract code blocks from files based on file paths and optional line numbers. Use this tool to see complete context after finding relevant files. Line numbers from output can be used with edit start_line/end_line for precise editing.';
156
156
exportconstdelegateDescription='Automatically delegate big distinct tasks to specialized probe subagents within the agentic loop. Used by AI agents to break down complex requests into focused, parallel tasks.';
157
-
exportconstbashDescription='Execute bash commands for system exploration and development tasks. Secure by default with built-in allow/deny lists.';
157
+
exportconstbashDescription='Execute bash commands for system operations: building, running tests, git, package management, etc. NEVER use for code exploration (no grep, cat, find, head, tail) — use search and extract tools instead. Secure by default with built-in allow/deny lists.';
158
158
exportconstanalyzeAllDescription='Answer questions that require analyzing ALL matching data in the codebase. Use for aggregate questions like "What features exist?", "List all API endpoints", "Count TODO comments". The AI automatically plans the search strategy, processes all results via map-reduce, and synthesizes a comprehensive answer. WARNING: Slower than search - only use when you need complete coverage.';
0 commit comments