Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

fix(ultrawiki): repair image provider fallback

Ruben Lütke160f32abb292
diff --git a/jarvis/memory/wiki/provider_chain.py b/jarvis/memory/wiki/provider_chain.py
index f1761142f3..a0aa5404f3 100644
--- a/jarvis/memory/wiki/provider_chain.py
+++ b/jarvis/memory/wiki/provider_chain.py
@@ -44,20 +44,22 @@ log = logging.getLogger(__name__)
# still tried before the chain gives up.
_PROVIDER_COOLDOWN_S = 900.0
-# provider name -> (monotonic timestamp of last hard failure, short reason)
-_provider_failures: dict[str, tuple[float, str]] = {}
+# (lane scope, provider name) -> (monotonic failure timestamp, short reason).
+# Modality-specific failures must not demote a provider for ordinary text work.
+_provider_failures: dict[tuple[str, str], tuple[float, str]] = {}
-def _note_provider_failure(provider: str, reason: str) -> None:
- _provider_failures[provider] = (time.monotonic(), reason)
+def _note_provider_failure(provider: str, reason: str, *, scope: str = "wiki") -> None:
+ _provider_failures[(scope, provider)] = (time.monotonic(), reason)
-def _in_cooldown(provider: str) -> bool:
- entry = _provider_failures.get(provider)
+def _in_cooldown(provider: str, *, scope: str = "wiki") -> bool:
+ key = (scope, provider)
+ entry = _provider_failures.get(key)
if entry is None:
return False
if time.monotonic() - entry[0] >= _PROVIDER_COOLDOWN_S:
- del _provider_failures[provider]
+ del _provider_failures[key]
return False
return True
@@ -79,6 +81,8 @@ def _record_chain_recovery(label: str) -> None:
def _order_by_cooldown(
chain: list[tuple[str, str | None]],
+ *,
+ scope: str = "wiki",
) -> tuple[list[tuple[str, str | None]], list[str]]:
"""Healthy providers first, recently-failed ones demoted to the end.
@@ -88,7 +92,7 @@ def _order_by_cooldown(
healthy: list[tuple[str, str | None]] = []
cooled: list[tuple[str, str | None]] = []
for entry in chain:
- (cooled if _in_cooldown(entry[0]) else healthy).append(entry)
+ (cooled if _in_cooldown(entry[0], scope=scope) else healthy).append(entry)
return healthy + cooled, [provider for provider, _model in cooled]
@@ -234,6 +238,8 @@ async def complete_with_fallback(
allow_lone_rejection: Callable[[str], bool] | None = None,
content_verdict: Callable[[str], bool] | None = None,
provider_options: Mapping[str, Mapping[str, Any]] | None = None,
+ record_health: bool = True,
+ failure_scope: str = "wiki",
) -> tuple[Any, str] | None:
"""Try each ``(provider, model)`` until one returns an aggregated response.
@@ -262,6 +268,13 @@ async def complete_with_fallback(
Live 2026-07-23: a single mis-kinded 'cloudflare-plugin' activity candidate
demanded a companion page no provider produced, wedging the chain and
listing all 8 providers as broken on every journal trigger.
+
+ ``record_health=False`` isolates an optional side lane from the normal Wiki
+ health strip. UltraWiki media enrichment uses the same provider machinery,
+ but an unreadable picture neither means normal Markdown capture is broken
+ nor has authority to clear a real capture failure after a later success.
+ ``failure_scope`` likewise isolates the short provider cooldown: an image-
+ specific 400 must not demote that same provider for ordinary text curation.
"""
from jarvis.memory.wiki.curator_llm import instantiate_curator_brain
@@ -275,8 +288,9 @@ async def complete_with_fallback(
# reach the chain-failure banner (see ``content_verdict`` above).
content_rejections: list[str] = []
allowed_rejection_fallback: tuple[Any, str, str] | None = None
+ shared_pipeline_failure = False
- ordered, demoted = _order_by_cooldown(chain)
+ ordered, demoted = _order_by_cooldown(chain, scope=failure_scope)
if demoted and ordered != chain:
log.info(
"%s: demoting recently-failed provider(s) to the end of the "
@@ -303,24 +317,64 @@ async def complete_with_fallback(
detail,
)
failure_summaries.append(f"{provider} instantiate failed: {detail}")
- _note_provider_failure(provider, detail)
+ _note_provider_failure(provider, detail, scope=failure_scope)
continue
if brain is None:
failure_summaries.append(f"{provider} unavailable")
continue
try:
- agg = await asyncio.wait_for(aggregate(brain.complete(request)), timeout=timeout_s)
+ stream = brain.complete(request)
+ except Exception as exc: # noqa: BLE001 — synchronous provider failure
+ detail = _exception_summary(exc)
+ log.warning(
+ "%s: provider %s failed before streaming (%s) — trying next provider",
+ label,
+ provider,
+ detail,
+ )
+ failure_summaries.append(f"{provider} {detail}")
+ _note_provider_failure(provider, detail, scope=failure_scope)
+ continue
+ try:
+ # Calling the caller-owned adapter is deliberately separate from
+ # awaiting it. A synchronous exception here is a shared pipeline
+ # contract bug, not six independent provider failures. Stop once,
+ # keep every provider healthy, and report the local stage honestly.
+ pending_aggregate = aggregate(stream)
+ except Exception as exc: # noqa: BLE001 — local adapter fault
+ detail = _exception_summary(exc)
+ log.error(
+ "%s: response aggregation setup failed (%s) — stopping the "
+ "provider chain because the shared adapter is broken",
+ label,
+ detail,
+ )
+ failure_summaries.append(f"{label} aggregation setup failed: {detail}")
+ shared_pipeline_failure = True
+ break
+ try:
+ agg = await asyncio.wait_for(pending_aggregate, timeout=timeout_s)
# Transport-level success: the provider is reachable again.
# A validation rejection below re-records it as failed.
- _provider_failures.pop(provider, None)
+ _provider_failures.pop((failure_scope, provider), None)
if validate is not None:
try:
rejection = validate(agg)
- except Exception as exc: # noqa: BLE001 - validator faults mean unusable output
- rejection = (
- "response validation failed: "
- f"{_exception_summary(exc)}"
+ if rejection is not None and not isinstance(rejection, str):
+ raise TypeError(
+ "response validators must return a rejection string or None"
+ )
+ except Exception as exc: # noqa: BLE001 - local validator fault
+ detail = _exception_summary(exc)
+ log.error(
+ "%s: response validator failed (%s) — stopping the "
+ "provider chain because the shared validator is broken",
+ label,
+ detail,
)
+ failure_summaries.append(f"{label} response validation failed: {detail}")
+ shared_pipeline_failure = True
+ break
if rejection:
safe_rejection = safe_preview(rejection, max_chars=240)
allowed = (
@@ -344,7 +398,8 @@ async def complete_with_fallback(
provider,
safe_rejection,
)
- _record_chain_recovery(label)
+ if record_health:
+ _record_chain_recovery(label)
return agg, provider
# If every later provider fails, their failure must not
# erase this valid bounded answer.
@@ -363,7 +418,8 @@ async def complete_with_fallback(
provider,
safe_rejection,
)
- _record_chain_recovery(label)
+ if record_health:
+ _record_chain_recovery(label)
return agg, provider
# A lone verdict this caller does not trust as
# final stays a retryable failure — one weak
@@ -417,7 +473,9 @@ async def complete_with_fallback(
failure_summaries.append(
f"{provider} unusable output: {safe_rejection}"
)
- _note_provider_failure(provider, safe_rejection)
+ _note_provider_failure(
+ provider, safe_rejection, scope=failure_scope
+ )
try:
telemetry.inc("wiki_provider_output_rejected")
except Exception: # noqa: BLE001 - telemetry cannot break fallback
@@ -427,7 +485,8 @@ async def complete_with_fallback(
exc_info=True,
)
continue
- _record_chain_recovery(label)
+ if record_health:
+ _record_chain_recovery(label)
return agg, provider
except TimeoutError:
log.warning(
@@ -437,7 +496,7 @@ async def complete_with_fallback(
timeout_s,
)
failure_summaries.append(f"{provider} timeout ({timeout_s:.1f}s)")
- _note_provider_failure(provider, "timeout")
+ _note_provider_failure(provider, "timeout", scope=failure_scope)
continue
except Exception as exc: # noqa: BLE001 — try the next family, never dead-end on one
detail = _exception_summary(exc)
@@ -448,7 +507,7 @@ async def complete_with_fallback(
detail,
)
failure_summaries.append(f"{provider} {detail}")
- _note_provider_failure(provider, detail)
+ _note_provider_failure(provider, detail, scope=failure_scope)
continue
if allowed_rejection_fallback is not None:
@@ -462,7 +521,8 @@ async def complete_with_fallback(
provider,
safe_rejection,
)
- _record_chain_recovery(label)
+ if record_health:
+ _record_chain_recovery(label)
return agg, provider
# A lone content verdict this caller does not trust as final: the
# chain ends as a retryable failure instead of terminal proof.
@@ -491,29 +551,41 @@ async def complete_with_fallback(
)
return None
- log.error(
- "%s: ALL %d wiki provider(s) failed or returned unusable output — "
- "nothing was written. Check provider health and structured-output logs.",
- label,
- len(chain),
- )
+ if shared_pipeline_failure:
+ log.error(
+ "%s: the shared response pipeline failed — nothing was written. "
+ "Provider health was left unchanged.",
+ label,
+ )
+ else:
+ log.error(
+ "%s: ALL %d wiki provider(s) failed or returned unusable output — "
+ "nothing was written. Check provider health and structured-output logs.",
+ label,
+ len(chain),
+ )
try:
- telemetry.inc("wiki_all_providers_failed")
+ telemetry.inc(
+ "wiki_provider_pipeline_failed"
+ if shared_pipeline_failure
+ else "wiki_all_providers_failed"
+ )
except Exception: # noqa: BLE001 — telemetry must never break the pipeline
log.debug("%s: telemetry inc failed", label, exc_info=True)
- try:
- from jarvis.memory.wiki.health import health
-
- health.record_chain_failure(
- safe_preview(
- "; ".join(failure_summaries)
- if failure_summaries
- else f"{label}: empty provider chain",
- max_chars=800,
+ if record_health:
+ try:
+ from jarvis.memory.wiki.health import health
+
+ health.record_chain_failure(
+ safe_preview(
+ "; ".join(failure_summaries)
+ if failure_summaries
+ else f"{label}: empty provider chain",
+ max_chars=800,
+ )
)
- )
- except Exception: # noqa: BLE001 — health recording must never break the pipeline
- log.debug("%s: health record_chain_failure failed", label, exc_info=True)
+ except Exception: # noqa: BLE001 — health recording must never break the pipeline
+ log.debug("%s: health record_chain_failure failed", label, exc_info=True)
return None
diff --git a/jarvis/ultrawiki/media_enrich.py b/jarvis/ultrawiki/media_enrich.py
index 9a02f30386..8a1ef9ca6c 100644
--- a/jarvis/ultrawiki/media_enrich.py
+++ b/jarvis/ultrawiki/media_enrich.py
@@ -353,7 +353,12 @@ def vision_chain(cfg: Any, registry: Any) -> list[tuple[str, str | None]]:
available=available,
credential_ready=credential_ready_wiki_providers(available=available, config=cfg),
)
- return [(name, model) for name, model in chain if _can_see(registry, name)]
+ seeing: list[tuple[str, str | None]] = []
+ for name, model in chain:
+ supported, vision_model = _vision_model(registry, name, model)
+ if supported:
+ seeing.append((name, vision_model))
+ return seeing
def _can_see(registry: Any, name: str) -> bool:
@@ -365,6 +370,32 @@ def _can_see(registry: Any, name: str) -> bool:
return bool(getattr(provider_class, "supports_vision", False))
+def _vision_model(registry: Any, name: str, model: str | None) -> tuple[bool, str | None]:
+ """Return a seeing model, rescuing a known-blind gateway default.
+
+ Provider capability is the first gate. When the cached catalog additionally
+ knows that this exact model is text-only, use the provider's fastest seeing
+ sibling. Unknown modality stays fail-open because direct provider catalogs
+ commonly omit it; a known-blind model with no sibling is excluded.
+ """
+ if not _can_see(registry, name):
+ return False, None
+ if not model:
+ return True, model
+ try:
+ from jarvis.brain.model_catalog import ( # noqa: PLC0415 — lazy (AP-26)
+ model_capabilities,
+ pick_fast_vision_model,
+ )
+
+ if model_capabilities(name, model)["vision"] is False:
+ sibling = pick_fast_vision_model(name)
+ return sibling is not None, sibling
+ except Exception: # noqa: BLE001 — missing catalog keeps class capability
+ log.debug("UltraWiki vision-model probe failed for %s", name, exc_info=True)
+ return True, model
+
+
async def describe_image(
data: bytes,
*,
@@ -401,6 +432,7 @@ async def describe_image(
)
)
+ from jarvis.brain.streaming import aggregate # noqa: PLC0415 — lazy (AP-26)
from jarvis.core.protocols import ( # noqa: PLC0415 — lazy (AP-26)
BrainMessage,
BrainRequest,
@@ -437,8 +469,13 @@ async def describe_image(
request=request,
timeout_s=timeout_s,
label="UltraWikiImageDescriber",
- aggregate=_aggregate,
+ aggregate=aggregate,
validate=_validate_description,
+ # Optional media enrichment has its own pause reason. It must neither
+ # paint/clear the normal Markdown Wiki's global health strip nor demote
+ # a provider for text work after a modality-specific image failure.
+ record_health=False,
+ failure_scope="ultrawiki-media",
)
if result is None:
return EnrichResult(reason="no provider that can read images returned a usable description")
@@ -460,23 +497,7 @@ async def describe_image(
)
-def _aggregate(chunks: Any) -> Any:
- """Collapse a provider's stream into one object carrying ``.text``."""
-
- @dataclass(slots=True)
- class _Aggregated:
- text: str
-
- if isinstance(chunks, str):
- return _Aggregated(text=chunks)
- parts: list[str] = []
- for chunk in chunks or ():
- piece = getattr(chunk, "text", None)
- parts.append(piece if isinstance(piece, str) else str(chunk))
- return _Aggregated(text="".join(parts))
-
-
-def _validate_description(aggregated: Any) -> bool:
+def _validate_description(aggregated: Any) -> str | None:
"""Reject a non-answer so the chain moves on to the next provider.
The ``NO_IMAGE_RECEIVED`` check is the load-bearing one: it is how a
@@ -485,8 +506,10 @@ def _validate_description(aggregated: Any) -> bool:
"""
text = _clean(str(getattr(aggregated, "text", "") or ""))
if not text or len(text) < 15:
- return False
- return CANNOT_SEE_MARKER not in text.upper()
+ return "empty or trivial image description"
+ if CANNOT_SEE_MARKER in text.upper():
+ return "provider reported that no image reached it"
+ return None
def _clean(text: str) -> str:
diff --git a/tests/unit/memory/wiki/test_provider_chain.py b/tests/unit/memory/wiki/test_provider_chain.py
index c26e2870c6..b7019a1b6a 100644
--- a/tests/unit/memory/wiki/test_provider_chain.py
+++ b/tests/unit/memory/wiki/test_provider_chain.py
@@ -271,6 +271,125 @@ async def test_first_provider_success_does_not_try_others():
assert reg.tried == ["gemini"] # no needless fallback calls
+async def test_synchronous_aggregation_fault_stops_after_one_provider(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ """A caller-owned stream adapter bug is not N broken provider families."""
+ from jarvis.memory.wiki import health as health_module
+ from jarvis.memory.wiki import provider_chain as pc
+ from jarvis.memory.wiki.health import WikiHealth
+
+ isolated_health = WikiHealth()
+ monkeypatch.setattr(health_module, "health", isolated_health)
+ reg = _FakeRegistry(fail_providers=set())
+
+ def _broken_adapter(_stream: Any) -> Any:
+ raise TypeError("async_generator object is not iterable")
+
+ result = await complete_with_fallback(
+ registry=reg,
+ chain=[("openrouter", None), ("gemini", None)],
+ request=object(),
+ timeout_s=5.0,
+ label="ImageDescriber",
+ aggregate=_broken_adapter,
+ )
+
+ assert result is None
+ assert reg.tried == ["openrouter"]
+ assert not pc._in_cooldown("openrouter")
+ detail = isolated_health.snapshot()["last_chain_failure"]["detail"]
+ assert detail == "ImageDescriber aggregation setup failed: TypeError"
+
+
+async def test_validator_fault_stops_after_one_provider_without_cooling_it(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ from jarvis.memory.wiki import provider_chain as pc
+
+ reg = _FakeRegistry(fail_providers=set())
+
+ def _broken_validator(_agg: Any) -> str | None:
+ raise TypeError("validator contract bug")
+
+ result = await complete_with_fallback(
+ registry=reg,
+ chain=[("openrouter", None), ("gemini", None)],
+ request=object(),
+ timeout_s=5.0,
+ label="ImageDescriber",
+ aggregate=_aggregate,
+ validate=_broken_validator,
+ )
+
+ assert result is None
+ assert reg.tried == ["openrouter"]
+ assert not pc._in_cooldown("openrouter")
+
+
+async def test_boolean_validator_contract_is_rejected_as_a_shared_fault() -> None:
+ """The old media validator returned bool, inverting success and failure."""
+ reg = _FakeRegistry(fail_providers=set())
+
+ result = await complete_with_fallback(
+ registry=reg,
+ chain=[("openrouter", None), ("gemini", None)],
+ request=object(),
+ timeout_s=5.0,
+ label="ImageDescriber",
+ aggregate=_aggregate,
+ validate=lambda _agg: False, # type: ignore[arg-type] - broken legacy contract
+ )
+
+ assert result is None
+ assert reg.tried == ["openrouter"]
+
+
+async def test_optional_lane_neither_sets_nor_clears_normal_wiki_health(
+ monkeypatch: pytest.MonkeyPatch,
+) -> None:
+ from jarvis.memory.wiki import health as health_module
+ from jarvis.memory.wiki.health import WikiHealth
+
+ isolated_health = WikiHealth()
+ isolated_health.record_chain_failure("normal wiki capture is unavailable")
+ monkeypatch.setattr(health_module, "health", isolated_health)
+
+ success = await complete_with_fallback(
+ registry=_FakeRegistry(fail_providers=set()),
+ chain=[("gemini", None)],
+ request=object(),
+ timeout_s=5.0,
+ label="OptionalMedia",
+ aggregate=_aggregate,
+ record_health=False,
+ failure_scope="optional-media",
+ )
+ assert success is not None
+ assert (
+ isolated_health.snapshot()["last_chain_failure"]["detail"]
+ == "normal wiki capture is unavailable"
+ )
+
+ isolated_health.record_chain_success()
+ failure = await complete_with_fallback(
+ registry=_FakeRegistry(fail_providers={"gemini"}),
+ chain=[("gemini", None)],
+ request=object(),
+ timeout_s=5.0,
+ label="OptionalMedia",
+ aggregate=_aggregate,
+ record_health=False,
+ failure_scope="optional-media",
+ )
+ assert failure is None
+ assert isolated_health.snapshot()["last_chain_failure"] is None
+ from jarvis.memory.wiki import provider_chain as pc
+
+ assert not pc._in_cooldown("gemini")
+ assert pc._in_cooldown("gemini", scope="optional-media")
+
+
class _TextBrain:
def __init__(self, text: str) -> None:
self._text = text
diff --git a/tests/unit/ultrawiki/test_media_enrich.py b/tests/unit/ultrawiki/test_media_enrich.py
index 72f432ce72..b6f8804b62 100644
--- a/tests/unit/ultrawiki/test_media_enrich.py
+++ b/tests/unit/ultrawiki/test_media_enrich.py
@@ -45,6 +45,44 @@ class _FakeRegistry:
return _FakeClass(self._providers[name])
+class _StreamingBrain:
+ def __init__(self, text: str = "", *, fail: bool = False) -> None:
+ self._text = text
+ self._fail = fail
+
+ async def complete(self, request: Any): # noqa: ARG002
+ from jarvis.core.protocols import BrainDelta
+
+ if self._fail:
+ raise RuntimeError("provider stream failed")
+ yield BrainDelta(content=self._text)
+ yield BrainDelta(finish_reason="stop")
+
+
+class _StreamingRegistry(_FakeRegistry):
+ def __init__(self, responses: dict[str, str | Exception]) -> None:
+ super().__init__({name: True for name in responses})
+ self._responses = responses
+ self.tried: list[str] = []
+
+ def instantiate(self, name: str, **kwargs: Any) -> Any: # noqa: ARG002
+ self.tried.append(name)
+ response = self._responses[name]
+ if isinstance(response, Exception):
+ return _StreamingBrain(fail=True)
+ return _StreamingBrain(response)
+
+
+async def _aggregate_text(kwargs: dict[str, Any], text: str) -> Any:
+ """Feed text through the same async ``BrainDelta`` stream as live brains."""
+ from jarvis.core.protocols import BrainDelta
+
+ async def _stream():
+ yield BrainDelta(content=text)
+
+ return await kwargs["aggregate"](_stream())
+
+
class _Cfg:
class ultrawiki: # noqa: N801 — mirrors the config attribute path
distill_provider = ""
@@ -90,6 +128,45 @@ def test_a_provider_that_will_not_load_is_treated_as_blind(all_credential_ready)
assert [name for name, _ in vision_chain(_Cfg(), registry)] == ["seeing"]
+def test_known_blind_model_is_swapped_for_a_seeing_sibling(
+ all_credential_ready, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ from jarvis.brain import model_catalog
+
+ monkeypatch.setattr(
+ model_catalog,
+ "model_capabilities",
+ lambda provider, model: {"vision": provider == "seeing" and model != "text-only"},
+ )
+ monkeypatch.setattr(
+ model_catalog, "pick_fast_vision_model", lambda provider: f"{provider}-vision"
+ )
+ import jarvis.memory.wiki.curator_llm as curator_mod
+
+ monkeypatch.setattr(curator_mod, "_cheap_model_for", lambda provider: "text-only")
+
+ registry = _FakeRegistry({"seeing": True})
+ assert vision_chain(_Cfg(), registry) == [("seeing", "seeing-vision")]
+
+
+def test_known_blind_model_without_a_seeing_sibling_is_excluded(
+ all_credential_ready, monkeypatch: pytest.MonkeyPatch
+) -> None:
+ from jarvis.brain import model_catalog
+
+ monkeypatch.setattr(
+ model_catalog,
+ "model_capabilities",
+ lambda _provider, _model: {"vision": False},
+ )
+ monkeypatch.setattr(model_catalog, "pick_fast_vision_model", lambda _provider: None)
+ import jarvis.memory.wiki.curator_llm as curator_mod
+
+ monkeypatch.setattr(curator_mod, "_cheap_model_for", lambda _provider: "text-only")
+
+ assert vision_chain(_Cfg(), _FakeRegistry({"seeing": True})) == []
+
+
async def test_no_seeing_provider_means_an_honest_reason_not_a_guess(
all_credential_ready,
):
@@ -122,10 +199,9 @@ async def test_a_model_that_admits_it_saw_no_image_is_rejected(
# Mirror the real helper: run validate(), and report failure when no
# attempt passes it.
validate = kwargs["validate"]
- aggregate = kwargs["aggregate"]
seen.append(kwargs["request"])
- answer = aggregate(f"{CANNOT_SEE_MARKER}")
- return None if not validate(answer) else (answer, "seeing")
+ answer = await _aggregate_text(kwargs, CANNOT_SEE_MARKER)
+ return None if validate(answer) else (answer, "seeing")
import jarvis.memory.wiki.provider_chain as chain_mod
@@ -140,9 +216,9 @@ async def test_a_model_that_admits_it_saw_no_image_is_rejected(
async def test_an_empty_or_trivial_answer_is_rejected(all_credential_ready, monkeypatch):
async def _fake_complete(**kwargs: Any) -> Any:
- validate, aggregate = kwargs["validate"], kwargs["aggregate"]
- answer = aggregate("ok")
- return None if not validate(answer) else (answer, "seeing")
+ validate = kwargs["validate"]
+ answer = await _aggregate_text(kwargs, "ok")
+ return None if validate(answer) else (answer, "seeing")
import jarvis.memory.wiki.provider_chain as chain_mod
@@ -157,12 +233,12 @@ async def test_a_real_description_comes_back_with_its_provider(
all_credential_ready, monkeypatch
):
async def _fake_complete(**kwargs: Any) -> Any:
- aggregate = kwargs["aggregate"]
- answer = aggregate(
+ answer = await _aggregate_text(
+ kwargs,
"A photo of two people on a beach at sunset, holding surfboards.\n"
"Text: Malibu 2019"
)
- assert kwargs["validate"](answer)
+ assert kwargs["validate"](answer) is None
return answer, "seeing"
import jarvis.memory.wiki.provider_chain as chain_mod
@@ -176,6 +252,25 @@ async def test_a_real_description_comes_back_with_its_provider(
assert result.provider == "seeing"
+async def test_live_chain_consumes_the_async_provider_stream(
+ all_credential_ready,
+) -> None:
+ """Regression for the live six-provider ``TypeError`` failure.
+
+ The media adapter used a synchronous ``for`` loop over the providers'
+ ``AsyncIterator[BrainDelta]``. Mocking the fallback helper hid that contract
+ mismatch, so this test deliberately crosses the real helper boundary.
+ """
+ registry = _StreamingRegistry({"seeing": "A photograph of a mountain range at dawn."})
+
+ result = await describe_image(PNG, filename="peak.png", cfg=_Cfg(), registry=registry)
+
+ assert result.ok is True
+ assert result.provider == "seeing"
+ assert "mountain range" in result.text
+ assert registry.tried == ["seeing"]
+
+
async def test_the_image_actually_reaches_the_request(all_credential_ready, monkeypatch):
"""A request without the image attached would be the silent version of the
same bug: the model answers about nothing and sounds fine."""
@@ -183,7 +278,7 @@ async def test_the_image_actually_reaches_the_request(all_credential_ready, monk
async def _fake_complete(**kwargs: Any) -> Any:
captured["request"] = kwargs["request"]
- answer = kwargs["aggregate"]("A photograph of a mountain range at dawn.")
+ answer = await _aggregate_text(kwargs, "A photograph of a mountain range at dawn.")
return answer, "seeing"
import jarvis.memory.wiki.provider_chain as chain_mod
@@ -371,10 +466,11 @@ class TestPictureText:
lines = "\n".join(f"Row {n}: telescope maintenance" for n in range(40))
async def _fake_complete(**kwargs: Any) -> Any:
- answer = kwargs["aggregate"](
+ answer = await _aggregate_text(
+ kwargs,
f"TEXT:\n{lines}\n\nDESCRIPTION:\nA screenshot of a table."
)
- assert kwargs["validate"](answer)
+ assert kwargs["validate"](answer) is None
return answer, "seeing"
import jarvis.memory.wiki.provider_chain as chain_mod
@@ -393,8 +489,8 @@ class TestPictureText:
"""The invented-photo guard must survive the new answer shape."""
async def _fake_complete(**kwargs: Any) -> Any:
- answer = kwargs["aggregate"](f"TEXT:\n{CANNOT_SEE_MARKER}")
- assert not kwargs["validate"](answer)
+ answer = await _aggregate_text(kwargs, f"TEXT:\n{CANNOT_SEE_MARKER}")
+ assert kwargs["validate"](answer)
return None
import jarvis.memory.wiki.provider_chain as chain_mod