Repository navigation
fix(providers): keep a Fireworks/AMD key across TUI instances and restarts - #4485
Merged
Merged
Conversation
…onade restarts A key pasted into the TUI's /provider panel lived only in Lemonade's memory, so the next TUI, or the next embedded-Lemonade start, had no Fireworks key and the user had to paste it again. - A key that connects and discovers models is kept in the OS credential store via the daemon (go-keyring cannot read what python-keyring writes). The Fireworks slot is the one GAIA's own Fireworks client already reads. - It is replayed into any Lemonade that has the provider but no key: by the agent readiness check when a cloud model is missing (every front-end), and when the /provider panel opens. A key Lemonade already has, from its environment or a paste, is never overwritten. - Ctrl+D forgets the kept copy too, and a store that cannot keep the key says "this session only" with the LEMONADE_<PROVIDER>_API_KEY remedy. - The gateway panel's daemon helper moves to daemon.Call so both panels share it.
Contributor
Author
|
One related gap this PR is well placed to close. With |
4 tasks
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>
This was referenced Sep 29, 2026
grtninja
pushed a commit
to grtninja/gaia
that referenced
this pull request
Oct 2, 2026
…ere (amd#4505) Three things on the AI provider screen told users something untrue. On a new machine, pressing **p** before setup installed Lemonade showed "Lemonade did not respond… Start it", a fault for a step they hadn't reached. A Fireworks key Lemonade already held (`LEMONADE_FIREWORKS_API_KEY`) still showed "Paste API key", though Enter connected. And the setup text said keys are lost when Lemonade restarts, which stopped being true with amd#4485. Now the picker names the setup step that installs Lemonade and waits for it, the key field says "A key is already set — Enter connects", and the text says the key is kept in the OS credential store. Past setup, an unreachable Lemonade still reports the fault as before. Closes amd#4503 <details> <summary>🔍 Technical details</summary> - Lemonade lists a provider in `/system-info`, and so reports `env_var_set`, only after `POST /install` registers it. That's why the env key was invisible. Opening Fireworks setup now registers it with the same fixed settings Connect sends (no key), re-runs the kept-key restore, then re-reads providers. I confirmed this against a real `lemond` 2026.39.1: `providers: []` before, `env_var_set: true` after. - `lemonade.ErrUnreachable` is now a sentinel. Root passes `Report.LemonadeStep()` into the panel via `WithSetupStep`, so the wording follows the real step number. - A failed provider read no longer wipes the known key states. This came out of review. - `tui/README.md` and `docs/guides/ai-providers.mdx` are updated to match. </details> ## Test plan - [x] `cd tui && go build ./... && go vet ./... && go test ./...` — all pass; `gofmt -l` clean after CRLF strip - [x] New frame tests in `tui/internal/ui/providers/setup_state_test.go`: step message before setup, fault after setup, "A key is already set" against a fake Lemonade that lists Fireworks only once registered, credential-store wording at both panel heights - [x] Fresh `GAIA_HOME` first run, driven over the control API, **p** on the setup gate: before shows "Lemonade did not respond"; after shows "Lemonade isn't installed yet — setup step 1 installs it" and Enter does nothing - [x] Real `lemond` started with `LEMONADE_FIREWORKS_API_KEY`, `/provider` → Fireworks: before shows "Paste API key" plus "Keys stay in Lemonade memory until it restarts"; after shows "A key is already set — Enter connects" plus the credential-store line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A Fireworks key pasted into the TUI's
/providerpanel 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/provideropens. The same applies to an AMD gateway key set from/provider. Pairs with #4469, which keeps the provider registration across embedded restarts; this keeps the key.LEMONADE_FIREWORKS_API_KEYor a paste, wins. A key that discovers no models is not kept, so a typo isn't replayed forever.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.pycd tui && go test ./internal/ui/providers/ ./internal/ui/gateway/ ./internal/daemon//providerand pick a model; quit;gaia lemonade embedded stop && gaia lemonade embedded start(with fix(lemonade): keep cloud providers across embedded restarts #4469); relaunchgaia tuiand chat onfireworks.*without re-entering the key/provider→ relaunch → the key is asked for again🔍 Technical details
gaia.llm.cloud_keyskeeps, recalls, forgets and replays per provider. Fireworks uses slotfireworks_api_key, the oneresolve_fireworks_api_keyalready reads. AMD reusesgateway:amdandGatewayManager.ensure_authenticated. Writes are read back, so a null keyring backend fails loudly instead of "saving" nothing./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_tokenbecomes_replay_cloud_key, covering every provider incloud_keys.PROVIDERS.daemonCallmoves todaemon.Call, so both panels share one implementation.lemondon its own port and config, with a fake key in the real Windows credential store:The last unchecked item needs a real Fireworks key, which I didn't handle.