Repository navigation
fix(ui): an upload queued for the model isn't stopped as stuck, and Cancel reaches it - #5448
Conversation
…stuck Indexing stops after GAIA_INDEX_TIMEOUT seconds without progress. Since model-slot waits no longer have a cap, an upload queued behind a long chat for the embedder or vision model got no page or batch done for that long and was stopped as 'no progress'. Queue updates from the broker now count as progress while the document indexes.
An upload queued for the model slot ignored Cancel and the no-progress stop until it got the slot, then loaded the model and embedded a batch before stopping. The index now runs inside the broker's cancel scope, so the wait ends at once. RAG re-raises the cancelled wait past its broad handlers, as it does IndexingStopped, so a cached document's cache isn't taken for corrupt and deleted.
|
Verdict: Approve with suggestions An Agent UI upload that is only waiting in line for the model is no longer stopped as "made no progress", and Cancel now ends that wait right away instead of after a full model load and batch. The code is correct and small. I found no blocking issues. Both new handlers keep their cache, which matches how the existing stop path already works. Two small follow-ups, neither blocking:
Real-world evidenceN/A: no evidence bundle was produced for this run. This is an internal indexing change that only shows up in the Agent UI when uploads have to compete for the model, so it can't easily be exercised on a no-inference runner. The verdict rests on static review and the PR's three unit reproductions. I couldn't run them here because pytest isn't installed in this review environment. A later Agent UI check would close the gap: upload a large PDF during a long chat, then press Cancel. 🔍 Technical details🟢 Minor: a cancelled vision wait is logged as a page failure ( 🟢 Minor: docstring is out of date ( What I checked:
Strengths
|
…he page Cancel during a page's wait for the vision model was logged as an image extraction failure. VLMClient and the PDF/PPTX page handlers now let LeaseWaitCancelled through, and the indexing docstring says that queue updates count as progress.
|
Both suggestions are in. Cancel during a page's wait for the vision model now stops indexing instead of being logged as a failed page, and the docstring says queue updates count as progress. On the "what if the holder dies" question: the wait still ends. The broker takes back a lease whose holder stops renewing or passes its max hold time, and a daemon that goes silent ends the stream, so a queued upload is never kept alive forever by queue updates alone. 🔍 Technical details
|
Combines with amd#5448: indexing now uses its lease_cancel_scope and a non-raising queue listener; _stop_behind also unwraps a LeaseWaitCancelled, so a cancelled embedder wait is a stop rather than an embedder failure. The fake-broker tests duplicated amd#5448's and are replaced by tests against a real daemon: a queued upload outlives the timeout, Cancel leaves the queue without a second lease request, and a dead holder is reclaimed.
…amd#5452) An Agent UI upload queued for the embedder behind a long chat failed with "made no progress for 600 s", even though it was only waiting its turn for the model. amd#5448 made the broker's queue updates count as progress and let Cancel end that wait; this PR finishes the job. A Cancel during the embedder's wait is now logged as a stop rather than an embedder failure, and the fix is proven against a real daemon instead of a faked broker, including that a dead holder can't keep an upload waiting forever. ## Test plan - [x] `python -m pytest tests/unit/test_daemon_broker_queue.py -k upload tests/unit/rag/test_embedding_outage.py -q` (the three real-daemon tests fail with the amd#5448 wiring removed) - [x] `python -m pytest tests/unit/chat/ui tests/unit/rag tests/unit/agents/tools tests/unit/test_broker_wiring.py tests/unit/test_daemon_broker_queue.py tests/unit/test_vlm_extraction_failures.py -q`: 2733 passed - [x] `python util/lint.py --all` - [ ] With `gaia daemon` running, hold the model slot with a raw `POST /host/v1/models/lease` for longer than `GAIA_INDEX_TIMEOUT`, then upload a document in the Agent UI. It indexes once the slot is released, instead of failing with "made no progress". <details> <summary>🔍 Technical details</summary> - `gaia.rag.sdk._stop_behind` finds an `IndexingStopped` or `LeaseWaitCancelled` behind the client's wrapping (`LemonadeClientError`, then `EmbeddingUnavailableError`). `_load_embedder` and `_embed_batch` re-raise it. - `_index_document._do_index` raises `IndexingStopped` when the stop is set after `index_document` returns, which covers a stop absorbed along the way. The caller has already given up by then, so discarding that result changes nothing the user sees. - Real-daemon tests in `test_daemon_broker_queue.py`: a queued upload outlives an 0.8 s timeout while the holder lives; Cancel removes it from the broker's queue with exactly one lease request (no reattach retry); a granted lease that is never renewed is reclaimed and the upload indexes. - A daemon too old to stream its queue sends no updates, so a wait on one still counts against the timeout; the docstring says so. - Not LLM-affecting. </details> Co-authored-by: Kalin Ovtcharov <[email protected]>
Before: an Agent UI upload waiting in line for the model slot (the embedder load, or a vision model call) got no page or batch done, so after
GAIA_INDEX_TIMEOUT(10 min) it was stopped as "no progress", even though it was only queued behind a long chat. Cancel didn't reach it either: it waited for the slot, loaded the model, embedded a batch, and only then stopped. After: queue updates from the broker count as progress, and Cancel or the no-progress stop end the wait at once. A cancelled wait on a cached document keeps its cache.This is the #5339 × #5328 merge item, "whichever lands second wires
lease_wait_listener". It didn't land with either PR.Reproduced by
tests/unit/chat/ui/test_indexing_bounds.py::test_waiting_in_line_for_the_embedder_counts_as_progress,::test_cancel_reaches_an_index_waiting_in_line_for_the_modelandtests/unit/rag/test_indexing_stopped.py::test_a_cancelled_wait_for_the_model_keeps_the_cache_too; all three fail on main and pass here.Test plan
pytest tests/unit/chat/ui tests/unit/rag tests/unit/agents/tools tests/unit/test_broker_wiring.py: 2655 passedpython util/lint.py --black --isort --pylint --flake8 --imports --test-lanes🔍 Technical details
_index_document._do_indexrunsrag.index_documentinsidelease_wait_listener(_queue_update)andlease_cancel_scope(stop). Both are contextvars set on the indexing thread, which is where the embedder'sload_modeland the VLM calls take their leases. The listener only notes the time, since it runs on the waiting thread and must not block or raise.LeaseWaitCancelledfrom that scope becomesIndexingStopped. Inrag/sdk.py, both ofindex_document's broad handlers re-raise it, as they doIndexingStopped. Without that, the cache-hit path took it for a corrupt cache.