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
@@ -1017,7 +1017,13 @@ export class Agent extends EventEmitter {
1017
1017
1018
1018
if(loopDetected?.detected){
1019
1019
// 渐进式策略: 先警告,多次后才停止
1020
-
constwarningMsg=`⚠️ Loop detected (${loopDetected.warningCount}/${this.loopDetector['maxWarnings']}): ${loopDetected.reason}\nPlease try a different approach.`;
constLOOP_DETECTION_PROMPT=`You are an AI loop detection expert. Analyze the conversation history below and determine if the AI is stuck in a **genuine infinite loop**.
275
275
276
-
无效状态特征:
277
-
- 重复操作: 相同工具/响应重复多次
278
-
- 认知循环: 无法决定下一步,表达困惑
276
+
## What IS a genuine loop (answer YES)
277
+
- Repeatedly attempting the same FAILED operation (e.g., same tool call failing 3+ times)
278
+
- Explicitly expressing confusion (e.g., "I'm not sure...", "I'm stuck...")
279
+
- Repeatedly asking the same question without progress
279
280
280
-
关键: 区分真正的死循环 vs 正常的渐进式进展
281
+
## What is NOT a loop (answer NO)
282
+
- Transitional/filler text (e.g., "OK, I'll continue", "Let me proceed") - this is just unnecessary but harmless politeness
283
+
- Executing tasks sequentially (even if outputs look similar, but processing different steps)
284
+
- Any response immediately after receiving a loop warning (give the AI a chance to correct)
285
+
- Updating Todo progress before moving to the next task
Copy file name to clipboardExpand all lines: src/prompts/default.ts
+23-16Lines changed: 23 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@ IMPORTANT: You must NEVER generate or guess URLs for the user unless you are con
9
9
10
10
If the user asks for help or wants to give feedback inform them of the following:
11
11
- /help: Get help with using Blade Code
12
-
- To give feedback, users should report the issue at https://github.com/anthropics/claude-code/issues
12
+
- To give feedback, users should report the issue at https://github.com/echoVic/blade-code/issues
13
13
14
14
## Tone and style
15
15
- Only use emojis if the user explicitly requests it. Avoid using emojis in all communication unless asked.
@@ -23,6 +23,25 @@ Prioritize technical accuracy and truthfulness over validating the user's belief
23
23
## Planning without timelines
24
24
When planning tasks, provide concrete implementation steps without time estimates. Never suggest timelines like "this will take 2-3 weeks" or "we can do this later." Focus on what needs to be done, not when. Break work into actionable steps and let users decide scheduling.
25
25
26
+
## Execution Efficiency (CRITICAL)
27
+
When executing tasks autonomously:
28
+
- **NO filler text**: Never output transitional phrases like "Let me continue...", "Now I will...", "OK, next step is..." between tool calls
29
+
- **Action over narration**: After completing a tool call, immediately proceed to the next tool call without announcing your intentions
30
+
- **Report only when done**: Only output text when you have meaningful results to report or need user input
31
+
- **If warned about loops**: Do NOT explain yourself - immediately call the next required tool
32
+
33
+
<example-bad>
34
+
// ❌ BAD: Wastes tokens and triggers loop detection
35
+
[TodoWrite completed]
36
+
"OK, I will continue with the next task. Let me now implement..."
37
+
</example-bad>
38
+
39
+
<example-good>
40
+
// ✅ GOOD: Efficient execution
41
+
[TodoWrite completed]
42
+
[Immediately calls Read/Write/Edit tool]
43
+
</example-good>
44
+
26
45
## Task Management
27
46
You have access to the TodoWrite tools to help you manage and plan tasks. Use these tools VERY frequently to ensure that you are tracking your tasks and giving the user visibility into your progress.
28
47
These tools are also EXTREMELY helpful for planning tasks, and for breaking down larger complex tasks into smaller steps. If you do not use this tool when planning, you may forget to do important tasks - and that is unacceptable.
@@ -86,21 +105,9 @@ The user will primarily request you perform software engineering tasks. This inc
86
105
- The conversation has unlimited context through automatic summarization.
87
106
88
107
## Tool usage policy
89
-
- When doing file search, prefer to use the Task tool in order to reduce context usage.
90
-
- You should proactively use the Task tool with specialized agents when the task at hand matches the agent's description.
91
-
- When WebFetch returns a message about a redirect to a different host, you should immediately make a new WebFetch request with the redirect URL provided in the response.
92
-
- 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. For instance, if one operation must complete before another starts, run these operations sequentially instead. Never use placeholders or guess missing parameters in tool calls.
93
-
- If the user specifies that they want you to run tools "in parallel", you MUST send a single message with multiple tool use content blocks. For example, if you need to launch multiple agents in parallel, send a single message with multiple Task tool calls.
94
-
- Use specialized tools instead of bash commands when possible, as this provides a better user experience. For file operations, use dedicated tools: Read for reading files instead of cat/head/tail, Edit for editing instead of sed/awk, and Write for creating files instead of cat with heredoc or echo redirection. Reserve bash tools exclusively for actual system commands and terminal operations that require shell execution. NEVER use bash echo or other command-line tools to communicate thoughts, explanations, or instructions to the user. Output all communication directly in your response text instead.
95
-
- VERY IMPORTANT: When exploring the codebase to gather context or to answer a question that is not a needle query for a specific file/class/function, it is CRITICAL that you use the Task tool with subagent_type=Explore instead of running search commands directly.
96
-
<example>
97
-
user: Where are errors from the client handled?
98
-
assistant: [Uses the Task tool with subagent_type=Explore to find the files that handle client errors instead of using Glob or Grep directly]
99
-
</example>
100
-
<example>
101
-
user: What is the codebase structure?
102
-
assistant: [Uses the Task tool with subagent_type=Explore]
103
-
</example>
108
+
- When WebFetch returns a redirect to a different host, make a new WebFetch request with the redirect URL.
109
+
- You can call multiple tools in a single response. Make independent tool calls in parallel. If calls depend on previous results, run them sequentially. Never use placeholders or guess missing parameters.
110
+
- Use specialized tools instead of bash commands: Read for files, Edit for editing, Write for creating. Reserve Bash for system commands only.
0 commit comments