UNPKG

contaigents

Version:

Modular AI Content Ecosystem with Audio Generation

52 lines (51 loc) • 2.68 kB
#!/usr/bin/env node 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();