From 43e62fb8fcbfc26e503e6333bbcbec61ac4fe050 Mon Sep 17 00:00:00 2001 From: abel533 Date: Sat, 4 Apr 2026 19:41:21 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=BC=BA=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E8=AF=8D=20=E2=80=94=20=E5=AF=B9=E9=BD=90?= =?UTF-8?q?=E5=AE=98=E6=96=B9=E5=B7=A5=E5=85=B7=E4=BD=BF=E7=94=A8=E6=8C=87?= =?UTF-8?q?=E5=8D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加 'Using your tools' 段落(匹配官方 Claude Code): - 专用工具优先于 Bash(FileRead/FileEdit/Glob/Grep) - WebSearch/WebFetch 主动使用指令:遇到实时信息需求时 必须使用 WebSearch,不要说无法获取实时信息 - 并行工具调用指导 - TodoWrite 任务管理指导 解决 AI 不主动使用 WebSearch 工具的问题 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../context/SystemPromptBuilder.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/main/java/com/claudecode/context/SystemPromptBuilder.java b/src/main/java/com/claudecode/context/SystemPromptBuilder.java index ed6cf3e..b36543e 100644 --- a/src/main/java/com/claudecode/context/SystemPromptBuilder.java +++ b/src/main/java/com/claudecode/context/SystemPromptBuilder.java @@ -72,6 +72,36 @@ public class SystemPromptBuilder { sb.append(BashTool.getShellHint()); sb.append("\n"); + // 工具使用指南(对齐官方 Claude Code 的 "Using your tools" 段落) + sb.append(""" + # Using your tools + - Do NOT use the Bash tool to run commands when a relevant dedicated tool is provided. \ + Using dedicated tools allows the user to better understand and review your work. \ + This is CRITICAL to assisting the user: + - To read files use FileRead instead of cat, head, tail, or sed + - To edit files use FileEdit instead of sed or awk + - To create files use FileWrite instead of cat with heredoc or echo redirection + - To search for files use Glob instead of find or ls + - To search the content of files, use Grep instead of grep or rg + - Reserve using the Bash exclusively for system commands and terminal operations \ + that require shell execution. If you are unsure and there is a relevant dedicated tool, \ + default to using the dedicated tool and only fallback on using the Bash tool for these \ + if it is absolutely necessary. + - When the user asks about current events, real-time information, weather, news, or anything \ + that requires up-to-date data beyond your knowledge cutoff, you MUST use the WebSearch tool \ + to find the answer. Do NOT say you cannot access real-time information — you have WebSearch \ + and WebFetch tools available. Use them proactively. + - Use WebFetch to retrieve and analyze specific web pages when you have a URL. + - You can call multiple tools in a single response. If you intend to call multiple tools \ + and there are no dependencies between them, make all independent tool calls in parallel. \ + Maximize use of parallel tool calls where possible to increase efficiency. However, if \ + some tool calls depend on previous calls to inform dependent values, do NOT call these \ + tools in parallel and instead call them sequentially. + - Break down and manage your work with the TodoWrite tool. These tools are helpful for \ + planning your work and helping the user track your progress. + + """); + // 行为准则 sb.append(""" # Guidelines