Skip to content

Commit 31ace96

Browse files
DaveZhengclaude
andcommitted
fix: tell model to answer general questions directly without tools
The model was using grep to count letters in "strawberry" because the prompt said "You MUST use tools". Updated system prompts and tool injection to clarify: only use tools for file/filesystem tasks, answer general knowledge questions directly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e7da628 commit 31ace96

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/prompt-trimmer.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,17 @@ function extractUserInstructions(prompt: string): string {
7474
const SMALL_SYSTEM = `You are a coding assistant. Help the user with software engineering tasks concisely and accurately.
7575
7676
Rules:
77-
- Use the provided tools to interact with the filesystem
78-
- Never guess or hallucinate file contents
79-
- Read files before editing them
80-
- Keep responses short and focused`;
77+
- For general knowledge questions, answer directly without using tools.
78+
- Only use tools when the task involves files or the filesystem.
79+
- Never guess or hallucinate file contents — use tools to read them.
80+
- Read files before editing them.
81+
- Keep responses short and focused.`;
8182

8283
const MEDIUM_SYSTEM = `You are a coding assistant that helps users with software engineering tasks.
8384
8485
Rules:
85-
- Use the provided tools to interact with the filesystem. Never guess file contents.
86+
- For general knowledge questions, answer directly without using tools.
87+
- Only use tools when the task involves files or the filesystem. Never guess file contents.
8688
- Read files before editing them.
8789
- Keep responses concise and focused on the task.
8890
- When editing files, prefer targeted edits over full rewrites.

src/prompt.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ export function buildToolInjection(): string {
3030
"</tool_call>",
3131
"",
3232
"CRITICAL RULES:",
33-
"- You MUST use tools to interact with the filesystem. NEVER guess or hallucinate file contents.",
33+
"- Only use tools when the task involves files, the filesystem, or running commands.",
34+
"- For general knowledge questions, answer directly WITHOUT using tools.",
35+
"- NEVER guess or hallucinate file contents — use tools to read them.",
3436
"- Always include the opening <tool_call> tag. Never omit it.",
3537
"- You may include text before a tool call to explain what you're doing.",
36-
"- You may make multiple tool calls in one response.",
37-
"- After a tool call, wait for the result before continuing.",
38+
"- After a tool call, STOP and wait for the result before continuing.",
3839
"",
3940
"<tools>",
4041
toolsXml,

0 commit comments

Comments
 (0)