Skip to content

fix(lemonade): keep cloud providers across embedded restarts - #4469

Merged
kovtcharov-amd merged 1 commit into
amd:mainfrom
kovtcharov:kalin/embedded-lemonade-keep-cloud-providers
Sep 29, 2026
Merged

kovtcharov-amd merged 1 commit into
amd:mainfrom
kovtcharov:kalin/embedded-lemonade-keep-cloud-providers

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

Restarting GAIA's embedded Lemonade forgot the Fireworks / AMD Gateway provider a user had connected, so the next chat or eval failed with "The selected cloud model is unavailable (HTTP 404)". GAIA now keeps Lemonade's own settings when it rewrites the config on start, so a connected provider survives restarts.

Closes #4422

Test plan

  • pytest tests/unit/test_lemonade_embedded.py — 54 passed, 5 skipped. New tests: a pre-existing cloud_providers survives write_config(), and GAIA-owned keys are still updated.
  • Live on a Strix Halo with embedded Lemonade 2026.39.1: Fireworks provider installed → gaia lemonade embedded stop / start from this branch → cloud_providers still in config.json and GET /api/v1/models?show_all=true lists all 25 fireworks.* models (before: 0, and loads 404'd).

@github-actions github-actions Bot added llm LLM backend changes tests Test changes performance Performance-critical changes labels Sep 29, 2026
Restarting GAIA's embedded Lemonade erased every cloud provider installed
into it, so fireworks.* models 404'd until the provider was reinstalled.

write_config() now merges GAIA's keys over the existing config.json instead
of replacing the file, so keys Lemonade persists there (cloud_providers)
survive. An unreadable or non-object file is replaced with a warning naming
the path, matching how the state file is handled.
@kovtcharov-amd
kovtcharov-amd force-pushed the kalin/embedded-lemonade-keep-cloud-providers branch from 81eb7a9 to ed6b612 Compare September 29, 2026 16:04
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Sep 29, 2026
Merged via the queue into amd:main with commit f6a1d32 Sep 29, 2026
32 of 35 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/embedded-lemonade-keep-cloud-providers branch September 29, 2026 16:42
kovtcharov added a commit to kovtcharov/gaia that referenced this pull request Sep 29, 2026
…tarts (amd#4485)

A Fireworks key pasted into the TUI's `/provider` panel worked only
until that Lemonade stopped. Every later TUI, and every
embedded-Lemonade restart, came back with no key, so users re-pasted it.
Now a key that connects is kept in the OS credential store and handed
back to any Lemonade that lacks it: when a chat starts on a cloud model,
or when `/provider` opens. The same applies to an AMD gateway key set
from `/provider`. Pairs with amd#4469, which keeps the provider
*registration* across embedded restarts; this keeps the *key*.

- **Never overwrites a live key.** A key Lemonade already has, from
`LEMONADE_FIREWORKS_API_KEY` or a paste, wins. A key that discovers no
models is not kept, so a typo isn't replayed forever.
- **Ctrl+D forgets the kept copy too.** Where no credential store exists
(headless Linux), the panel says "this session only" and names
`LEMONADE_<PROVIDER>_API_KEY`.

## Test plan
- [ ] `python -m pytest tests/unit/test_cloud_keys.py
tests/unit/test_daemon_gateway_routes.py tests/unit/test_gateway.py`
- [ ] `cd tui && go test ./internal/ui/providers/ ./internal/ui/gateway/
./internal/daemon/`
- [ ] Paste a Fireworks key in `/provider` and pick a model; quit; `gaia
lemonade embedded stop && gaia lemonade embedded start` (with amd#4469);
relaunch `gaia tui` and chat on `fireworks.*` without re-entering the
key
- [ ] Ctrl+D in `/provider` → relaunch → the key is asked for again

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

- `gaia.llm.cloud_keys` keeps, recalls, forgets and replays per
provider. Fireworks uses slot `fireworks_api_key`, the one
`resolve_fireworks_api_key` already reads. AMD reuses `gateway:amd` and
`GatewayManager.ensure_authenticated`. Writes are read back, so a null
keyring backend fails loudly instead of "saving" nothing.
- New daemon routes:
`/daemon/v1/providers/{fireworks|amd}/{key,authenticate}`, guarded by
the daemon client token. The key is never logged or echoed back, and an
unusable store returns 503 with the remedy.
- `readiness._replay_gateway_token` becomes `_replay_cloud_key`,
covering every provider in `cloud_keys.PROVIDERS`.
- The gateway panel's private `daemonCall` moves to `daemon.Call`, so
both panels share one implementation.
- Live check against a separate `lemond` on its own port and config,
with a fake key in the real Windows credential store:

```
fresh lemond:          runtime_key_set False
kept in OS store:      True
after replay:          runtime_key_set True   (usable False — fake key discovers nothing)
after lemond restart:  runtime_key_set False
after second replay:   runtime_key_set True
forgot kept key:       True | still stored: False
```
The last unchecked item needs a real Fireworks key, which I didn't
handle.
</details>
kovtcharov added a commit to kovtcharov/gaia that referenced this pull request Sep 29, 2026
…amd#4497)

Before: a model picked in the TUI (Fireworks → DeepSeek V4.1 Flash, say)
was forgotten on quit. The next launch ran local Gemma with no notice,
and the header didn't name the model. After: the last provider + model
the agent confirmed is saved in `~/.gaia/config.json` and restored on
launch, and the header names the model from the moment the chat opens,
local included. If a restore doesn't take (key gone, model not listed,
agent down, or you stop it), GAIA says so in one line and opens the
provider picker. It never quietly runs another model. This is the third
piece after amd#4469 (provider registration kept) and amd#4485 (key kept): the
*selection*.

Closes amd#4490

## Test plan
- [ ] `cd tui && go vet ./... && go test ./...`
- [ ] `python -m pytest hub/agents/gaia/python/tests/test_stdio.py
tests/unit/test_cli_config.py`
- [ ] Fresh `GAIA_HOME` + `GAIA_CONFIG_DIR`: launch `gaia-tui`. The
header names the local model before any message. `/provider` → Fireworks
→ `deepseek-v4p1-flash`, chat once, quit, relaunch. Expect "Restored
your last model." `/model` should say `Currently running:
fireworks.deepseek-v4p1-flash`, and the gate should skip the local chat
load.
- [ ] Set `last_model` to a bogus `fireworks.*` id or an undownloaded
local id and relaunch. Expect one `Couldn't restore your last model, …`
line, the picker opens, and the saved value is untouched.

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

- **Storage:** `last_provider` / `last_model` are declared on
`GaiaConfig`, because `save()` writes declared fields only and a Python
`gaia config set` would otherwise drop them. Go writes them with the
same read-modify-write as `full_access` (the shared helper is
`writeConfigKeys`). A value is saved only when the agent's `/model` ping
matches the requested id and the turn ends in a `final`.
- **Restore:** one `/model <id>` turn sent as the chat opens, before
amd#4488's warm-up. The warm-up then runs on the restored model, and is
skipped if the restore fails. Anything typed before it, and a `--query`,
waits behind it. Every non-confirmed ending sets `startup.unresolved`,
which `ChatModel.Update` turns into the line + picker: an agent refusal,
a crash before the model ping, a transport error, a cancel, or a
double-Esc abort.
- **Which choices become the launch model:** a saved cloud model does,
so the gate skips the local chat load. Local and Claude choices are
switched to after launch, so a deleted model or missing
`ANTHROPIC_API_KEY` reaches the one-line path instead of halting at the
gate. Explicit `--model` / `--use-claude` win for that launch.
- **Scope:** the remembered choice lives in a shared box in `root` and
is only ever applied to the flagship. `/agents` switches to other agents
never receive it, and switching back restores the latest confirmed
choice. A gate pick is cleared from `m.model` once the flagship has
launched on it.
- **Header before the first ping:** shows the chat model the readiness
gate loaded (new `Report.ChatModel`), display-only, so the agent's first
ping replaces it without tripping the revert warning.
- **Agent:** `/model` on a cloud id Lemonade doesn't list now asks
`readiness.probe_model_present`, which replays the key amd#4485 keeps
(Fireworks or AMD), then re-lists. So a restore survives a Lemonade
restart.
- **Live drive** (Windows Terminal, control API, isolated
`GAIA_HOME`/config/memory/daemon, `PYTHONPATH` pinned to this checkout,
existing embedded Lemonade that already held a Fireworks key):

```
fresh launch:   GAIA │ agent gaia │ Gemma-4-E4B-it-GGUF        (no config.json yet)
after pick:     {"last_model": "fireworks.deepseek-v4p1-flash", "last_provider": "fireworks"}
relaunch gate:  Starting GAIA — chat runs on fireworks.deepseek-v4p1-flash (in the cloud)…
relaunch:       GAIA │ agent gaia │ Fireworks AI · deepseek-v4p1-flash (remote)
                Restored your last model.
/model:         Currently running: fireworks.deepseek-v4p1-flash.
bogus cloud id: Couldn't restore your last model, Fireworks AI · not-a-real-model: Fireworks AI does not list it — the key may be missing or the provider is not connected. Pick a model to continue, now or later with /provider.
missing local:  Couldn't restore your last model, Qwen3-0.6B-GGUF: it is not downloaded. Pick a model to continue, now or later with /provider.
```

- **Pre-existing failures, not from this PR:** three `hub/agents/gaia`
browser-tool registry tests fail without `playwright` installed, and
pylint flags `os.getuid` / `signal.SIGKILL` on Windows. Both reproduce
on `main`.
- **Agent eval:** not run. No prompt, tool schema or error
classification changed; the agent change only adds a re-list in the
`/model` handler.
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llm LLM backend changes performance Performance-critical changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(lemonade): restarting the embedded Lemonade forgets the connected Fireworks/AMD provider

2 participants