Repository navigation
feat(daemon): start and supervise the local model server - #3122
Conversation
|
Request changes — one timeout was left behind, plus a few doc/test follow-ups. This makes GAIA start the local model server itself instead of telling the user to. The daemon owns the process, every front-end asks it over one new route, and failures come back naming what broke and what to do. The design is clean and the test coverage is unusually good. The blocking issue: the scripted, non-interactive path ( Three smaller things worth fixing before merge:
Real-world evidenceStrong, and it supports the verdict for everything it covers. The bundle exercised the new HTTP route on a real booted daemon (start refused with a 503 carrying the install message, status without starting anything, token auth, request validation), the CLI before/after on Deferred to the strix-halo lane, as marked: any path where a server actually comes up ( 🔍 Technical detailsIssues found🟡 Important — the one-shot readiness deadline was not raised with the gate's (
Failure: The comment just above it should keep naming 🟡 Important — new daemon routes missing from the documented control plane ( The table enumerating 🟡 Important — documented The PR swapped the The prose at 2934 / 3230 — "Against an unreachable dependency that is about a second" — and 🟡 Important — the "what to do" assertion can no longer fail ( Line 473 already asserts 🟢 Nit —
🟢 Nit — comment at the Agent UI's Lemonade probe is now wrong ( "Pre-warm LemonadeManager — check reachability only" / "Only check reachability — don't trigger model reloads". It now starts the server and, via 🟢 Nit —
Strengths
|
d4277ac to
7cb72bd
Compare
Skill audit
✅ All audited skills cleared the tier they claim. Per-finding detail is withheld here on purpose. Read it in the Security > Code scanning tab, or download the |
Approve with suggestionsThe daemon supervision feature is well-designed end-to-end: fail-loud errors, correct lock discipline in 🟡 The "what to do" assertion in The middle predicate of the three-part contract check passes trivially — Before this PR the assertion was 🔍 Technical details
# Current (always true once the first assert passes)
assert any(c in lower for c in ("gaia daemon start", "gaia init", "lemonade"))
The fix is to drop assert any(c in lower for c in ("gaia daemon start", "gaia init"))If |
|
Rebased onto current main, which brought the flagship agent package (#3120) carrying six fresh copies of One gap left deliberately: the flagship launch uses a second, daemon-free readiness gate that #3120 added, so it still shows a (correctly resolved) manual start command rather than auto-starting. Closing that means giving the default journey a resident daemon it doesn't currently need — a reversal of #3120's design that belongs in its own change. Filed as #3126. Re-verified on current main: cold |
|
Verdict: Approve with suggestions
This introduces daemon-owned supervision of the local model server: 🟡 Missing CLI evidence — the PR changes user-observable behavior at every GAIA entry point that calls 🟢 Nit: 🟢 Nit: 🔍 Technical detailsEvidence gap ( Private import (
Shutdown ordering (
|
|
Verdict: Approve with suggestions This is a well-designed, thoroughly tested PR. The daemon-owned Lemonade supervision model is architecturally sound — single-ownership through the daemon eliminates the race where a CLI and a UI both try to spawn a server, the lock discipline in One concrete correctness gap in the SD integration test prerequisites, noted below. 🟡 The SD integration test is missing its model-pull step. 🔍 Technical details
Prerequisites:
gaia daemon start
gaia initThe test module docstring (line 5) still reads: "These tests require Lemonade Server running with SD-Turbo model available." Fix: add the equivalent SD model pull. If or, if No other blocking issues found. The |
|
Verdict: Approve This lands a well-scoped, well-tested architecture change: the GAIA daemon now owns the Lemonade process instead of leaving users to start it. The fast path (server already up) stays at one probe. The slow path routes every front-end through one supervisor so two concurrent launches cannot race into two servers. I read the full diff — no correctness bugs, no security issues, and no CLAUDE.md violations. Three small observations below; none block merge. 🔍 Technical detailsLock discipline in
Timeout ordering test — |
|
CI watched through to green, with two real bugs found and one that isn't mine. A design mistake CI caught that my local runs could not. Also fixed: three assertions this change invalidated, in files this machine cannot run (the 77 pass, 1 fail, and the failure is the runner. My only touch anywhere near it is |
|
Both remaining CI failures are environmental, and each names itself:
77 pass, 2 fail, zero code failures. Ready for review. |
ca58e3c to
d82cf17
Compare
|
🟡 The three "Request changes" items from the previous review are still open — none were fixed in this push. The most important: The other two open items: the 🔍 Technical details
The comment on lines 502–504 names this invariant; update it to reference the new value.
The stale terminal transcript at |
GAIA needed you to run `lemonade-server serve` before anything worked, and that command has not existed since Lemonade 10.7 — every front-end that found the server down printed a remedy that fails with "command not found". Now the daemon starts the model server itself, supervises it as a child, and reaps it on shutdown. The TUI, the Agent UI, `gaia chat` and `gaia llm` all come up on a cold machine with nothing typed. The daemon owns the process; nothing else spawns one. That makes "one server per machine" a property of the design rather than a race that usually works: front-ends ask over the existing authenticated loopback channel (`POST /daemon/v1/lemonade/start`, host API 1.2), and in-process callers reach the same supervisor directly. A server the daemon did not start — one launched from the tray — is attached to and left alone, including at shutdown. Failures stay loud. Not installed, port held by a stranger, the server died on launch, the daemon unreachable: each is its own error naming what failed, what to do, and where to look. Nothing degrades quietly to "no LLM". How the server is launched is still `resolve_lemonade()` / `build_start_command()`'s decision, and `StartSpec(argv, env)` is passed through untouched — the embeddable `lemond ./ --port N` form takes a working directory and port the others do not, so nothing here may assume the argv shape. That also removes the ~10 stale `lemonade-server serve` strings across runtime messages, hub agent docs and the doc site: the manual fallback is now resolved against the machine it will be typed into.
The flagship agent package and the chat view landed after this branch was cut, each carrying its own copy of `lemonade-server serve` — a command Lemonade removed in 10.7, so following it gets "command not found" and no way forward. Four runtime messages and the SKILL.md integrator guide named it. Six tests ASSERTED it, which is why it survived: a suite that pins a dead literal reports the remedy as verified every time it runs. Those now assert that some real next step is named, not which one — the manual fallback is resolved against the machine it will be typed into, so there is no single string to pin. The chat view's model-switch refusal points at `gaia daemon status` instead of a launcher: the daemon owns the server, and that command exists everywhere, which is exactly the property the old one lacked.
Three CI failures, all mine, all in files this machine cannot run: the `tests/unit/agents/` tree fails to collect here because the editable install resolves `gaia_agent_email` to a different worktree, and every TestClient test is blocked by the unit-test socket guard on Windows. - `_build_deregister` gained a required `lemonade` argument. The ordering test now passes one and asserts WHERE the model server is reaped: after the sidecars, so an agent finishing a model call mid-teardown does not have the server pulled out from under it. - The email sidecar's `/init` and provisioning tests asserted `lemonade-server serve` in the hint. They now assert the next step the hint actually names. Also drops the same dead command from four developer-facing skip reasons and prints, and from an `or` branch in the error-classification tests that would have kept a removed command's assertion passing.
CI caught a design mistake in the previous commit, and the symptom was a
timeout rather than a failed assertion, which is why it took a CI run to see.
`LemonadeManager.ensure_ready` asked the model server's owner to start it, and
that ask start-or-attached a daemon. So constructing an agent — in a unit test,
in a library caller, anywhere — spawned a machine-wide background service and a
model server, and took 30 seconds. The email agent's job went from 3 minutes to
past its 10-minute ceiling with every assertion still green.
Bringing up background infrastructure is a front-end's decision, made once and
where a user can see it. A readiness check may only attach to what is already
running, and say so loudly when nothing is:
The local model server is not running, and neither is the GAIA background
service that owns it — so nothing can start it.
To fix: run `gaia daemon start`, then retry.
`gaia llm` and `gaia chat` still come up on a cold machine: the CLI is a
front-end, so it opts in through `ensure_daemon_owns_lemonade()` before the
readiness check runs. One status probe when a daemon is already up.
The health probe's connect budget drops to 0.5s. It only ever dials loopback,
where a connection is refused in microseconds, and it is paid twice per probe
because `localhost` resolves to both ::1 and 127.0.0.1 — 4 seconds to learn
"not running", on every down-path call. The down path is now ~1s slower than
before this branch rather than ~26s.
d82cf17 to
dfcf545
Compare
|
Merged
One test on this branch also needed a fix to survive the merge — unrelated to the feature, just a mock that 🔍 Technical details
Go build / vet / tests green. Python failure set is byte-identical to a pristine |
amd#4120) Five open PRs (amd#4096, amd#4108, amd#3937, amd#3122, amd#3072) are showing a red agent-eval lane for a scorecard that was never produced. The Anthropic account is over its weekly spend cap, and the rejection text changed to a wording the preflight classifier does not recognise, so instead of "quota exhausted, this says nothing about your PR" the job dies in ~37 seconds with "could not be classified" and looks like a measured quality regression. After this change the same outage is named as a quota outage and points at billing rather than at the PR or the repository secrets. The pattern matches on `weekly limit`, not on the reset date the message quotes — that date moves every reset. ## Test plan - [ ] `python -m pytest tests/unit/test_classify_claude_probe.py -q` — 30 passed - [ ] `test_real_weekly_limit_rejection_is_a_quota_problem` feeds the verbatim text from run 35681533582 (job 106629918099), BOM and U+00B7 included, and asserts `quota`; it fails on `main` - [ ] `test_the_weekly_limit_pattern_does_not_depend_on_the_reset_date` pins that a different reset date still classifies - [ ] `python util/lint.py --black --isort --flake8` passes - [ ] The classifier stays pure ASCII (`test_the_classifier_module_is_pure_ascii`), which the PowerShell eval step depends on Co-authored-by: Kalin Ovtcharov <[email protected]>
…d#4321) Two Microsoft connector tests were skipped while they waited on a PR that merged long ago, so the Microsoft forward path had no HTTP-level coverage. A Lemonade test was skipped as "still in development" for \`set_params\`, a method that can never succeed: Lemonade rejects every key it sends, and nothing calls it. Now the Microsoft tests run and pass, and \`set_params\` is deleted along with its skipped test and a unit test that only proved a fake mock response round-trips. Two test comments that still called closed features unimplemented are corrected. \`TestDatabaseMixin\` in \`tests/test_sdk.py\` (the third marker in amd#4256) is left alone on purpose, because the amd#4205 work is already rewriting that file. <details> <summary>🔍 Technical details</summary> - Live check against the local Lemonade server: \`POST /api/v1/params\` returns 404. amd#3319 recorded 400 \`Unknown config key\` for every key on 11.5.0. So the skipped integration test could never pass. - The C++ \`setParams\` takes arbitrary JSON, so it still works with valid config keys and is kept. Only its "Mirrors Python set_params()" comment is removed. - Dropping the skip decorator left the module-level \`import pytest\` in \`test_lemonade_client.py\` used only by a duplicate import under \`__main__\` (flake8 F811). The duplicate is removed. - Swept every \`skip\`/\`xfail\` marker under \`tests/\` and \`hub/\`. The rest are either environment-conditional or strict xfails that record a deliberate product decision (mandatory API/MCP auth), so none are stale. - Overlap: amd#3122 edits the code directly after \`set_params\` in \`lemonade_client.py\`, so whichever merges second may need a trivial rebase. - Pre-existing and unrelated: \`tests/unit/connectors/test_forwarded_import.py\` fails 2 tests when it runs after \`test_router_forwarded.py\` and \`test_email_sidecar_proxy.py\` in one session. This happens with or without this change (Microsoft tests deselected). - amd#2109 and amd#2243 are closed, and their tests pass. Only the comments said otherwise. </details> ## Test plan - [x] \`pytest tests/unit/connectors/test_router_forwarded.py -q\`: 20 passed. The 2 \`TestMicrosoftForward\` tests were skipped on main and now pass. - [x] \`pytest tests/test_lemonade_client.py -q -p no:randomly\`: same 6 failed / 15 errors as on main (local-environment tests that hit this machine's real Lemonade), 75 passed vs 76, 0 skipped vs 1. The difference is the two deleted tests. - [x] \`pytest tests/unit/test_email_sidecar_proxy.py tests/unit/agents/test_registry.py -q\`: 112 passed, 2 skipped (environment-conditional) - [x] black, isort, flake8 and pylint clean on the changed Python files Fixes amd#4256 Fixes amd#3319 Co-authored-by: Kalin Ovtcharov <[email protected]>
…ce load errors (amd#4290) Before this change, the first image extraction loaded the vision model at Lemonade's default context and then reloaded it straight away at the size GAIA requires. That meant two cold loads, and it evicted the chat model when both are the same Gemma. The pre-load also gave up after 60 s, which is shorter than a cold iGPU load, and any failure (timeout, out of memory) turned into a generic "model is not available". Now each extraction loads the model once, at the right context, inside the request. The real load error reaches the caller, and a model evicted mid-batch reloads on the next page instead of failing. The only overlap with open PRs is amd#3122, which edits a different line of `tests/test_vlm_integration.py`. ## Test plan - [x] New tests fail on `main` (5 failed) and pass with the fix: `python -m pytest tests/unit/test_vlm_extraction_failures.py -q` (15 passed) - [x] Neighbouring tests: `python -m pytest tests/unit/test_structured_vlm_extraction.py tests/unit/test_ingest_helpers.py tests/unit/test_lemonade_base_url_passthrough.py tests/unit/test_llm.py tests/unit/test_testing_utilities.py tests/unit/rag/ -q` (all pass) - [x] `black --check`, `isort --check-only`, and the CI pylint command on `src/gaia/llm src/gaia/vlm src/gaia/rag` are clean - [ ] With Lemonade running, index a PDF with images from a cold state (vision model not loaded) and confirm one `/load` at the model's required ctx Fixes amd#4215 Co-authored-by: Kalin Ovtcharov <[email protected]>
# Conflicts: # docs/cpp/setup.mdx # docs/guides/email.mdx # hub/agents/gaia/python/gaia_agent/server.py # src/gaia/cli.py # src/gaia/daemon/app.py # src/gaia/llm/lemonade_client.py
initialize_lemonade_for_agent calls ensure_daemon_owns_lemonade() once at startup (this PR: the daemon is what owns the model server, and a front-end has to be allowed to bring it up). This file's tests call initialize_lemonade_for_agent directly and mocked LemonadeManager.ensure_ready but not this new call, so they tried to spawn a real GAIA daemon and hit the test-isolation guard that exists to catch exactly that.
When a model was missing, GAIA told users to run `gaia download <model>`. The CLI rejects that with exit 2, so the only fix it offered couldn't work. The model-not-found and agent-builder errors now give the pull command for the user's actual Lemonade install, and the image-gen skill no longer tells the model to suggest the removed `lemonade-server pull`. A new guard test fails CI on any runtime string that names `lemonade-server serve`/`pull`, so these can't come back. This covers the part of amd#4216 that no other PR does. The `lemonade-server serve` strings are fixed in amd#3122 (email agent, readiness, provider timeout, TUI, webui README, tests) and amd#4181 (hub gaia agent). The guard lists those files as pending. It fails whichever of those PRs merges second until its entries are removed from the list, which keeps the list from going stale. ## Test plan - [x] `python -m pytest tests/unit/test_remedy_commands_are_runnable.py tests/unit/test_no_removed_lemonade_cli.py tests/unit/test_lemonade_error_classification.py tests/unit/agents/test_builder_model_selection.py -q`: 7 failed on main before the fix, 107 passed after - [x] Neighbouring tests (`test_lemonade_launcher.py`, `test_sd_error_messages.py`, `test_llamacpp_backend.py`, `test_amd_gaia_urls.py`): 197 passed in total - [x] black, isort, and pylint (errors only) are clean on the changed files - [ ] `gaia eval agent`: the model-not-found text is returned as the agent's answer, and the image-gen skill text is shown to the LLM Part of amd#4216 --------- Co-authored-by: Kalin Ovtcharov <[email protected]> Co-authored-by: Kalin Ovtcharov <[email protected]>
Nine test files that no CI lane runs had been failing for weeks without anyone seeing it. `tests/test_sdk.py` alone had 17 failures against APIs that were renamed or removed. This PR gets every one of them passing against current main, so amd#4205's follow-up can put them in a lane. Where a test covered something that no longer exists, it's deleted and the commit says why, rather than rebuilt. Overlaps (small, easy to resolve, all by the same author): - amd#4033 bumps the same schema-version assertion from 4 to 5. Whichever lands second takes its own number. - amd#4290 and amd#3122 edit `tests/test_vlm_integration.py`, which this PR deletes. That file returned booleans instead of asserting, so it could never fail, and it passed a constructor argument that no longer exists. ## Test plan - [x] Before, on `origin/main`: the repaired files fail offline (`test_sdk.py` 17, `test_multi_caller_equivalence.py` 2, `test_memory_integration.py` 1, `test_memory_api_integration.py` 1, `test_documents_router.py` 3, `test_tui_control_e2e.py` 6, `test_ui_email_scope_consent.py` 5, `test_lemonade_embedded_lifecycle.py` 1 on macOS) - [x] After, with homes isolated and Lemonade pointed at a dead port: the offline set passes. That's 534 passed and 12 skipped across the 23 files amd#4205 wires in, in a clean py3.12 venv with `-e ".[api,mcp]"` plus the unit job's test deps, with Go on PATH - [x] `tests/test_ui_email_scope_consent.py` passes inside the email unit lane's full pytest command (4971 passed), in a clean venv with `.[dev,api,publish,mcp]` and the email package installed - [x] `black --check`, `isort --check-only`, `flake8`, and `pylint --errors-only` are clean on every changed file <details> <summary>🔍 Technical details</summary> - `test_sdk.py`: `Agent.execute_tool` was never public; the replacement follows `docs/sdk/testing.mdx` (registry lookup). `openai_server` exposes a module-level `app`, not `create_app()`. `STATE_*` constants live on `Agent`. `_register_tools` is now the only abstract method. Removed the xfail `DatabaseMixin` block, since it ships as `gaia.database.mixin` and has its own wired tests. The MCP tests in this file need the `[mcp]` extra, which the lane installs. - `test_multi_caller_equivalence.py`: mutating `/api/*` calls need `X-Gaia-UI: 1` (`gaia.ui.security`), and `/api/connectors` returns `{"connectors": [...]}` keyed by `id`. - `test_memory_api_integration.py`: consolidation returns 503 until a chat session registers `_consolidate_fn`. That is intended behavior, not a side effect of the environment. Both branches are now pinned. - `test_documents_router.py`: the `failed_doc` fixture and one test uploaded without `mock_index_document`, so they indexed for real and needed Lemonade. - `test_tui_control_e2e.py`: a fresh pty is 0x0, so `resize` refused; runners leave `TERM` unset, so the ANSI screen had no escapes. - `test_ui_email_scope_consent.py`: `EmailTriageAgent` also declares `microsoft_work` now. The three deleted tests hit an in-process `/v1/email` mount that the UI dropped in the amd#1767 sidecar cutover; `tests/unit/test_email_sidecar_*` cover the forwarder. </details> Refs amd#4205 --------- Co-authored-by: Kalin Ovtcharov <[email protected]> Co-authored-by: Kalin Ovtcharov <[email protected]>
# Conflicts: # hub/agents/email/python/gaia_agent_email/api_routes.py # hub/agents/gaia/npm/SKILL.md # hub/agents/gaia/python/gaia_agent/server.py # hub/agents/gaia/python/gaia_agent/stdio.py # hub/agents/gaia/python/tests/test_stdio.py # src/gaia/daemon/app.py # src/gaia/daemon/constants.py # src/gaia/daemon/server.py # tests/test_vlm_integration.py # tests/unit/test_daemon_agents_routes.py # tests/unit/test_daemon_clock_wiring.py
# Conflicts: # docs/reference/eval.mdx
start_advice() replaced stdio.py's lemonade_start_instruction() in #3122 but dropped its punctuation normalization: describe_start_hint() often returns a bare command with no trailing period (e.g. "Run: lemond --port 13305"), so the message read as a run-on sentence into whatever prose the caller appended. Restores the same "add a period only if the hint doesn't already end in one" rule the old function had. Also fixes test_lemonade_start_hint.py, which still patched stdio_mod.describe_start_hint and called the since-removed stdio_mod.lemonade_start_instruction() — both went with #3122's refactor, which routed the "not reachable" messages through start_advice() instead.
…profile pins #4038's docstring trim dropped "call it directly as a tool instead" from run_python's no-tool-access warning, leaving only what NOT to do without the actionable alternative -- restored within the same char budget. Also refreshes test_tool_loader_token_budget.py's doc-profile pins: the tool count drifted from 39 to 44 (and char/token counts with it) as today's merges (#3122, #4021, #3335, #3791, #4376, and others) each added or exposed a doc-profile tool. Re-measured all five values fresh rather than estimating.
… list Their fixes already landed (as part of #3122's daemon work), but the allowlist wasn't pruned, so test_pending_entries_still_need_their_fix has been failing on every main-branch Linux Unit Tests run — the required CI gate for every PR. Only the 3 genuinely-still-pending entries remain.
…md#6991) ## Summary `gaia kill --lemonade` now stops the Lemonade Server GAIA actually uses. Before, it ran the removed `lemonade-server stop`, then killed whatever held port 13305, so it never reached GAIA's own server, which picks its own port, or a server set with `LEMONADE_BASE_URL`. With a remote `LEMONADE_BASE_URL` it even went after port 13305 on this machine. ## Why The issue asks to route the kill through what starts the server and to fail loudly when it can't stop it. A silent fallback to a fixed port is what `CLAUDE.md` rules out. ## Linked issue Closes amd#4437 Two of the issue's four parts were already fixed on `main`: the "start lemonade-server" log text and the `lemonade-server pull` docs. This PR does the other two. ## Changes | Server GAIA uses | Before | Now | |---|---|---| | GAIA's own (no `LEMONADE_BASE_URL` or setup choice) | Port 13305, which it doesn't use | Stopped the way `gaia lemonade embedded stop` does, child processes included | | Chosen, on this machine (`localhost`, a loopback address, `0.0.0.0` or this machine's hostname) | Port 13305, not the chosen port | Stopped by the chosen port, but only a process identified as Lemonade (`lemond`, `LemonadeServer`, `llama-server`). Anything else there, including a Python, Node or Electron dev server, is left running and named with its PID | | Chosen, on another machine | A local port 13305 | Refused with exit 1: "Stop it on that machine" | Nothing running still exits 0, so the documented `gaia kill --lemonade && …` keeps working. The removed-CLI guard test: - Drops the three "pending amd#3122" exemptions. amd#3122 has merged, and those files mention the old CLI only in comments and a docstring. - Skips Python docstrings as well as comments, so those mentions don't need an exemption. - Catches every removed subcommand (`stop`, `list`, `status` and the rest, not only `serve` and `pull`), including the argv form `["lemonade-server", "stop"]` that hid this bug from it. ## Test plan Run in a `python:3.12-slim` container with `.[ui]` and the test tools installed: - [x] `pytest tests/unit/test_kill_lemonade.py tests/unit/test_no_removed_lemonade_cli.py`: 9 passed. - [x] `pytest tests/unit/test_cli_refusal_exit_codes.py`: passes except `test_kill_lemonade_stays_chainable_when_nothing_is_running`, which runs `gaia kill --port 1` and fails in my container because it has no `lsof`. It fails the same way on `main`, and this PR doesn't touch that path. - [x] `python util/lint.py --all`: Black, isort, Flake8, Bandit and the MyPy ratchet pass. Pylint crashed in a parallel worker on my machine; run alone with the same flags, it reports nothing. - [x] `pytest tests/unit -n 3`: 25,993 passed and 31 failed under load. Rerun on their own, 15 still fail the same way on `main` in my container. Two failures were caused by this change and are now fixed: `test_kill_process_by_port.py::test_lemonade_port_stop_propagates_exit_status` tested the removed `lemonade-server` path (deleted; `test_kill_lemonade.py` covers the same exit codes), and the process-safety ratchet needed `cli.py`'s untimed-subprocess count lowered from 3 to 2. With `main`'s `cli.py`, all eight kill tests fail (the old code ran `lemonade-server` in every case), and the widened guard reports what the old one missed: ``` E src/gaia/cli.py:5495: ["lemonade-server", "stop"], E src/gaia/cli.py:5504: log.warning(f"lemonade-server stop failed: {result.stderr}") ``` ## Evidence `gaia kill --lemonade` run from `main` and from this branch, with a stand-in HTTP server on port 8123 and `lsof` installed: ``` ======== main $ LEMONADE_BASE_URL=http://127.0.0.1:8123/api/v1 gaia kill --lemonade ✅ No process is listening on port 13305 (exit 0) $ LEMONADE_BASE_URL=http://10.0.0.5:13305/api/v1 gaia kill --lemonade ✅ No process is listening on port 13305 (exit 0) ======== this PR $ LEMONADE_BASE_URL=http://127.0.0.1:8123/api/v1 gaia kill --lemonade ❌ Refusing to kill 26465 (unknown process) on port 8123: not a GAIA or Lemonade process. Stop it with its own tooling, or kill it by PID if that is really what you want. (exit 1) $ LEMONADE_BASE_URL=http://10.0.0.5:13305/api/v1 gaia kill --lemonade ❌ GAIA uses the Lemonade Server at http://10.0.0.5:13305/api/v1, which runs on another machine, so `gaia kill` can't stop it. Stop it on that machine. (exit 1) ``` The stand-in is a Python HTTP server, so it is refused. (Since this capture, `--lemonade` refuses any listener not identified as Lemonade, not just non-interpreter ones, and the message says it may be your own program.) The point is that it now looks at port 8123 at all. GAIA's own server isn't installed in my container, so that path is covered by the unit tests, not a live run. - [ ] **Agent exposed in the Agent UI**: N/A - [ ] **MCP tools / servers**: N/A - [x] **CLI**: `gaia kill --lemonade`, above. - [ ] **HTTP API / REST**: N/A ## Checklist - [x] I have linked a GitHub issue above (`Closes #N` / `Fixes #N` / `Refs #N`). - [x] I have described **why** this change is being made, not just what changed. - [x] I have run linting and tests locally (`python util/lint.py --all`, `pytest tests/unit/`). - [x] I have attached **real-world evidence matched to the surface I changed** (see Evidence above), or marked each surface N/A. - [x] I have updated documentation if user-visible behavior changed (see [CONTRIBUTING.md](../CONTRIBUTING.md)). The `gaia kill` table in the CLI reference. --------- Co-authored-by: Kalin Ovtcharov <[email protected]>
GAIA needed you to run
lemonade-server servebefore anything worked — a command Lemonade removed in 10.7, so on any current install it fails with "command not found" and the user is left with no path forward. Now the daemon starts the local model server itself, supervises it as a child, and reaps it on shutdown. Launch the TUI, or rungaia chat/gaia llm, on a machine with nothing running: it comes up working, with nothing typed.The daemon owning the process is what makes "one server per machine" real rather than a race that usually works. Front-ends ask over the authenticated loopback channel they already use (
POST /daemon/v1/lemonade/start, host API 1.2); nothing else spawns a server. A server the daemon did not start — one launched from the tray — is attached to and left running, including when the daemon stops.Failures stay loud: not installed, port held by something else, the server died on launch, the daemon unreachable — each names what failed, what to do, and where to look. Nothing degrades quietly to "no LLM".
🔍 Technical details
LemonadeSupervisor(src/gaia/llm/lemonade_supervisor.py) probes, starts the server in its own process group, polls/health, and tree-kills on shutdown — tree-kill because Lemonade spawnsllama-serverchildren, and an orphan still holds the port and the GPU memory the next start needs. No new locking scheme: the daemon is already single-instance, so its in-process lock is the whole story.ensure_lemonade_running(src/gaia/llm/lemonade_service.py) is the one verb. Inside the daemon it uses the supervisor directly; everywhere else it start-or-attaches the daemon and asks.resolve_lemonade()/build_start_command()and treatsStartSpec(argv, env)as opaque. The embeddablelemond ./ --port Nform (PR chore(lemonade): pin Lemonade 11.8.1 #3117) takes a working directory and port the others do not, so nothing here inspects or rebuilds argv — bundled-lemond support arrives behind the same seam for free.LemonadeClient.health_checkgained an optionaltimeout. The client default (900s) is right for generation and catastrophic for a liveness probe: a socket that accepts and never answers would block one for 15 minutes.readiness.py, the email sidecar's/initand/query, the playground), hub agent docs, and ~45 doc-site pages.--ctx-sizewent with it — GAIA pins the window per device profile, so telling a user to set one is wrong advice that looks like it works.Not in scope, worth a follow-up:
gaia initstill starts a server directly (installer/init_command.py), so it can leave an unsupervised one the daemon will attach to and never reap.Test plan
gaia daemon stop && taskkill /F /IM LemonadeServer.exe && rm ~/.gaia/host/instance.json, thengaia llm "..."— answers, having started the daemon and the server itself.gaia-tui run email --query "..."from a stopped server — answers; daemon log showslemonade: starting supervised serverthenlemonade_routes.start.gaia daemon stopreaps the server it started; a tray-launched server survives it (/daemon/v1/lemonade/statusreportssupervised: false).python -m pytest tests/unit/test_lemonade_{supervisor,service}.py tests/unit/test_daemon_lemonade_routes.py tests/unit/test_lemonade_manager_autostart.py— 40 new tests pass.cd tui && go test ./...— 3 failures, all reproduced on a stashed tree (TestKeysDriveTheRightActions,TestHubCatalogLoadSurvivesTheChatView,TestASubprocessAgentIsNotGated).TestClient).grep -rn "lemonade-server serve" docs/ src/ hub/returns only comments explaining why the command is dead.