- Track failed tool calls in call history (parse errors, execution errors)
- Increment turns counter for failed tool calls too
- Stuck detection now works even when tools fail repeatedly
- Inspired by Ruflo and Hermes Agent best practices
Fixes the bug where zCode would get stuck in infinite loops when tool calls fail.
Test results: ✅ All stuck detection tests passing
48 lines
1.6 KiB
JavaScript
48 lines
1.6 KiB
JavaScript
const intentDetector = require('./src/bot/intent-detector.js');
|
|
|
|
// Test cases from the original failing scenarios
|
|
const testCases = [
|
|
{ text: 'Hey', expected: 'greeting' },
|
|
{ text: 'Thanks', expected: 'greeting' },
|
|
{ text: 'Continue', expected: 'greeting' },
|
|
{ text: 'Done', expected: 'greeting' },
|
|
{ text: 'I asked you a question about your earlier task you ignore me…', expected: 'question' },
|
|
{ text: 'You didn\'t answer my question earlier', expected: 'question' },
|
|
{ text: 'What about the landing page design?', expected: 'question' },
|
|
{ text: 'How is it going?', expected: 'greeting' },
|
|
{ text: 'Status', expected: 'status' },
|
|
{ text: 'Ping', expected: 'status' },
|
|
{ text: 'Check my tasks', expected: 'status' },
|
|
];
|
|
|
|
console.log('🎯 INTENT DETECTOR TEST RESULTS\n');
|
|
console.log('─'.repeat(80));
|
|
|
|
let passed = 0;
|
|
let failed = 0;
|
|
|
|
testCases.forEach((test, index) => {
|
|
const result = intentDetector.detectIntent(test.text);
|
|
const status = result.type === test.expected ? '✅ PASS' : '❌ FAIL';
|
|
|
|
if (result.type === test.expected) {
|
|
passed++;
|
|
} else {
|
|
failed++;
|
|
}
|
|
|
|
console.log(`${status} ${index + 1}. "${test.text}"`);
|
|
console.log(` Expected: ${test.expected} → Got: ${result.type} (confidence: ${result.confidence.toFixed(2)})`);
|
|
if (result.type !== test.expected) {
|
|
console.log(` ❌ MISMATCH!`);
|
|
}
|
|
console.log('');
|
|
});
|
|
|
|
console.log('─'.repeat(80));
|
|
console.log(`\n📊 SUMMARY: ${passed}/${testCases.length} PASSED`);
|
|
console.log(` Success rate: ${(passed / testCases.length * 100).toFixed(1)}%`);
|
|
console.log(`\n${'─'.repeat(80)}\n`);
|
|
|
|
process.exit(failed > 0 ? 1 : 0);
|