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: