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.
This commit is contained in:
2026-05-31 23:10:16 +03:00
parent ab90755fa1
commit 83e6181bf5

View File

@@ -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: