fix(settings): accept the caller's image fallback flag on the validated client

ImageCaptionBatcher already passes allow_image_fallback=False, and the
validated client now sets that argument itself, so the batch path raised
TypeError: got multiple values and returned no captions for the whole
batch. The caller's flag is dropped before forwarding; the validated
verdict is the authority either way.

Refs #2037

Signed-off-by: cgycorey <cgycorey@users.noreply.github.com>
This commit is contained in:
cgycorey
2026-10-23 20:20:08 +01:00
parent 731b5159a0
commit 4da7b28372
2 changed files with 34 additions and 0 deletions

View File

@@ -54,6 +54,8 @@ class _ImageDescriptionClient(LLMClient):
history: list[dict[str, str]] | None = None,
**kwargs: Any,
) -> str:
# The caption batcher passes this flag too; the validated verdict wins.
kwargs.pop("allow_image_fallback", None)
# Preserve the full resolved profile (including wire API and endpoint)
# rather than rebuilding an override from a subset of its fields.
return await complete_with_config(

View File

@@ -124,3 +124,35 @@ async def test_complete_sends_images_for_the_validated_selection(
assert await client.complete("Describe", image_data="synthetic-image") == "a labelled diagram"
assert calls[0]["allow_image_fallback"] is False
@pytest.mark.asyncio
async def test_complete_tolerates_a_caller_supplied_fallback_flag(
tmp_path: Path, monkeypatch
) -> None:
"""The caption batcher passes this flag itself; it must not collide."""
service = _service(tmp_path, [{"id": "m", "model": "llama3.2-vision"}])
_patch_catalog(monkeypatch, service)
config = resolve_image_description_config(SELECTION)
calls: list[bool | None] = []
async def complete(
*,
config: Any,
prompt: str,
system_prompt: str,
messages: Any,
allow_image_fallback: bool | None = None,
**kwargs: Any,
) -> str:
calls.append(allow_image_fallback)
return "a labelled diagram"
monkeypatch.setattr(image_description, "complete_with_config", complete)
client = image_description._ImageDescriptionClient(config, configure_env=False)
caption = await client.complete(
"Describe", image_data="synthetic-image", max_retries=0, allow_image_fallback=False
)
assert caption == "a labelled diagram"
assert calls == [False]