feat: harden video analysis and runtime resilience
This commit is contained in:
1 parent
5ada543a09
commit
bb16991f2c
55 files changed
+5023
-437
No files matched your search
@@ -1,4 +1,8 @@
|
||||
import { cleanErrorMessage, getUniqueGenericTools } from './tool-formatter.util';
|
||||
import {
|
||||
cleanErrorMessage,
|
||||
getUniqueGenericTools,
|
||||
getVideoAnalysisView
|
||||
} from './tool-formatter.util';
|
||||
|
||||
describe('cleanErrorMessage', () => {
|
||||
it('removes repeated LLM wrapper labels while preserving the provider reason', () => {
|
||||
@@ -86,3 +90,77 @@ describe('getUniqueGenericTools retry aggregation', () => {
|
||||
expect(result.map(tool => tool.name)).toEqual(['llm_pause']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('video analysis timeline formatting', () => {
|
||||
it('distinguishes a cache hit without presenting it as running', () => {
|
||||
const view = getVideoAnalysisView({
|
||||
name: 'spawn_sub_agent',
|
||||
status: 'success',
|
||||
payload: {
|
||||
args: { start_time: 0, end_time: 42 },
|
||||
result: 'CACHED VIDEO ANALYSIS: existing evidence'
|
||||
}
|
||||
});
|
||||
|
||||
expect(view?.outcome).toBe('complete');
|
||||
expect(view?.reuse).toBe('full');
|
||||
expect(view?.title).toBe('Reused video analysis');
|
||||
expect(view?.requestedRange).toEqual({ start: 0, end: 42 });
|
||||
});
|
||||
|
||||
it('collapses child video chunks into one stable note-style timeline item', () => {
|
||||
const result = getUniqueGenericTools([
|
||||
{
|
||||
trace_id: 'chunk-1',
|
||||
parent_trace_id: 'video-agent-1',
|
||||
type: 'tool',
|
||||
name: 'spawn_sub_agent',
|
||||
status: 'success',
|
||||
timestamp: 100,
|
||||
payload: {
|
||||
args: { start_time: 0, end_time: 30, specific_query: 'find the result' },
|
||||
result: '[from 0.0s to 30.0s] Summary: first'
|
||||
}
|
||||
},
|
||||
{
|
||||
trace_id: 'chunk-2',
|
||||
parent_trace_id: 'video-agent-1',
|
||||
type: 'tool',
|
||||
name: 'spawn_sub_agent',
|
||||
status: 'success',
|
||||
timestamp: 101,
|
||||
payload: {
|
||||
args: { start_time: 30, end_time: 60, specific_query: 'find the result' },
|
||||
result: 'PARTIAL VIDEO ANALYSIS (successful chunks were persisted). Failed intervals: 45.0s-60.0s'
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
expect(result.length).toBe(1);
|
||||
expect(result[0].name).toBe('video_analysis');
|
||||
expect(result[0].trace_id).toBe('video-analysis-video-agent-1');
|
||||
expect(result[0].payload.result.outcome).toBe('partial');
|
||||
expect(result[0].payload.result.requested_range).toEqual({ start: 0, end: 60 });
|
||||
expect(getVideoAnalysisView(result[0])?.title).toBe('Video analysis partially completed');
|
||||
});
|
||||
|
||||
it('keeps video analyses from independent parent executions separate', () => {
|
||||
const result = getUniqueGenericTools([
|
||||
{
|
||||
trace_id: 'chunk-1', parent_trace_id: 'video-agent-1', type: 'tool',
|
||||
name: 'spawn_sub_agent', status: 'success',
|
||||
payload: { args: { start_time: 0, end_time: 10 }, result: 'first' }
|
||||
},
|
||||
{
|
||||
trace_id: 'chunk-2', parent_trace_id: 'video-agent-2', type: 'tool',
|
||||
name: 'spawn_sub_agent', status: 'success',
|
||||
payload: { args: { start_time: 10, end_time: 20 }, result: 'second' }
|
||||
}
|
||||
]);
|
||||
|
||||
expect(result.map(tool => tool.trace_id)).toEqual([
|
||||
'video-analysis-video-agent-1',
|
||||
'video-analysis-video-agent-2'
|
||||
]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user