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
const_fewShotExample='### Tool Call Example\nUser: Create an HTML page called hello.html with a greeting\nAssistant:\n```json\n{"tool":"write_file","params":{"filePath":"hello.html","content":"<!DOCTYPE html>\\n<html><head><title>Hello</title></head><body><h1>Hello!</h1></body></html>"}}\n```\n';
console.log(`[AI Chat] Code-dump nudge: model produced code blocks without tool calls. Nudges remaining: ${nudgesRemaining}`);
2149
+
const_nudgeMsg=`[SYSTEM: You wrote code directly in the chat instead of saving it to a file. Use the write_file tool to save code to a file. Format: \`\`\`json\n{"tool":"write_file","params":{"filePath":"filename.ext","content":"...your code..."}}\n\`\`\`\nDo NOT repeat the code in chat — call write_file now.]`;
2150
+
currentPrompt={
2151
+
systemContext: currentPrompt.systemContext,
2152
+
userMessage: _nudgeMsg,
2153
+
};
2154
+
continue;// retry without breaking
2155
+
}
2075
2156
console.log(`[AI Chat] No more tool calls, ending agentic loop`);
// Continuation hint — signal to keep building multi-section or multi-file output
2380
+
// Continuation hint — context-aware to prevent duplicate-write loops.
2381
+
// If the same filePath was already written in a previous iteration, do NOT
2382
+
// nudge to "call write_file IMMEDIATELY" — that causes the model to re-write
2383
+
// the same file repeatedly. Instead, signal task completion for that file.
2300
2384
if(tr.tool==='write_file'){
2301
-
toolFeedback+=`*File written. If the task requires MORE FILES to be created, call write_file IMMEDIATELY for the next file. If this file needs more content added, call append_to_file IMMEDIATELY. Do NOT stop until ALL required files and content are fully written.*\n`;
toolFeedback+=`*File updated (already created earlier). This file is complete. If the original task required OTHER files, create them now. Otherwise, provide a summary of what was built.*\n`;
2390
+
}else{
2391
+
toolFeedback+=`*File written. If the task requires MORE FILES to be created, call write_file IMMEDIATELY for the next file. If this file needs more content added, call append_to_file IMMEDIATELY. Do NOT stop until ALL required files and content are fully written.*\n`;
2392
+
}
2302
2393
}else{
2303
2394
toolFeedback+=`*Content appended. If more content remains for this file, call append_to_file again immediately. If other files still need to be created, call write_file for the next required file. Stop only when ALL required files and sections are fully written.*\n`;
Copy file name to clipboardExpand all lines: main/mcpToolServer.js
+12-1Lines changed: 12 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -2216,8 +2216,9 @@ class MCPToolServer {
2216
2216
* Grammar handles structural validity; this provides semantic guidance.
2217
2217
* Task-filtered to reduce noise. ~350 tokens.
2218
2218
*/
2219
-
getCompactToolHint(taskType){
2219
+
getCompactToolHint(taskType,options){
2220
2220
if(taskType==='chat')return'';
2221
+
constminimal=options&&options.minimal;
2221
2222
lethint='## Your Tools\n';
2222
2223
hint+='Call tools with: ```json\n{"tool":"read_file","params":{"filePath":"index.js"}}\n```\nUse the actual parameter names shown below for each tool.\n';
2223
2224
if(this.projectPath){
@@ -2235,6 +2236,16 @@ class MCPToolServer {
2235
2236
hint+='- **run_command**(command) — Run a terminal/shell command.\n';
0 commit comments