Repository navigation
fix(vlm): load the vision model once, at the right context, and surface load errors - #4290
Conversation
…ce load errors The first image extraction loaded the vision model at Lemonade's default context and then immediately reloaded it at the size GAIA requires: two cold loads, evicting the chat model when it is the same Gemma. The pre-load's 60 s timeout was shorter than a cold iGPU load, and any failure (timeout, OOM) was replaced with a generic "model is not available". A cached "loaded" flag meant an eviction mid-batch went unnoticed. The separate pre-load is gone. Each extraction request now asks LemonadeClient.chat_completions to do its context-aware load under the model-slot lease (auto_download follows auto_load), so the model loads once at the right size, the client's own load timeout applies, and the real load error reaches VLMExtractionError with its cause attached. Fixes amd#4215
Verdict: Approve with suggestionsThis removes the redundant pre-load in the vision client so a PDF page's first image loads the model once — at the context size GAIA requires, under the model-slot lease — instead of loading it twice and reporting any failure as a generic "model not available". The dead Two things worth a follow-up:
Smaller items (wrong default model named in a docstring, a stale code sample in the spec, and two pre-existing broken constructor calls in the integration script) are in the details below. Real-world evidenceN/A — no 🔍 Technical details🟡
|
…free box Both files this PR repairs still failed in the offline lane, so the "534 passed" claim held only on the author's machine. The memory test built its URL by interpolating a local-timezone stamp. At a negative UTC offset the "-" is URL-safe and it passes; on a UTC runner the "+00:00" decodes to a space, fromisoformat rejects it, and the endpoint correctly 422s. Passing the stamp through the client's params lets it percent-encode, and a second pinned +00:00 case means the test now catches this from any timezone rather than only from UTC. The TUI test set TERM to get color, but termenv treats any environment with CI set as "not a TTY" before it looks at TERM or the pty, so lipgloss dropped to the Ascii profile and rendered no escapes at all for format=ansi to return. CLICOLOR_FORCE is the documented override, and NO_COLOR outranks it, so both it and CLICOLOR are cleared. Also resolves the merge with main: amd#4290 removed only one of this file's three fallback_model uses, and VLMClient no longer takes that argument, so the deletion stands.
Nine test files that no CI lane runs had been failing for weeks without anyone seeing it. `tests/test_sdk.py` alone had 17 failures against APIs that were renamed or removed. This PR gets every one of them passing against current main, so amd#4205's follow-up can put them in a lane. Where a test covered something that no longer exists, it's deleted and the commit says why, rather than rebuilt. Overlaps (small, easy to resolve, all by the same author): - amd#4033 bumps the same schema-version assertion from 4 to 5. Whichever lands second takes its own number. - amd#4290 and amd#3122 edit `tests/test_vlm_integration.py`, which this PR deletes. That file returned booleans instead of asserting, so it could never fail, and it passed a constructor argument that no longer exists. ## Test plan - [x] Before, on `origin/main`: the repaired files fail offline (`test_sdk.py` 17, `test_multi_caller_equivalence.py` 2, `test_memory_integration.py` 1, `test_memory_api_integration.py` 1, `test_documents_router.py` 3, `test_tui_control_e2e.py` 6, `test_ui_email_scope_consent.py` 5, `test_lemonade_embedded_lifecycle.py` 1 on macOS) - [x] After, with homes isolated and Lemonade pointed at a dead port: the offline set passes. That's 534 passed and 12 skipped across the 23 files amd#4205 wires in, in a clean py3.12 venv with `-e ".[api,mcp]"` plus the unit job's test deps, with Go on PATH - [x] `tests/test_ui_email_scope_consent.py` passes inside the email unit lane's full pytest command (4971 passed), in a clean venv with `.[dev,api,publish,mcp]` and the email package installed - [x] `black --check`, `isort --check-only`, `flake8`, and `pylint --errors-only` are clean on every changed file <details> <summary>🔍 Technical details</summary> - `test_sdk.py`: `Agent.execute_tool` was never public; the replacement follows `docs/sdk/testing.mdx` (registry lookup). `openai_server` exposes a module-level `app`, not `create_app()`. `STATE_*` constants live on `Agent`. `_register_tools` is now the only abstract method. Removed the xfail `DatabaseMixin` block, since it ships as `gaia.database.mixin` and has its own wired tests. The MCP tests in this file need the `[mcp]` extra, which the lane installs. - `test_multi_caller_equivalence.py`: mutating `/api/*` calls need `X-Gaia-UI: 1` (`gaia.ui.security`), and `/api/connectors` returns `{"connectors": [...]}` keyed by `id`. - `test_memory_api_integration.py`: consolidation returns 503 until a chat session registers `_consolidate_fn`. That is intended behavior, not a side effect of the environment. Both branches are now pinned. - `test_documents_router.py`: the `failed_doc` fixture and one test uploaded without `mock_index_document`, so they indexed for real and needed Lemonade. - `test_tui_control_e2e.py`: a fresh pty is 0x0, so `resize` refused; runners leave `TERM` unset, so the ANSI screen had no escapes. - `test_ui_email_scope_consent.py`: `EmailTriageAgent` also declares `microsoft_work` now. The three deleted tests hit an in-process `/v1/email` mount that the UI dropped in the amd#1767 sidecar cutover; `tests/unit/test_email_sidecar_*` cover the forwarder. </details> Refs amd#4205 --------- Co-authored-by: Kalin Ovtcharov <[email protected]> Co-authored-by: Kalin Ovtcharov <[email protected]>
Before this change, the first image extraction loaded the vision model at Lemonade's default context and then reloaded it straight away at the size GAIA requires. That meant two cold loads, and it evicted the chat model when both are the same Gemma. The pre-load also gave up after 60 s, which is shorter than a cold iGPU load, and any failure (timeout, out of memory) turned into a generic "model is not available". Now each extraction loads the model once, at the right context, inside the request. The real load error reaches the caller, and a model evicted mid-batch reloads on the next page instead of failing.
The only overlap with open PRs is #3122, which edits a different line of
tests/test_vlm_integration.py.Test plan
main(5 failed) and pass with the fix:python -m pytest tests/unit/test_vlm_extraction_failures.py -q(15 passed)python -m pytest tests/unit/test_structured_vlm_extraction.py tests/unit/test_ingest_helpers.py tests/unit/test_lemonade_base_url_passthrough.py tests/unit/test_llm.py tests/unit/test_testing_utilities.py tests/unit/rag/ -q(all pass)black --check,isort --check-only, and the CI pylint command onsrc/gaia/llm src/gaia/vlm src/gaia/ragare clean/loadat the model's required ctxFixes #4215