OpenWriterControle/evals/framework/test-timeline.ts
darrenhinde 8eb4b31ef4 feat(evals): add opencoder test suite and fix expected violation handling
- Create separate test folder for opencoder agent with 4 tests
- Update openagent tests to use multi-turn prompts for approval workflow
- Fix test runner to properly handle expectedViolations with shouldViolate: true
- Add mustUseAnyOf behavior expectation for flexible tool matching
- Add unit tests for timeline-builder and context-loading-evaluator
- Update documentation to reflect agent-specific test structure
- Remove outdated AGENT_DETECTION_STATUS.md

Opencoder tests: 4/4 passing
Key insight: openagent uses text-based approval, opencoder uses tool permissions only
2025-11-26 01:52:18 +00:00

68 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* Test script to verify timeline builder works with real session data
*/
import { SessionReader } from './src/collector/session-reader.js';
import { TimelineBuilder } from './src/collector/timeline-builder.js';
async function test() {
const reader = new SessionReader();
const builder = new TimelineBuilder(reader);
// Get sessions
const sessions = await reader.listSessions();
console.log('Total sessions:', sessions.length);
// Find a session with tools (check first 10)
for (const session of sessions.slice(0, 10)) {
console.log('\n--- Checking session:', session.id);
console.log(' Title:', session.title?.substring(0, 60));
const messagesWithParts = await reader.getMessagesWithParts(session.id);
console.log(' Messages:', messagesWithParts.length);
let toolCount = 0;
const toolNames: string[] = [];
for (const msg of messagesWithParts) {
for (const part of msg.parts || []) {
if (part.type === 'tool') {
toolCount++;
toolNames.push(part.tool);
}
}
}
console.log(' Tool parts in raw data:', toolCount);
if (toolNames.length > 0) {
console.log(' Tools:', [...new Set(toolNames)].join(', '));
}
if (toolCount > 0) {
// Build timeline and check
const timeline = await builder.buildTimeline(session.id);
const toolCalls = timeline.filter(e => e.type === 'tool_call');
console.log(' Timeline tool_call events:', toolCalls.length);
if (toolCalls.length > 0) {
console.log(' ✅ Timeline correctly captured tool calls!');
console.log(' First tool in timeline:', toolCalls[0].data?.tool);
} else {
console.log(' ❌ Timeline MISSING tool calls!');
}
// Found a session with tools, we can stop
console.log('\n=== VERIFICATION COMPLETE ===');
if (toolCalls.length === toolCount) {
console.log('✅ SUCCESS: Timeline correctly captures all tool calls');
} else {
console.log(`❌ MISMATCH: Raw data has ${toolCount} tools, timeline has ${toolCalls.length}`);
}
return;
}
}
console.log('\n⚠️ No sessions with tool calls found in first 10 sessions');
}
test().catch(console.error);