Skip to content

fix(memory): don't download a model for profile inference unasked - #7270

Merged
kovtcharov-amd merged 5 commits into
amd:mainfrom
kovtcharov:kalin/rc18-memory-infer-no-download
Nov 12, 2026
Merged

kovtcharov-amd merged 5 commits into
amd:mainfrom
kovtcharov:kalin/rc18-memory-infer-no-download

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

Memory > Run Inference on a PC set up with a cloud model used to download
and load the local Gemma (5.6 GB) with no question and no progress, behind a
log line that only said it was calling the local LLM. It now stops with a
message that the local model isn't downloaded and where in Settings to
download it.

Profile inference runs only on the default local chat model; the route
checked that the model is local but not that it is on disk, and Lemonade
pulls a missing model on first use. The route now reads Lemonade's catalog
and refuses when the model isn't listed as downloaded, and an unreadable
catalog refuses as before.

Closes #7218

Closes #7218

Test plan

  • python -m pytest tests/unit/test_memory_router.py (3 new tests fail on main)
  • Rebuilt app on a fresh cloud-only profile: Memory > Run Inference says the model is not downloaded and where to get it, and the model server log shows no load

Memory > Run Inference on a PC set up with a cloud model used to download
and load the local Gemma (5.6 GB) with no question and no progress, behind a
log line that only said it was calling the local LLM. It now stops with a
message that the local model isn't downloaded and where in Settings to
download it.

Profile inference runs only on the default local chat model; the route
checked that the model is local but not that it is on disk, and Lemonade
pulls a missing model on first use. The route now reads Lemonade's catalog
and refuses when the model isn't listed as downloaded, and an unreadable
catalog refuses as before.

Closes amd#7218
@github-actions github-actions Bot added documentation Documentation changes tests Test changes labels Nov 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

Memory › Run Inference no longer downloads the 5.6 GB local model without asking. When the default local model isn't on disk, it now stops with a message saying where in Settings to download it. The fix is narrow and correct, and the tests cover the three cases: not listed, listed but not downloaded, and catalog unreadable.

  • Still to do before merge: tick the manual test-plan item (fresh cloud-only profile, Run Inference refuses, and the model server log shows no load), or attach the route's SSE output. Unit tests show the logic works, but they don't show the screen.
  • Small wording fix: if the download check can't read Lemonade's model list, the user is told GAIA "couldn't confirm the model is a local one". In that case the real question was whether the model is downloaded.

Real-world evidence

N/A: no evidence bundle was produced for this run. The verdict rests on static review alone. I couldn't run the unit tests here because pytest isn't installed on this runner. The Agent UI surface (Memory › Run Inference) has not been exercised, and the PR's own manual test-plan item is still unchecked.

🔍 Technical details

Issues

🟡 No real-world evidence for a UI-backed route (PR description): the only end-to-end item in the test plan is unchecked. Route-level evidence would be enough for merge-time CI: a capture of GET /api/memory/stream-inference on a PC without the model, showing the error event and no Calling local LLM line. The screenshot can follow.

🟢 Catalog-failure message names the wrong check (src/gaia/ui/routers/memory.py:1553-1566): _downloaded_on_this_pc raising LemonadeClientError lands in the existing handler. That handler says "GAIA couldn't confirm that '{model}' is one", meaning a local model. For a MODELS id, _runs_on_this_pc returns True with no network call, so this branch is now usually reached through the download check. A neutral wording covers both cases:

                            "Profile inference runs only on a local model, and "
                            f"GAIA couldn't check '{model}' on this PC: Lemonade's "
                            "model list didn't load. Check that Lemonade is running "
                            f"in Settings > Setup, then try again (id={cid})."

The test asserts only "couldn't confirm", so it would need the matching tweak.

🟢 Redundant shape check (memory.py:1268-1273): LemonadeClient.list_models already calls _check_model_list_shape, which raises LemonadeClientError for anything but {"data": [dict, ...]}, so the second isinstance guard can't fire. It's harmless, but you can drop it.

Checked, not an issue

  • The PR avoids the existing LemonadeClient.check_model_available, and rightly so: it swallows LemonadeClientError and returns False. That would turn a Lemonade outage into "not downloaded" instead of the actionable outage message.
  • _model_ids_match handles the user. prefix, so a registered model listed under its stripped id still counts as downloaded.
  • The docs change in agent-ui.mdx matches the new behaviour. No other doc describes this route's refusal cases.
  • A cloud default_model still hits the not local branch first, because local and … short-circuits and skips the catalog call.

Strengths

  • Fails loudly in every branch. Nothing falls back to downloading anyway, and the new refusal names the exact Settings path.
  • The tests drive the real _downloaded_on_this_pc through a patched list_models, assert show_all=True, and check that the LLM client is never created. They test the actual contract rather than mocking the helper away.

…ails

The catalog failure is now usually reached through the download check, so
"couldn't confirm it is a local model" named the wrong question. Also drop
a shape check list_models already makes.
@kovtcharov

Copy link
Copy Markdown
Contributor Author

When Lemonade's model list can't be read, the message now says GAIA "couldn't check '' on this PC", which fits both the local-model and the download check. The three tests that read that message assert the new wording and failed before the change.

  • Dropped the second shape check in the download helper: list_models already refuses anything that isn't a list of model objects.
  • Not done: the manual Run Inference check on a fresh cloud-only profile. It needs the rebuilt app against a real model server, which I couldn't run here, so that item stays unticked for a maintainer.

Merged current main; the memory router tests pass (208).

…rcuit

A registered model Lemonade lists under its stripped id must still count
as downloaded, another downloaded model must not, and a cloud default must
be refused before the catalog is read.
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Nov 12, 2026
Merged via the queue into amd:main with commit 85c29bb Nov 12, 2026
39 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/rc18-memory-infer-no-download branch November 12, 2026 07:23
kovtcharov added a commit to kovtcharov/gaia that referenced this pull request Nov 12, 2026
Both fixes are on main now, so the memory-inference and warm-up cells pass
and their expected-failure lines go, as the strict marker requires. The two
scheduled-run cells (amd#7329) are the ones left.
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Nov 12, 2026
…d#7331)

In rc18 a cloud-only user had a 5 GB local model downloaded and loaded
without being asked: by the start-up warm-up, by Memory > Run Inference,
and by a scheduled run. Each bug fired only from one starting state, and
every existing test started from a PC that was already set up, with the
client mocked. This adds a matrix that crosses five starting states with
three entry points, runs each against the installer journeys' stand-in
Lemonade over real HTTP, and asserts what actually reached that server.

A new starting state or entry point is one row; every combination is
then covered, and a combination with no rule is an error.

| | start-up warm-up | Memory > Run Inference | scheduled run |
|---|---|---|---|
| cloud model as `default_model` | ✅ | ✅ | ✅ |
| cloud model picked in the app | ✅ | ✅ (amd#7270) | ❌ **new: amd#7329** |
| cloud model as Custom model ID | ✅ (amd#7271) | ✅ | ❌ **new: amd#7329** |
| empty cache | ✅ | ✅ (amd#7270) | not asserted |
| local model on disk (control) | ✅ | ✅ | ✅ |

The two ❌ cells are strict expected failures naming the issue, so the
fix has to delete its line. Three more cells failed when this PR opened
(amd#7217, amd#7218); their fixes, amd#7270 and amd#7271, merged since, the strict
markers tripped as designed, and those lines are gone.

**New bug it found:** amd#7184 made `gaia schedule run` honour
`default_model`, but a cloud model picked in the desktop app is saved
elsewhere, so a scheduled run for that user still loads (and downloads)
local Gemma. Filed as amd#7329.

## Test plan

- [ ] `python -m pytest tests/unit/test_starting_state_matrix.py -q`
reports 14 passed, 2 xfailed
- [ ] Delete a line from `KNOWN_BUGS` and the failure prints the
requests the server saw, ending in `POST /api/v1/load
Gemma-4-E4B-it-GGUF`
- [ ] Runs in the unit job; the warm-up column needs the flagship
package, so it skips there and runs in `test_gaia_agent.yml`, which now
names this file

<details>
<summary>🔍 Technical details</summary>

- `tests/fixtures/fake_lemonade.py` starts
`installer/headless/fake_model_server.py` (the server the setup and
installer journeys already use) and reads its request log into `pulls`,
`loads`, `chats` and `downloads`. No second fake server. A load or chat
asked of a model that is not downloaded counts as a download, because
real Lemonade fetches it by itself.
- The matrix pins installed memory to 128 GB, because the warm-up is
skipped on a small PC and a CI runner would hide the bug, and stubs the
PC scan so profile inference never reads the machine it runs on.
- Not covered here: what the setup and model screens *say* from these
states (F1, F6, F43). Those are assertions on API payloads, not on
server requests.
</details>

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memory: Run Inference silently downloads and loads Gemma on a cloud-only setup

2 participants