Skip to content

fix(lemonade): never preload a local chat model for a cloud selection - #4757

Merged
kovtcharov-amd merged 1 commit into
amd:mainfrom
kovtcharov:kalin/no-local-preload-for-cloud
Oct 5, 2026
Merged

kovtcharov-amd merged 1 commit into
amd:mainfrom
kovtcharov:kalin/no-local-preload-for-cloud

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

Picking a Fireworks or AMD Gateway model in the Agent UI didn't stop the UI from loading the default local chat model (Gemma, several GB) onto an idle Lemonade at startup. Cloud-only users, often on low-memory laptops, paid for a resident model they never use. Now a process whose chat model is cloud never preloads a local one. Local-model users still get the idle-server preload from #839, now for the model they actually picked and at that model's own context window instead of ctx_size=0. The same fix covers gaia llm --model fireworks.… and a cloud default_model on the CLI.

Test plan

  • New tests fail on main and pass here (11): no /load for a cloud selection at UI boot, CLI, or via a cloud default_model; /load still sent with the right ctx_size for a local selection on an idle server, including after a cloud caller and on a cloud-default machine
  • pytest tests/unit — only failures are the same ones on clean main (profile golden prompts, pip/uv installer, PATH shims, run_python), plus a log-rotation test that flakes under xdist and passes alone
  • python util/lint.py --black --isort
  • Manual: set custom_model to fireworks.deepseek-v4p1-flash, start python -m gaia.ui.server against an idle Lemonade, and confirm no "Preloading …" line appears and no model is loaded
🔍 Technical details
  • Root cause: the UI's _check_lemonade boot job calls LemonadeManager.ensure_ready(min_context_size=0), which preloads _preload_model() (the machine default) whenever the server is idle. _load_model already skipped cloud models, but it ran after the preload.
  • ensure_ready(model=...) is the chat model the caller will run. Unset, it resolves to resolve_default_chat_model(). For a cloud model it confirms the server is up, skips the preload and context checks, and records _ready_for_cloud rather than _initialized, so a later local caller still gets the preload.
  • Call sites that now pass their model: UI boot, initialize_lemonade_for_agent (gaia llm, prompt/chat/talk), gaia init's context check (the local model it set up, even with a cloud default), and Agent.__init__ (otherwise a cloud default_model would skip the preload for an agent pinned to a local model). The per-chat pre-flight and the sidecar/stdio paths already skipped cloud models.
  • This reverses fix(models): size a Windows Strix Halo iGPU from its driver, so it gets Qwen3.6 #4671's "cloud default seeds Gemma" test case on purpose.
  • tests/test_lemonade_client.py was not run because it starts and talks to a real Lemonade server. The client is covered by the mocked tests/unit Lemonade suites.

Starting the Agent UI with a Fireworks model selected still loaded the
default local chat model (several GB, plus a vision projector) onto an idle
Lemonade, because the boot reachability check preloaded the machine default
without knowing which model the session uses.

LemonadeManager.ensure_ready now takes the chat model the caller will run.
A cloud model skips the idle preload and the local context check and logs
why at debug; a local model is preloaded as before, now the caller's own
model at its own window rather than the default at ctx_size=0. The UI boot,
the CLI (--model), gaia init's context check and the base Agent pass their
model through, so a cloud default_model no longer seeds Gemma and no longer
suppresses the preload for an agent pinned to a local model.
@github-actions github-actions Bot added documentation Documentation changes llm LLM backend changes cli CLI changes tests Test changes performance Performance-critical changes agents labels Oct 5, 2026
@github-actions

github-actions Bot commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

Cloud-only users no longer get a multi-GB local model loaded onto an idle Lemonade when the Agent UI, gaia llm --model fireworks.…, or a cloud default_model starts up. Local users still get the idle-server preload, and it now loads the model they actually picked at that model's own context window. The logic is sound, a later local caller still gets its preload after a cloud caller, and the tests cover each entry point.

Nothing blocks the merge. Two things are worth doing:

  • The manual check in the test plan is still open. Starting the UI with a Fireworks model against an idle Lemonade and confirming nothing loads is the proof this PR needs. Please run it, or paste the server log, before merging.
  • One code comment now says the opposite of what the code does. The UI boot comment still says the check "only checks reachability" and won't trigger model loads. For a local selection it now loads the model at its full window. A future reader could "fix" it back.

Real-world evidence

N/A: no evidence bundle was produced for this run, and pytest isn't installed on this review runner, so I couldn't run the new tests here. This verdict rests on static review alone. The UI-boot behaviour (no "Preloading …" line for a cloud selection) is only covered by the author's unchecked manual item.

🔍 Technical details

Issues

🟡 No real-world evidence for the UI boot path. The change targets what python -m gaia.ui.server does at startup, but the only proof is mocked unit tests. The PR's own manual item, a cloud custom_model on an idle Lemonade with no /load, is unchecked. Paste the boot log, or /api/v1/health showing loaded_models: [], into the PR.

🟢 Stale comment and docstring at UI boot (src/gaia/ui/server.py:263-270). With min_context_size=0, a local selection on an idle server is now preloaded at resolve_ctx_size(model=…), not at ctx 0. Both "check reachability only" and "don't trigger model reloads" are now wrong:

                min_context_size=0,  # No floor: never resize an already-loaded model

🟢 Comment in initialize_lemonade_for_agent (src/gaia/cli.py:~188). The comment above the changed call still says the idle server is seeded "with the default model". It is now seeded with the caller's model, falling back to the default.

🟢 Bigger preload at UI boot on large-model machines. On a 64 GB Strix Halo with Qwen3.6 as the default, boot now loads at its memory-sized window instead of ctx 0. This is intended: the first chat no longer reloads. Mentioning it in case boot-time RAM on that tier was being watched.

Checked and fine

  • _ready_for_cloud is kept separate from _initialized and is cleared in reset(), so a local caller after a cloud caller still gets the full init and preload.
  • _preload_model() is still the fallback in _try_preload_with_ctx and in the "run gaia init" error text, so it isn't dead code.
  • Agent.__init__ only reaches ensure_ready for a non-cloud model_id, so passing model=model_id lets the agent's own local model win over a cloud default_model.
  • The hub email wiring tests only assert min_context_size, so the new model= kwarg doesn't break them.
  • Removing fix(models): size a Windows Strix Halo iGPU from its driver, so it gets Qwen3.6 #4671's "cloud default seeds Gemma" case is a deliberate, documented reversal.

Strengths

  • The fix sits in one place (ensure_ready(model=…)), and each entry point passes in the model it will actually run, instead of each call site special-casing cloud models.
  • gaia init passes the local model it just set up, so a cloud default_model can't turn the context check into a "verified" message for a window nobody loaded. A test pins this.
  • The new tests reproduce the real starting state: an idle server with a cloud default in config.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 5, 2026
Merged via the queue into amd:main with commit dc6a8c5 Oct 5, 2026
@kovtcharov-amd
kovtcharov-amd deleted the kalin/no-local-preload-for-cloud branch October 5, 2026 21:06
@kovtcharov-amd kovtcharov-amd mentioned this pull request Oct 6, 2026
5 of 10 tasks
grtninja pushed a commit to grtninja/gaia that referenced this pull request Oct 6, 2026
# GAIA v0.25.0 Release Notes

## Breaking Changes

- **`gaia chat` runs the flagship GAIA agent**, the same agent as the
TUI and Agent UI, instead of the retired ChatAgent. `gaia chat -q "…"`
queries it once. (PR [amd#4520](amd#4520))
- **`gaia talk` transcribes and speaks through Lemonade** — it uses
Lemonade's Whisper and `kokoro-v1`, and stops with the reason if
Lemonade is down. The `[audio]` extra is gone; `pip install
amd-gaia[audio]` only warns. (PR
[amd#4665](amd#4665))
- **The Agent UI runs only the GAIA agent** — the Agent Hub home, agent
picker, and custom-agent export/import are removed from the UI. The CLI
and eval harness can still run other agents. (PR
[amd#4509](amd#4509))
- **The retired nomic embedder is removed** — memory saved with it is
re-embedded on first start. (PR
[amd#4489](amd#4489))
- **Indexed documents are re-indexed once** — the document cache is now
keyed on chunking settings, so the first query after upgrading rebuilds
it. (PR [amd#4624](amd#4624))
- **A skill that asks for more than its tier allows no longer loads** —
the permission ceiling is checked at every load, so a skill already on
disk that exceeds it is refused with the reason. (PR
[amd#4849](amd#4849))

## What's New

- **A larger local model where the GPU holds it** — `gaia init` picks
Qwen3.6-35B-A3B on a 64 GB+ Strix Halo or a 32 GB GPU and keeps
Gemma-4-E4B elsewhere, with each context window sized to available
memory. Qwen3.8 Flash Next is opt-in on 128 GB Strix Halo. (PRs
[amd#4479](amd#4479),
[amd#4670](amd#4670),
[amd#4671](amd#4671),
[amd#4658](amd#4658),
[amd#4655](amd#4655))
- **The Agent UI opens straight to a chat and sets itself up** — a fresh
install runs the same setup steps as the TUI in the window, with
provider, key and model settings, permission modes, and revocable
"always allow" grants. (PR
[amd#4509](amd#4509))
- **A much smaller install** — PyTorch, transformers and accelerate are
gone from the core, `[ui]` and `[talk]` installs; the desktop app's
Python environment drops from ~0.9 GB to ~0.1 GB on Windows. (PRs
[amd#4666](amd#4666),
[amd#4621](amd#4621),
[amd#4665](amd#4665))
- **One Windows installer for the desktop app and the terminal**, with a
GAIA Windows Terminal profile. (PRs
[amd#4720](amd#4720),
[amd#4707](amd#4707))
- **A "no" holds** — a declined action isn't retried through another
tool; the agent asks again with the exact command. The TUI gains
Shift+Tab permission modes. (PRs
[amd#4460](amd#4460),
[amd#4461](amd#4461))
- **Answers are checked against what the tools actually did** — the
agent looks at files you name before answering about them, and a short
plain-English note appears only when work isn't confirmed. (PRs
[amd#4532](amd#4532),
[amd#4501](amd#4501),
[amd#4508](amd#4508))
- **One shell session** — commands share a persistent shell, risky ones
ask instead of being refused, and "full access" is one setting
everywhere. (PR [amd#4408](amd#4408))
- **Memory surfaces what's relevant to each request, with its age**,
keeps what fixed a failure as a lesson for that workspace, and extracts
after the answer instead of before it. (PRs
[amd#4061](amd#4061),
[amd#4066](amd#4066),
[amd#4406](amd#4406))
- **`gaia.log` stays bounded** — it rotates at 10 MB with three backups
(`GAIA_LOG_MAX_MB`, `GAIA_LOG_BACKUPS`). (PRs
[amd#4668](amd#4668),
[amd#4760](amd#4760))
- **Child processes get a trimmed environment** — shell, MCP and skill
children no longer inherit GAIA's internal credentials; `GAIA_NO_DOTENV`
skips loading `.env`. (PRs
[amd#4635](amd#4635),
[amd#4659](amd#4659))
- **Every file tool checks the allowed-folders rule**, and paths inside
an inline shell script are checked one by one. (PRs
[amd#4656](amd#4656),
[amd#4758](amd#4758))

## Bug Fixes

A selection of the user-visible fixes; the full list is in the changelog
below.

- **Local Qwen models no longer loop on repeated tool calls** — they run
with their model card's sampling instead of near-greedy settings. (PR
[amd#4655](amd#4655))
- **Qwen3.6 runs on a Strix Halo with an older AMD driver** — it used to
crash on its first token, so `gaia init` failed; GAIA now turns off the
Vulkan path that crashes on those drivers only, and newer drivers keep
the faster path. (PR [amd#4674](amd#4674))
- **A long PDF no longer hangs or times out while indexing** — big
documents index in the background, and PDFs that only carry
owner-password restrictions now index. (PRs
[amd#4754](amd#4754),
[amd#4679](amd#4679),
[amd#4734](amd#4734))
- **Document answers cite the right document and page**, and every chunk
is embedded whole instead of its first 1,200 characters. (PRs
[amd#4688](amd#4688),
[amd#4723](amd#4723))
- **`gaia init` fails when model verification fails**, shows downloads
live, and no longer hangs while Lemonade hashes a large model. (PRs
[amd#4620](amd#4620),
[amd#4564](amd#4564),
[amd#4673](amd#4673))
- **`gaia init` adds a profile's extras without reinstalling GAIA**,
which failed on Windows while `gaia.exe` was running. (PR
[amd#4672](amd#4672))
- **Every SDK and CLI entry point starts GAIA's own Lemonade**, and
every call goes to the resolved URL with its API key. (PRs
[amd#4657](amd#4657),
[amd#4627](amd#4627))
- **Local chat stays cached across turns** — the system prompt is fixed
and side requests no longer evict the conversation. (PRs
[amd#4698](amd#4698),
[amd#4543](amd#4543))
- **A cloud model selection never preloads a local model**, and cloud
models no longer get llama.cpp-only fields. (PRs
[amd#4757](amd#4757),
[amd#4709](amd#4709))
- **The Agent UI stops claiming "100% local" while chat goes to a cloud
model**, and the chat header names the session's real model. (PRs
[amd#4711](amd#4711),
[amd#4550](amd#4550))
- **Enter can't approve a permission prompt**, and prompts wait 10
minutes before timing out. (PRs
[amd#4700](amd#4700),
[amd#4699](amd#4699))
- **Stopping a run keeps the turn and its steps visible.** (PR
[amd#4743](amd#4743))
- **A file edit keeps the file's line endings** — a one-line edit on
Windows used to rewrite every line ending, so a small change showed up
as the whole file changed. (PR
[amd#4864](amd#4864))
- **A broken agent install is reported as broken, not as missing** — the
error names both package versions and the real import error, and
suggests a reinstall that works. (PR
[amd#4588](amd#4588))
- **A meeting or document summary is never cut off mid-sentence** — a
thinking model used to spend the summary's output budget reasoning, so a
long meeting lost its second half. (PR
[amd#4827](amd#4827))
- **"What can you do?" gets an answer** instead of an attempt to
generate an image of the question. (PR
[amd#4809](amd#4809))
- **Writes and approved edits can't reach credential folders**
(`~/.ssh`, `~/.aws`, `~/.kube` and others), and shell option values and
script arguments get the same path check as plain paths. (PRs
[amd#4848](amd#4848),
[amd#4847](amd#4847))
- **`gaia connectors connect google --grant-agent installed:gaia`
works** — it used to fail with no sign-in link for the shipped agent; it
now asks for read-only Gmail and grants exactly that. (PR
[amd#4859](amd#4859))
- **A "no" to creating a folder also covers writing into it** — GAIA no
longer asks again to create the same folder a different way. (PR
[amd#4857](amd#4857))
- **`gaia skill import` runs the same checks as a hub install** — https
only, the audit, the permission ceiling, and an explicit opt-in for
skills that ship code. (PR
[amd#4849](amd#4849))
- **Memory off and private chats apply to scheduled and background runs
too.** (PRs [amd#4842](amd#4842),
[amd#4821](amd#4821))
- **Memory stops false apologies and reusing deleted values**, saves
"remember this" requests, and skips loading the embedder when memory is
off. (PRs [amd#4708](amd#4708),
[amd#4756](amd#4756))
- **A reply cut off by the token limit is continued** instead of ending
mid-sentence, and a tool call cut off at the output cap is retried
shorter. (PRs [amd#4054](amd#4054),
[amd#4556](amd#4556))
- **The TUI remembers the chosen model** across restarts and
agent-process restarts. (PRs
[amd#4497](amd#4497),
[amd#4710](amd#4710))
- **`gaia uninstall --purge` removes installer binaries, PATH edits and
daemon state.** (PR [amd#4413](amd#4413))

## Contributors

Thanks to the community members who contributed to this release:

- [@itomek](https://github.com/itomek) — the flagship's browser and tool
picker, one shell session, memory extraction off the answer path, stale
tool-result eviction, the TUI's sourced Fireworks rankings, and
`--purge` cleanup (PRs [amd#4407](amd#4407),
[amd#4408](amd#4408),
[amd#4406](amd#4406),
[amd#4465](amd#4465),
[amd#4414](amd#4414),
[amd#4413](amd#4413))
- [@mikemikimike](https://github.com/mikemikimike) — chained shell
command timeouts, bundled skills in frozen builds, and sidecar cleanup
reporting (PRs [amd#4463](amd#4463),
[amd#4467](amd#4467),
[amd#4419](amd#4419))
- [@Hashim1999164](https://github.com/Hashim1999164) — honoring
`GAIA_HOME` for cache, chat and index paths (PR
[amd#4381](amd#4381))
- [@krtadev](https://github.com/krtadev) — `~` expansion in file and
document tool paths (PR [amd#4576](amd#4576))
- [@aksh8b](https://github.com/aksh8b) — telling a broken agent install
apart from a missing one, with a reinstall hint that works (PR
[amd#4588](amd#4588))
- [@Dev-next-gen](https://github.com/Dev-next-gen) — numeric prerelease
ordering in the hub (PR [amd#4517](amd#4517))
- [@vianmangal](https://github.com/vianmangal) — recording denied tool
calls as unsuccessful in memory (PR
[amd#4412](amd#4412))
- [@GaetanVDB07](https://github.com/GaetanVDB07) — links to upstream
credential setup guides for connectors (PR
[amd#4669](amd#4669))
- [@rradjabi](https://github.com/rradjabi) — moving self-hosted CI jobs
to the xsj-dispatch runner pool (PR
[amd#4534](amd#4534))




## Also in this PR

- **Hub floors raised to core 0.25.0** — the chat agent imports the
allowed-folders check that only 0.25.0 ships (amd#4656), so
`gaia-agent-chat` goes to 0.2.0 with `amd-gaia>=0.25.0`, and the
flagship requires `amd-gaia>=0.25.0` and `gaia-agent-chat>=0.2.0`.
- **Two follow-ups held back until that floor could rise** —
`~/.gaia/logs/gaia-agent.log` now rotates like `gaia.log` (amd#4668), and
the chat agent's Python runners and Windows notification start their
children without GAIA's internal credentials (amd#4659).

The full changelog (300 commits) is in `docs/releases/v0.25.0.mdx`.

## Test plan

- [x] `util/validate_release_notes.py docs/releases/v0.25.0.mdx --tag
v0.25.0` passes; narrative is 590 words (cap 600)
- [x] `util/check_component_core_api.py --release-version 0.25.0` passes
- [x] `pytest tests/unit/test_docs_json_release.py
tests/unit/test_check_component_core_api.py
hub/agents/chat/python/tests/test_chat_dependency_floor.py
hub/agents/chat/python/tests/test_dependency_floor.py
hub/agents/gaia/python/tests/test_gen_binaries_lock.py` (72 passed)
- [x] `pytest hub/agents/gaia/python/tests/test_stdio.py` (91 passed,
incl. the new rotation test); `pytest
tests/unit/test_execute_python_file_cwd.py
tests/unit/test_run_python_tool.py` (42 passed)
- [ ] `mintlify validate` (docs CI job) — timed out locally, relying on
CI
- [x] Full flagship eval on main 9ce6598
(https://github.com/amd/gaia/actions/runs/37436249503): 181/308
scenarios pass vs 100/183 for the same categories in the baseline, 39
FAIL→PASS, 13 PASS→FAIL (two fixed in amd#4878, held until after rc1);
retrieval lane still finishing at merge time
- [ ] CI green

## Release checklist

- [ ] Publish `gaia-agent-chat` 0.2.0 only after core 0.25.0 is on PyPI
— it fails at import on an older core
- [ ] Build Installers on the merged SHA (pre-tag verification) before
pushing `v0.25.0`
- [ ] terminal-hub 0.25.0 published before the flagship npm release
consumes `binaries.lock.json`

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
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

agents cli CLI changes documentation Documentation changes llm LLM backend changes performance Performance-critical changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants