@probelabs/probe-chat 0.6.0-rc72 → 0.6.0-rc74
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/probeChat.js +76 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@probelabs/probe-chat",
|
|
3
|
-
"version": "0.6.0-
|
|
3
|
+
"version": "0.6.0-rc74",
|
|
4
4
|
"description": "CLI and web interface for Probe code search (formerly @probelabs/probe-web and @probelabs/probe-chat)",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"@ai-sdk/anthropic": "^1.2.0",
|
|
33
33
|
"@ai-sdk/google": "^1.2.1",
|
|
34
34
|
"@ai-sdk/openai": "^1.3.0",
|
|
35
|
-
"@buger/probe": "^0.6.0-
|
|
35
|
+
"@buger/probe": "^0.6.0-rc74",
|
|
36
36
|
"@opentelemetry/api": "^1.9.0",
|
|
37
37
|
"@opentelemetry/exporter-trace-otlp-http": "^0.203.0",
|
|
38
38
|
"@opentelemetry/resources": "^2.0.1",
|
package/probeChat.js
CHANGED
|
@@ -671,17 +671,17 @@ When troubleshooting:
|
|
|
671
671
|
if (this.debug) {
|
|
672
672
|
console.log(`[DEBUG] Using predefined prompt: ${this.promptType}`);
|
|
673
673
|
}
|
|
674
|
-
// Add common instructions to predefined prompts
|
|
675
|
-
systemMessage += commonInstructions;
|
|
676
674
|
} else {
|
|
677
675
|
// Use the default prompt (code explorer) if no prompt type is specified
|
|
678
676
|
systemMessage = "<role>" + predefinedPrompts['code-explorer'] + "</role>";
|
|
679
677
|
if (this.debug) {
|
|
680
678
|
console.log(`[DEBUG] Using default prompt: code explorer`);
|
|
681
679
|
}
|
|
682
|
-
// Add common instructions to the default prompt
|
|
683
|
-
systemMessage += commonInstructions;
|
|
684
680
|
}
|
|
681
|
+
|
|
682
|
+
// ALWAYS add common instructions regardless of prompt type
|
|
683
|
+
// This ensures tool call guidance is never missing
|
|
684
|
+
systemMessage += commonInstructions;
|
|
685
685
|
// Add XML Tool Guidelines
|
|
686
686
|
systemMessage += `\n${xmlToolGuidelines}\n`;
|
|
687
687
|
|
|
@@ -916,6 +916,7 @@ When troubleshooting:
|
|
|
916
916
|
let currentIteration = 0;
|
|
917
917
|
let completionAttempted = false;
|
|
918
918
|
let finalResult = `Error: Max tool iterations (${MAX_TOOL_ITERATIONS}) reached without completion. You can increase this limit using the MAX_TOOL_ITERATIONS environment variable or --max-iterations flag.`; // Default error
|
|
919
|
+
let consecutiveNoToolCallCount = 0;
|
|
919
920
|
|
|
920
921
|
this.abortController = new AbortController();
|
|
921
922
|
const debugFilePath = join(process.cwd(), 'probe-debug.txt');
|
|
@@ -1306,6 +1307,8 @@ When troubleshooting:
|
|
|
1306
1307
|
|
|
1307
1308
|
const parsedTool = parseXmlToolCallWithThinking(assistantResponseContent);
|
|
1308
1309
|
if (parsedTool) {
|
|
1310
|
+
// Reset counter on successful tool call detection
|
|
1311
|
+
consecutiveNoToolCallCount = 0;
|
|
1309
1312
|
const { toolName, params } = parsedTool;
|
|
1310
1313
|
if (this.debug) console.log(`[DEBUG] Parsed tool call: ${toolName} with params:`, params);
|
|
1311
1314
|
|
|
@@ -1432,10 +1435,75 @@ When troubleshooting:
|
|
|
1432
1435
|
}
|
|
1433
1436
|
|
|
1434
1437
|
} else {
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1438
|
+
consecutiveNoToolCallCount++;
|
|
1439
|
+
if (this.debug) console.log(`[DEBUG] No tool call detected in assistant response. Prompting for tool use.`);
|
|
1440
|
+
|
|
1441
|
+
// After 3 consecutive failures to provide tool calls, force completion
|
|
1442
|
+
if (consecutiveNoToolCallCount >= 3) {
|
|
1443
|
+
if (this.debug) console.log(`[DEBUG] Too many consecutive failures to detect tool calls (${consecutiveNoToolCallCount}). Forcing completion.`);
|
|
1444
|
+
|
|
1445
|
+
const forceCompletionContent = `CRITICAL: ${consecutiveNoToolCallCount} consecutive invalid responses detected. You must complete this task NOW.
|
|
1446
|
+
|
|
1447
|
+
You have failed to provide valid XML tool calls multiple times. This indicates the task should be concluded.
|
|
1448
|
+
|
|
1449
|
+
You MUST respond with exactly this format:
|
|
1450
|
+
<attempt_completion>
|
|
1451
|
+
<result>
|
|
1452
|
+
[Based on the conversation above, provide your final answer. If the task was not fully completed, explain what was accomplished and what remains to be done.]
|
|
1453
|
+
</result>
|
|
1454
|
+
</attempt_completion>
|
|
1455
|
+
|
|
1456
|
+
REQUIRED: Respond with ONLY the attempt_completion XML block above. No other text.`;
|
|
1457
|
+
currentMessages.push({ role: 'user', content: forceCompletionContent });
|
|
1458
|
+
this.tokenCounter.calculateContextSize(currentMessages);
|
|
1459
|
+
} else {
|
|
1460
|
+
// Check if we've done substantial work that might indicate completion is appropriate
|
|
1461
|
+
const hasToolResults = currentMessages.some(msg => msg.content && msg.content.includes('<tool_result>'));
|
|
1462
|
+
|
|
1463
|
+
let forceToolContent;
|
|
1464
|
+
if (hasToolResults && consecutiveNoToolCallCount >= 2) {
|
|
1465
|
+
forceToolContent = `INVALID RESPONSE FORMAT: Your response must contain exactly ONE tool call in XML format.
|
|
1466
|
+
|
|
1467
|
+
You have tool results available above. Based on those results:
|
|
1468
|
+
|
|
1469
|
+
If the user's question is answered or task is complete:
|
|
1470
|
+
<attempt_completion>
|
|
1471
|
+
<result>Your final answer based on the tool results above</result>
|
|
1472
|
+
</attempt_completion>
|
|
1473
|
+
|
|
1474
|
+
If you need more information:
|
|
1475
|
+
<search>
|
|
1476
|
+
<query>specific keywords</query>
|
|
1477
|
+
<path>specific path</path>
|
|
1478
|
+
</search>
|
|
1479
|
+
|
|
1480
|
+
REQUIRED: Choose one option and respond with ONLY the XML tool call, no other text.`;
|
|
1481
|
+
} else {
|
|
1482
|
+
forceToolContent = `INVALID RESPONSE FORMAT: You did not provide a tool call in the required XML format.
|
|
1483
|
+
|
|
1484
|
+
You MUST respond with exactly one tool call using this structure:
|
|
1485
|
+
<tool_name>
|
|
1486
|
+
<parameter_name>value</parameter_name>
|
|
1487
|
+
</tool_name>
|
|
1488
|
+
|
|
1489
|
+
Available tools:
|
|
1490
|
+
- <search> - find code using keywords
|
|
1491
|
+
- <query> - find code using patterns
|
|
1492
|
+
- <extract> - get specific files/lines
|
|
1493
|
+
- <attempt_completion> - provide final answer
|
|
1494
|
+
|
|
1495
|
+
Example:
|
|
1496
|
+
<search>
|
|
1497
|
+
<query>authentication functions</query>
|
|
1498
|
+
<path>src</path>
|
|
1499
|
+
</search>
|
|
1500
|
+
|
|
1501
|
+
REQUIRED: Respond with ONLY the XML tool call, no explanatory text.`;
|
|
1502
|
+
}
|
|
1503
|
+
|
|
1504
|
+
currentMessages.push({ role: 'user', content: forceToolContent });
|
|
1505
|
+
this.tokenCounter.calculateContextSize(currentMessages);
|
|
1506
|
+
}
|
|
1439
1507
|
}
|
|
1440
1508
|
|
|
1441
1509
|
if (currentMessages.length > MAX_HISTORY_MESSAGES + 3) {
|