Skip to content

fix: surface failures GAIA was hiding and drop dead code - #4618

Merged
kovtcharov-amd merged 4 commits into
amd:mainfrom
kovtcharov:kalin/fail-loud-cleanup
Oct 4, 2026
Merged

kovtcharov-amd merged 4 commits into
amd:mainfrom
kovtcharov:kalin/fail-loud-cleanup

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

A corrupt ~/.gaia/config.json made the Agent UI quietly report the "chat" profile, and a stopped or missing Lemonade sent users to lemonade-server.ai — then promised GAIA would start it, in a message printed after auto-start had already failed. Users now see what broke and a command that fixes it: the UI shows the config error in a banner, Lemonade remedies lead with gaia init (or the start command resolved for this machine), and gaia init prints hub-catalog and config-reset warnings instead of only logging them. Also removes code nothing calls.

  • Fail loudly: config error in the UI status and banner; gaia init remedies; gaia init warnings shown on the console; sidecar connection errors get the start hint; agent-loop notify failures logged with the session id; no more mentions of the removed lemonade-server binary.
  • Dead code: unreferenced install-ui scripts (they also linked to a 404 page), the litellm extra (the docs already say it's gone), the interactive menu nothing calls, and a device→recipe map whose only use was a debug log.

Test plan

  • pytest tests/unit/chat/ui tests/unit/test_init_command.py tests/unit/test_lemonade_not_running_remedy.py tests/unit/test_email_sidecar_relay.py tests/unit/test_no_removed_lemonade_cli.py tests/unit/test_amd_gaia_urls.py, with GAIA_HOME and GAIA_DAEMON_HOME pointed at fresh temp dirs
  • black, isort, flake8, and pylint (repo config) on the changed files
  • Webui vitest + tsc (CI): the new ConnectionBanner case and the config_error field in the API types
  • Put invalid JSON in ~/.gaia/config.json, then run gaia chat --ui: the banner names the file and how to fix it

A broken ~/.gaia/config.json made the Agent UI silently report the "chat"
profile, and a stopped or missing Lemonade sent users to lemonade-server.ai
with a promise that GAIA would start it - printed after auto-start had
already failed. These now say what went wrong and point at `gaia init` or
the start command resolved for this machine.

- Agent UI status carries the config load error and the banner shows it
- Lemonade remedies lead with `gaia init`; GAIA's own server counts as
  installed, so its users get the start hint instead of "not installed"
- `gaia init` shows hub-catalog and config-reset warnings on the console
  and logs through gaia.logger
- Email/GAIA sidecar connection errors append the resolved start hint
- Agent-loop notify failures are logged with the session id
- Removed the unreferenced install-ui scripts, the retired litellm extra,
  the uncalled interactive menu and the unused device-to-recipe map
@github-actions github-actions Bot added dependencies Dependency updates llm LLM backend changes cli CLI changes tests Test changes performance Performance-critical changes agents labels Oct 4, 2026
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This PR stops hiding two kinds of failure. A broken ~/.gaia/config.json now shows up as a banner in the Agent UI instead of quietly falling back to the "chat" profile. And "Lemonade isn't running" messages now give a command that works (gaia init, or the start command for this machine) instead of linking to lemonade-server.ai. It also deletes code nothing calls. The logic is correct and has tests, and I checked that nothing still references the deleted scripts, menu, device map or litellm extra.

Nothing blocks merge. Three things are worth a look:

  • No proof yet that the banner and CLI messages work for real. The manual check of the banner is still unchecked, and there's no CLI output in the PR. Paste a screenshot of the banner with a corrupt config, plus the real gaia init warning output, before merge.
  • One "not installed" path is still wrong for people who already ran gaia init. If GAIA's own Lemonade is installed but stopped, the Python SDK's startup path still tells them to run gaia init. It tells a user of an unreachable remote server the same thing.
  • Edge case in the banner: if the config is broken and Lemonade is down, dismissing the config banner also hides the Lemonade warning until something changes.

Real-world evidence

N/A: no evidence bundle was produced for this run. This verdict rests on static review and the unit tests in the diff. The UI banner (gaia chat --ui) and the CLI remedy text were not run here.

🔍 Technical details

🟡 No real-world evidence for user-visible surfaces (nudge, not a blocker)
The banner change (ConnectionBanner.tsx, /api/system/status → config_error) and the CLI remedies (LemonadeManager.print_server_error, gaia init warnings) are user-visible. The PR shows only unit tests, and the "invalid JSON → gaia chat --ui" item is unchecked. Add to the PR description:

  • a before/after screenshot of the banner, embedded as a raw raw.githubusercontent.com image
  • curl -s localhost:4200/api/system/status | jq .config_error with a corrupt config
  • real gaia init output showing the hub-catalog warning

🟢 LemonadeClient.initialize still reports "not installed" when GAIA's own Lemonade is installed (src/gaia/llm/lemonade_client.py:5584)
_check_lemonade_installed() only checks resolve_lemonade().found on localhost, and that check doesn't count GAIA's own Lemonade (EmbeddedLemonade). So a user who ran gaia init but has the server stopped is told "not installed, run gaia init". The PR fixes exactly this in LemonadeManager.is_lemonade_installed (lemonade_manager.py:309), but this public SDK path (initialize_lemonade) is still missing it. The remote LEMONADE_BASE_URL branch also returns False, which now prints "run gaia init" for an unreachable remote server. That would be better as "server at not reachable". The fix is to apply the same configured_lemonade_url() / EmbeddedLemonade().is_installed() guard in _check_lemonade_installed.

🟢 Dismissing the config banner hides a Lemonade-down banner too (ConnectionBanner.tsx:217)
Case 1b runs before Case 2 and uses the shared dismissed flag. The reset effect only re-arms when lemonade_running changes to false. If Lemonade was already down when the user dismissed the config banner, the Lemonade warning never appears. One option is to add a prevConfigErrorRef and track which banner was dismissed. Another is to skip the dismiss button for 1b, since a broken config blocks session creation anyway.

🟢 The sidecar hint now repeats itself (src/gaia/ui/email_sidecar/relay.py:108)
lemonade_hint already ends "Start Lemonade Server, then retry." and then describe_start_hint() is appended. On Windows that reads "…Start Lemonade Server, then retry. Start Lemonade Server from the Lemonade tray icon…". With GAIA's own Lemonade it reads "…then retry. GAIA starts its Lemonade Server when it needs it…". Consider dropping the trailing sentence from both profile hints in profiles.py so the resolved instruction is the only remedy.

Strengths

  • system_status now catches only GaiaConfigError. GaiaConfig.load raises nothing else (OSError and JSON errors are both wrapped), so the narrower catch can't turn the status endpoint into a 500. Two route tests cover the corrupt-config and valid-config cases.
  • _notify_loop replaces except: pass with a contextual warning that includes the session id, and the comment explains why it doesn't raise.
  • The remedy tests assert the absence of dead strings (lemonade-server, "automatically start") and patch describe_start_hint, so they don't depend on what's installed on the host.

Kalin Ovtcharov added 2 commits October 4, 2026 02:42
…installed

LemonadeClient.initialize now counts GAIA's embedded Lemonade as installed, and
reports an unreachable LEMONADE_BASE_URL as not reachable instead of telling
the user to run gaia init. The sidecar relay hints drop their own start
sentence so the resolved start instruction is the only remedy.
The config-error banner is no longer dismissable, since its dismiss flag also
suppressed the Lemonade-down warning. A non-UTF-8 config.json now raises
GaiaConfigError, so the status endpoint reports it instead of returning 500.
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

🟡 The SDK fix for GAIA's own Lemonade stops one step short. A user who ran gaia init and whose server is stopped now gets past the "not installed" check. But initialize() auto-starts by default, and the auto-start only knows how to launch a system-installed Lemonade. That user still ends up with "Failed to start Lemonade Server: Lemonade Server not found … Run gaia init", which is the same wrong advice in new words. Start GAIA's own server on that path (the way LemonadeManager.ensure_ready does), or return the resolved start hint instead of trying the system launcher. Then add a test that runs initialize() end to end for this case.

🔍 Technical details
  • lemonade_client.py:5425: _check_lemonade_installed now returns True when EmbeddedLemonade().is_installed(), with no system tooling present.
  • initialize(auto_start=True) then calls launch_server(...) (around line 5672). There, resolve_lemonade().found is False (lemonade_client.py:1797), so it raises LemonadeClientError("Lemonade Server not found … Run gaia init …"). The except Exception at about line 5698 catches it and prints that message.
  • The new tests stop at _check_lemonade_installed(), or patch it out of initialize(), so none of them reaches this branch.

kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Oct 4, 2026
Merge after amd#4618 — this branch contains its commits.

The Agent UI status endpoint hid its own probe failures. When the
model-catalog, inference-stats, device or disk check failed, the
response still looked complete: the GPU row went blank, download state
stayed unknown and stats disappeared, with nothing to say why. Each
failure is now listed in a new `probe_warnings` field on
`/api/system/status` and logged at warning. The UI doesn't render the
field yet (no Node on the authoring machine), but the API exposes it and
the TS types include it. Memory upkeep also no longer stops silently: if
the agent's consolidate/reconcile methods are renamed, wiring them now
fails loudly.

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

- Probes catch transport, JSON and payload-shape errors
(`httpx.HTTPError`, `ValueError`, `TypeError`, `AttributeError`) instead
of `Exception`. Anything else falls through to the existing "Lemonade
health query failed" path, which now logs its cause.
- The UI polls status, so each probe logs at warning once per distinct
message and at debug after that.
- The `urlparse` try/except was dead code (it never raises) and is
removed.
- `_register_agent_memory_ops` checks `isinstance(agent, MemoryMixin)`
and then reads the attributes directly. Agents without memory are still
skipped.
- `disk_space_gb` still defaults to `0.0` when the disk probe fails,
because making it nullable would need a frontend change I couldn't
verify without Node. The new warning explains the 0.
- The schema was regenerated with `python -m gaia.ui.export_openapi`,
with this worktree's `src` on `PYTHONPATH`. The `api.gen.ts` line was
added by hand to match the generator's output.
</details>

## Test plan
- [x] `pytest tests/unit/chat/ui/test_status_probe_failures.py`: stats,
device, catalog (exception and HTTP 500) and disk failures each appear
in `probe_warnings`, Lemonade stays "running", repeat failures log at
warning once, memory-op wiring (registers, skips, fails on a renamed
method), and the store-close failure is logged
- [x] `pytest tests/unit/test_init_command.py tests/unit/installer
tests/unit/chat/ui tests/unit/test_memory_router.py
tests/unit/test_ui_gpu_detection.py
tests/integration/test_memory_api_integration.py` (1658 passed), run
with fresh `GAIA_HOME` / `GAIA_DAEMON_HOME`
- [x] `test_export_openapi` passes against the regenerated schema
- [ ] `cd src/gaia/apps/webui && npm run gen:api-types` produces no diff
to `api.gen.ts`

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Oct 4, 2026
… point (amd#4657)

Right after `gaia init`, if GAIA's own Lemonade is stopped (after a
reboot, a crash, or `gaia lemonade embedded stop`), `gaia llm`, `gaia
chat`, `gaia api`, every agent constructor, the TUI and
`initialize_lemonade()` look for a system Lemonade. They find none and
tell the user to run the `gaia init` they already ran. Only the Agent UI
server started the right one. Now every start path checks one resolver
and starts GAIA's server through the daemon. If that start fails, the
daemon's error is shown and nothing tries a system install.

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

- **Cause.** `ensure_ready` only started the embedded server when the
caller pinned no URL. The CLI pins env host and port, and the Agent base
pins the URL it resolved while the server was stopped. Both fell through
to `/daemon/v1/lemonade/start`, whose `LemonadeSupervisor` only knows
`resolve_lemonade()`. `LemonadeClient.initialize` / `launch_server`
resolved the system launcher directly.
- **Fix.** `gaia_runs_lemonade(base_url)` in `lemonade_launcher.py` is
the single decision. It is true when the embedded server is installed,
`LEMONADE_BASE_URL` is unset, and the URL is unset or is the one GAIA
resolves on its own. `ensure_ready`, the supervisor (now given the
daemon's `EmbeddedLemonadeOwner`), `launch_server`,
`_check_lemonade_installed`, `start_embedded_if_stopped` and
`describe_start_hint` all go through it. The embedded server binds a
random port, so `ensure_ready`, the Agent base and `launch_server`
re-resolve after starting it.
- **Not a start path.** `AgentSDK` construction never starts a server;
its first request fails with the provider's client hint.
- **Overlap.** This conflicts textually with amd#4618 in
`LemonadeClient._check_lemonade_installed`, where both add an "embedded
counts as installed" check. Either can merge first; on rebase keep this
PR's `gaia_runs_lemonade(self.base_url)` line and amd#4618's message
changes. It doesn't touch the functions changed by amd#4627, amd#4632 or
amd#4543.
</details>

## Test plan
- [x] `pytest tests/unit/test_gaia_lemonade_start_path.py` covers the
cold state: embedded installed and stopped, no system Lemonade. The
tests patch only the daemon, HTTP, `Popen` and the launcher resolver.
Each case asserts the daemon started GAIA's server, the system launcher
was never consulted, nothing was spawned, and the caller ended up on the
new port. Cases: CLI, Agent base, UI server, `initialize_lemonade`,
`create_lemonade_client`, the daemon supervisor, and failure paths.
- [x] Related suites pass: `test_lemonade_manager_autostart`,
`test_lemonade_supervisor`, `test_lemonade_launcher`,
`test_lemonade_service`, `test_daemon_lemonade`,
`test_daemon_lemonade_routes`
- [ ] On a machine with only `gaia init`'s Lemonade: `gaia lemonade
embedded stop`, then `gaia llm "hi"` answers instead of saying Lemonade
is not installed
- [ ] Same state, TUI: the model server comes up without a "could not
find one to start" error

Co-authored-by: Kalin Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 4, 2026
Merged via the queue into amd:main with commit 5f8e363 Oct 4, 2026
@kovtcharov-amd
kovtcharov-amd deleted the kalin/fail-loud-cleanup branch October 4, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents cli CLI changes dependencies Dependency updates 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