Skip to content

fix(llm): a Lemonade server below the version floor is actually reported - #4632

Merged
kovtcharov-amd merged 2 commits into
amd:mainfrom
kovtcharov:kalin/lemonade-version-floor-reported
Oct 4, 2026
Merged

kovtcharov-amd merged 2 commits into
amd:mainfrom
kovtcharov:kalin/lemonade-version-floor-reported

Conversation

@kovtcharov

@kovtcharov kovtcharov commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

If your Lemonade Server was older than GAIA supports, the Lemonade client's setup call (initialize() / initialize_lemonade()) didn't tell you. It computed the verdict, but both callers threw it away, and a version it couldn't read counted as "compatible". Now a server below the floor produces an error that names the installed version, the required one, and gaia init --force-reinstall, and the client won't start a server it already knows is too old. A version it can't read now triggers a warning. The flagship's /init readiness check (what the TUI preflight shows) now gives the same fix.

  • One floor. 10.2.0 is now defined only in gaia.version. The gaia init profiles and the flagship's /init check both use it, and the flagship uses the shared version comparison instead of its own copy. The frozen email sidecar keeps its deliberate copy (it can't import core), and a new test holds that copy to the core floor.
  • Cleanup in the same file. If the model catalog can't be fetched, get_status now logs a warning instead of silently showing loaded models with no labels. The unused LemonadeClient.ready() and the __main__ demo block are deleted.
  • Release note: LemonadeClient.ready() is removed; call health_check() instead. The CLI startup path (LemonadeManager.ensure_ready) does not check the floor yet; that is a follow-up.

Test plan

  • tests/unit/test_lemonade_version_check.py covers the too-old error and its message, refusing to start a too-old server, the warning for an unreadable version, the supported path, and the logged catalog failure
  • hub/agents/gaia/python/tests/test_init_version_floor.py: /v1/gaia/init returns 503 with the fix in the hint for an old server, still accepts CalVer dev builds, and shows an unreadable version as unknown
  • tests/unit/test_lemonade_calver.py checks that the flagship uses the shared check and that the email sidecar's floor matches core
  • pytest tests/unit hub/agents/gaia/python/tests -k "lemonade or init_command or readiness or calver or server or installer" with GAIA_HOME and GAIA_DAEMON_HOME pointed at fresh temp dirs: the only 3 failures also fail on main or depend on pip/network
  • With Lemonade below 10.2.0 running, python -c "from gaia.llm.lemonade_client import initialize_lemonade; print(initialize_lemonade(auto_start=False).error)" prints both versions and gaia init --force-reinstall

A Lemonade Server older than GAIA supports passed the version check:
the client computed the verdict and both callers threw it away, and an
unknown or unparseable version returned "compatible".

- _check_version_compatibility raises LemonadeVersionError below the
  floor, naming the found and required versions and
  `gaia init --force-reinstall`; initialize() reports it on the status
  and refuses to start a too-old server. An unknown version now warns.
- The floor is defined once in gaia.version: init profiles and the
  flagship sidecar reference it, and the sidecar uses the core
  version_meets_min instead of its own parser. The frozen email sidecar
  keeps its vendored copy, now held to the core floor by a test.
- get_status logs a failed catalog lookup instead of hiding it.
- Removes the unused LemonadeClient.ready() and the __main__ demo.
@github-actions github-actions Bot added llm LLM backend changes tests Test changes performance Performance-critical changes labels Oct 4, 2026
@github-actions

github-actions Bot commented Oct 4, 2026

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This makes a Lemonade Server below GAIA's minimum version an actual error. Before, the check was computed and thrown away, and an unreadable version counted as "fine". Now the error names both versions and the fix (gaia init --force-reinstall), and the client won't start a server it knows is too old. The 10.2.0 floor is now defined in one place, and the flagship's /init check uses the shared comparison. The logic is sound and well tested. Two things are worth knowing before merge:

  • Most CLI users still won't see the new error. gaia chat, gaia llm and the other CLI commands start up through a different path, and that path has no version check. This PR fixes the SDK setup call (which nothing in the repo calls) and the flagship's /init readiness check. That's worth fixing, but the title reads broader. Either narrow the description or add the same check to the CLI startup path in a follow-up.
  • A public method is removed with no notice. Deleting LemonadeClient.ready() breaks any outside code that calls it. It deserves a line in the release notes, or a deprecation period.

Real-world evidence

N/A — no evidence bundle was produced for this run. The only runnable surfaces are the SDK setup call and the flagship's /init HTTP route. The verdict rests on reading the code alone; pytest wasn't available in this environment, so I didn't run the PR's tests either. The PR's own unchecked test-plan item (running against a real Lemonade below 10.2.0) is the right proof to capture before merge.

🔍 Technical details

Issues

🟡 Version gate doesn't reach the main CLI path (src/gaia/llm/lemonade_client.py:5606, src/gaia/cli.py:181). initialize_lemonade_for_agent calls LemonadeManager.ensure_ready, and lemonade_manager.py never compares against LEMONADE_MIN_VERSION. In-tree, LemonadeClient.initialize() is reached only through initialize_lemonade(), which has no callers. So the user-visible fix covers SDK callers plus GET /v1/gaia/init. Either scope the PR text to that, or file a follow-up to raise LemonadeVersionError from ensure_ready (the CLI already catches LemonadeClientError at cli.py:194, so it would print cleanly).

🟡 LemonadeClient.ready() removed without deprecation (src/gaia/llm/lemonade_client.py:5081). It was a public method on the SDK's Lemonade client. It was also a silent-fallback (except Exception: return False), so dropping it is defensible, but add a CHANGELOG / release-notes line naming health_check() as the replacement.

🟢 Narrowed except can now let a non-client error through (src/gaia/llm/lemonade_client.py:5195). list_models().get("data", []) raising AttributeError on a non-dict body, or m.get on a non-dict entry, used to be swallowed and now propagates out of get_status. That's arguably correct under fail-loudly. Just confirm it's intended, since get_status runs on every initialize().

🟢 Redundant local import ast (tests/unit/test_lemonade_calver.py:184, :314). ast is already imported at module top (line 30), so both function-local imports can go.

Strengths

  • An unknown version now returns None after a logged warning instead of True. That closes the silent-pass gap and follows the no-silent-fallback rule.
  • A stopped server below the floor is never auto-started (test_stopped_server_below_floor_is_not_started asserts launch_server isn't called). Good to cover the cold path, not just a running server.
  • Replacing the flagship's vendored copy with an AST test that fails if it's re-vendored, and pinning the email sidecar's floor to core, removes a real drift source.

@kovtcharov

Copy link
Copy Markdown
Contributor Author

The CLI startup path stays out of this PR, and the description already scopes the fix to the SDK setup call and the flagship's /init check. The ready() removal now has a release-note line in the description.

🔍 Technical details
  • CLI path: adding the floor to LemonadeManager.ensure_ready changes the startup path every gaia command takes, so it gets its own PR and its own cold-state test rather than riding on this one.
  • ready(): there is no core CHANGELOG; release notes are written when the release is cut. The description now names health_check() as the replacement so the release notes pick it up.
  • Narrowed except in get_status: intended. A non-dict catalog body is a broken server, and fail-loudly wants that to surface, not to come back as unlabelled models.
  • Redundant import ast: removed.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 4, 2026
Merged via the queue into amd:main with commit a2f125e Oct 4, 2026
@kovtcharov-amd
kovtcharov-amd deleted the kalin/lemonade-version-floor-reported branch October 4, 2026 11:36
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]>
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.

2 participants