From 0cb9ed2f6411f06ffe30fe136ca2d0def0e7df72 Mon Sep 17 00:00:00 2001 From: Alex Nork Date: Tue, 24 Feb 2026 08:39:36 -0500 Subject: [PATCH] fix: guard buildChunks infinite loop and use nullish coalescing for inputs Co-Authored-By: Claude --- .../media-processing/tools/analyze-keyframes.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/assistant/src/config/bundled-skills/media-processing/tools/analyze-keyframes.ts b/assistant/src/config/bundled-skills/media-processing/tools/analyze-keyframes.ts index ee2e0350c1c..7490fffc238 100644 --- a/assistant/src/config/bundled-skills/media-processing/tools/analyze-keyframes.ts +++ b/assistant/src/config/bundled-skills/media-processing/tools/analyze-keyframes.ts @@ -40,7 +40,7 @@ Return a JSON array of these objects, one per frame. Return ONLY the JSON array, function buildChunks(keyframes: MediaKeyframe[], chunkSize: number, overlap: number): MediaKeyframe[][] { const chunks: MediaKeyframe[][] = []; - const step = chunkSize - overlap; + const step = Math.max(1, chunkSize - overlap); for (let i = 0; i < keyframes.length; i += step) { chunks.push(keyframes.slice(i, i + chunkSize)); } @@ -275,9 +275,9 @@ export async function run( } const analysisType = (input.analysis_type as string) || 'scene_description'; - const batchSize = (input.batch_size as number) || 10; - const chunkSizeInput = (input.chunk_size as number) || 10; - const overlapInput = (input.overlap as number) || 2; + const batchSize = (input.batch_size as number) ?? 10; + const chunkSizeInput = (input.chunk_size as number) ?? 10; + const overlapInput = (input.overlap as number) ?? 2; try { // Check if all keyframes are already analyzed before calling the core function