contaigents
Version:
Modular AI Content Ecosystem with Audio Generation
52 lines (51 loc) ⢠2.68 kB
JavaScript
import { ChatService } from '../services/chatService.js';
async function testToolFirstBehavior() {
console.log('š§ Testing Tool-First Behavior with Enhanced Prompts...\n');
try {
// Initialize chat service
const chatService = new ChatService(process.cwd());
// Test the exact scenario the user mentioned
console.log('š Testing: "learn project setup in detail and update the readme"');
const session = await chatService.createSession();
console.log('Sending message...\n');
const response = await chatService.sendMessage(session.id, "learn project setup in detail and update the readme");
console.log('š¤ Response Analysis:');
console.log('Response length:', response.content.length);
// Check if the response contains tool calls (XML format)
const hasToolCalls = response.content.includes('<tool_call');
console.log('Contains tool calls:', hasToolCalls ? 'ā
YES' : 'ā NO');
// Check if response starts with planning text vs tool calls
const startsWithPlanning = response.content.trim().startsWith('To help you') ||
response.content.trim().startsWith('I\'ll help you') ||
response.content.trim().startsWith('Let me plan');
console.log('Starts with planning:', startsWithPlanning ? 'ā YES (BAD)' : 'ā
NO (GOOD)');
// Show first 300 characters to analyze behavior
console.log('\nš First 300 characters of response:');
console.log('---');
console.log(response.content.substring(0, 300));
console.log('---\n');
// Test another scenario
console.log('š Testing: "analyze my project structure"');
const response2 = await chatService.sendMessage(session.id, "analyze my project structure");
const hasToolCalls2 = response2.content.includes('<tool_call');
console.log('Contains tool calls:', hasToolCalls2 ? 'ā
YES' : 'ā NO');
console.log('\nš First 200 characters of response:');
console.log('---');
console.log(response2.content.substring(0, 200));
console.log('---\n');
console.log('ā
Tool-first behavior test completed!');
if (hasToolCalls && hasToolCalls2) {
console.log('š SUCCESS: Agent is using tools immediately!');
}
else {
console.log('ā ļø NEEDS IMPROVEMENT: Agent should use tools first for information gathering');
}
}
catch (error) {
console.error('ā Error testing tool-first behavior:', error);
process.exit(1);
}
}
// Run the test
testToolFirstBehavior();