From 83e6181bf5857c7364e75bfd658eabb394ff9aee Mon Sep 17 00:00:00 2001 From: busya Date: Sun, 31 May 2026 23:10:16 +0300 Subject: [PATCH] fix(validation): fallback chunk size when max_images=0 or None When max_images could not be detected (e.g. Kilo gateway doesn't support OpenAI image format, probe returned 0), chunking was disabled entirely and all screenshots sent in a single request. Nvidia NeMo still enforces an 8-image limit regardless of the gateway, causing 400 errors. Fix: default to 8 images per chunk when max_images is 0 or None, so chunking always applies for multi-tab dashboards. --- backend/src/plugins/llm_analysis/service.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/backend/src/plugins/llm_analysis/service.py b/backend/src/plugins/llm_analysis/service.py index c2836604..5c4ca40a 100644 --- a/backend/src/plugins/llm_analysis/service.py +++ b/backend/src/plugins/llm_analysis/service.py @@ -1297,8 +1297,12 @@ class LLMClient: prompt = render_prompt(prompt_template, {"logs": log_text}) # 2. Determine chunking + # Default to 8 images per chunk as a safe fallback when max_images is 0 or None + # (0 means probe failed — e.g. Kilo gateway doesn't support OpenAI image format) + DEFAULT_CHUNK_SIZE = 8 + effective_max = max_images if (max_images is not None and max_images > 0) else DEFAULT_CHUNK_SIZE n_total = len(encoded_images) - chunk_size = max_images if (max_images and max_images > 0 and max_images < n_total) else n_total + chunk_size = effective_max if effective_max < n_total else n_total is_chunking = chunk_size < n_total if is_chunking: