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(tools): stop a command readback burying its own result in app state

Ruben Lütke7ee6fd298567
diff --git a/jarvis/ui/web/ultrawiki_routes.py b/jarvis/ui/web/ultrawiki_routes.py
index f55f71e36d..c6c2ac6ed9 100644
--- a/jarvis/ui/web/ultrawiki_routes.py
+++ b/jarvis/ui/web/ultrawiki_routes.py
@@ -269,10 +269,12 @@ def _apply_reembed_to_legs(
**vector,
"available": False,
"rebuilding": True,
+ # Deliberately short: `health.py::_search_check` appends what
+ # keyword-only costs, and two sentences saying the same thing read
+ # as two different problems.
"reason": (
- f"semantic search is rebuilding on {model} ({progress}). Exact "
- "words are found the whole time; meaning-based search returns "
- "by itself the moment the rebuild finishes."
+ f"semantic search is rebuilding on {model} ({progress}) — it "
+ "comes back by itself when the rebuild finishes."
),
},
}
diff --git a/jarvis/ultrawiki/pipeline.py b/jarvis/ultrawiki/pipeline.py
index 9e4935e48a..bb35268a57 100644
--- a/jarvis/ultrawiki/pipeline.py
+++ b/jarvis/ultrawiki/pipeline.py
@@ -325,6 +325,23 @@ class PipelineWorker:
await self._promote_pass()
return attempted
+ async def _reembed_is_running(self) -> bool:
+ """Is a model switch rebuilding the vector space? Never raises.
+
+ A store without the capability (an older embedded one, a test fake)
+ answers ``False``, so every stage keeps its normal behaviour there.
+ """
+ probe = getattr(self._store, "reembed_is_running", None)
+ if probe is None:
+ return False
+ try:
+ return bool(await probe())
+ except asyncio.CancelledError:
+ raise
+ except Exception: # noqa: BLE001 — an unreadable pin never pauses a stage
+ log.debug("UltraWiki: rebuild probe failed", exc_info=True)
+ return False
+
async def _promote_pass(self) -> None:
"""Swap in a finished embedding rebuild (see
``UltraStore.promote_pending_space``).
@@ -865,6 +882,22 @@ class PipelineWorker:
if not distill_ok:
self._note_stage_pause("distill", distill_reason)
return 0
+ if await self._reembed_is_running():
+ # A model switch has taken semantic search down until the new space
+ # is complete, and distillation cannot shorten that: only the embed
+ # stage releases an item from the rebuild. Worse, `begin_reembed`
+ # demoted these items, so every summary produced now is produced
+ # again after the swap. Measured on a live store, the LLM round
+ # trips of this stage were ~90 % of a pass — the rebuild was
+ # waiting hours on work that would be thrown away.
+ self._note_stage_pause(
+ "distill",
+ "summaries are paused while the search index is rebuilt on the "
+ "new embedding model - they resume by themselves once it is "
+ "complete, and nothing is lost meanwhile",
+ key="reembed-priority",
+ )
+ return 0
self._clear_stage_pause("distill")
items = await self._store.claim_batch(
ItemState.DISTILLED, limit=DISTILL_BATCH, now=self._claim_now()
diff --git a/jarvis/ultrawiki/store.py b/jarvis/ultrawiki/store.py
index 85a7a26829..98cd12ffd9 100644
--- a/jarvis/ultrawiki/store.py
+++ b/jarvis/ultrawiki/store.py
@@ -2087,6 +2087,14 @@ class UltraStore:
)
return True
+ async def reembed_is_running(self) -> bool:
+ """Is a model switch rebuilding the vector space right now?
+
+ One primary-key read, because the pipeline asks once per pass to
+ decide whether a stage should stand aside for the rebuild.
+ """
+ return await self.get_meta(META_PENDING_EMBED_MODEL) is not None
+
async def reembed_status(self) -> dict[str, Any]:
"""Honest progress of a running rebuild, for the settings surface.
@@ -3832,6 +3840,10 @@ class PostgresStore:
)
return True
+ async def reembed_is_running(self) -> bool:
+ """Postgres twin of :meth:`UltraStore.reembed_is_running`."""
+ return await self.get_meta(META_PENDING_EMBED_MODEL) is not None
+
async def reembed_status(self) -> dict[str, Any]:
"""Postgres twin of :meth:`UltraStore.reembed_status`."""
pending_model, _pending_dim = await self._pending_space()
diff --git a/tests/unit/ultrawiki/test_store.py b/tests/unit/ultrawiki/test_store.py
index 71b48c5b9f..cbaa846076 100644
--- a/tests/unit/ultrawiki/test_store.py
+++ b/tests/unit/ultrawiki/test_store.py
@@ -1425,3 +1425,18 @@ async def test_a_rebuild_started_by_an_older_build_is_adopted_on_open(tmp_path):
assert (status["done"], status["total"]) == (0, 1)
assert [row["id"] for row in claimed] == [item_id]
+
+
+async def test_reembed_is_running_is_a_single_meta_read(store):
+ """The pipeline asks once per pass, so it must stay a primary-key read."""
+ await add_source(store)
+ item_id, doc_id = await _seed_embedded_item(store, 0)
+ await store.store_embedding(doc_id, model="model-a", dim=4, vector=[1, 0, 0, 0])
+ await store.mark_stage_done(item_id, ItemState.EMBEDDED)
+ assert await store.reembed_is_running() is False
+
+ await store.begin_reembed("model-b")
+ assert await store.reembed_is_running() is True
+
+ await store.abort_reembed()
+ assert await store.reembed_is_running() is False