Skip to content

feat(daemon): start and supervise the local model server - #3122

Merged
kovtcharov-amd merged 10 commits into
mainfrom
claudia/task-47a27e1c
Sep 26, 2026
Merged

kovtcharov-amd merged 10 commits into
mainfrom
claudia/task-47a27e1c

Conversation

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

GAIA needed you to run lemonade-server serve before 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 run gaia 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 spawns llama-server children, 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.
  • Launch resolution is unchanged and untouched: everything goes through resolve_lemonade() / build_start_command() and treats StartSpec(argv, env) as opaque. The embeddable lemond ./ --port N form (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_check gained an optional timeout. 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.
  • The stale-command sweep covers runtime messages (readiness.py, the email sidecar's /init and /query, the playground), hub agent docs, and ~45 doc-site pages. --ctx-size went 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 init still 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

  • Cold start, nothing running: gaia daemon stop && taskkill /F /IM LemonadeServer.exe && rm ~/.gaia/host/instance.json, then gaia llm "..." — answers, having started the daemon and the server itself.
  • Cold start through the TUI's readiness gate: gaia-tui run email --query "..." from a stopped server — answers; daemon log shows lemonade: starting supervised server then lemonade_routes.start.
  • Go client against a live daemon: cold 9.8s, warm 26ms (one probe).
  • gaia daemon stop reaps the server it started; a tray-launched server survives it (/daemon/v1/lemonade/status reports supervised: false).
  • Daemon boot alone does not start a server — it is on demand.
  • 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).
  • Wider Python suites match their pre-existing baseline exactly (40 failures, all reproduced with the branch stashed — Windows path assumptions and the unit-test socket guard blocking TestClient).
  • Reviewer: grep -rn "lemonade-server serve" docs/ src/ hub/ returns only comments explaining why the command is dead.

@github-actions github-actions Bot added documentation Documentation changes devops DevOps/infrastructure changes llm LLM backend changes tests Test changes performance Performance-critical changes agents agent::email Email agent changes tui Go terminal UI (gaia-tui) daemon Daemon supervisor / sidecar control plane sidecar Agent sidecar contract / harness labels Aug 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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 (gaia tui run … --query …) still gives readiness a 90-second budget, while the interactive gate was raised to 210 seconds for exactly this change. On a machine where the model server is down, the script's clock runs out while the start is still in progress — so a cold start that was about to succeed gets aborted, and the message shown blames the background service rather than naming the real cause. That's the specific failure the PR's own reasoning says to avoid; the two paths just need the same number.

Three smaller things worth fixing before merge:

  • The new daemon routes aren't listed in the CLI reference's table of daemon routes, even though that table is right there in a file this PR already edits.
  • A documented terminal transcript for the scripted path is now wrong: it still shows the old "here's how to start it" wording and claims the command fails "after about a second", neither of which is true once GAIA tries the start first.
  • One test's "does the error say what to do" check can no longer fail — the list of accepted answers picked up a word that the previous line already guarantees is present.

Real-world evidence

Strong, 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 gaia llm, the Go transport against the live daemon, and the reworded readiness hint on the email sidecar's real route. A spot-regression pass covered sibling daemon and email routes plus the changed shutdown order.

Deferred to the strix-halo lane, as marked: any path where a server actually comes up (started: true, supervised pid, tree-kill on shutdown), and rendered pixels. Not covered at all — the scripted gaia tui run path, which is where the blocking issue above lives; the Go check drove the transport directly rather than through that path's deadline.

🔍 Technical details

Issues found

🟡 Important — the one-shot readiness deadline was not raised with the gate's (tui/internal/ui/oneshot.go:494)

checkTimeout went 90s → 210s in preflight/model.go:34 to cover checkInit → autoStartLemonade. readinessCheckTimeout — same preflight.Check call, from oneshot.go:536 — is still 90s, and the comment above it states the invariant this breaks: "Same value as the gate's checkTimeout, over the same call — two paths asking the same question must not disagree about how long the answer may take."

Failure: gaia tui run email --query … with Lemonade down. StartLemonade uses lemonadeStartHeaderTimeout = 150s against a daemon whose budget is DEFAULT_START_TIMEOUT_S = 120s, but checkCtx cancels at 90s. The cancellation is not a *LemonadeStartRefused, so autoStartLemonade takes the !errors.As(err, &refused) branch and renders "cannot be started" diagnosed against the background service — the exact wrong-cause outcome lemonadeStartHeaderTimeout's comment exists to prevent.

	readinessCheckTimeout = 210 * time.Second

The comment just above it should keep naming checkTimeout as the source of truth.

🟡 Important — new daemon routes missing from the documented control plane (docs/reference/cli.mdx:2773)

The table enumerating /daemon/v1/* gained nothing for POST /daemon/v1/lemonade/start or GET /daemon/v1/lemonade/status, and the DAEMON_API_VERSION 1.1 → 1.2 bump isn't mentioned. This file is already in the diff.

| `GET /daemon/v1/status` | pid / port / uptime / API version |
| `POST /daemon/v1/lemonade/start` | start-or-attach the local model server (blocking; 503 + `detail` on refusal; optional `{"ctx_size": N}`, defaults to the device profile). Host API ≥ 1.2 |
| `GET /daemon/v1/lemonade/status` | whether this daemon supervises a server, its pid, and its log path |

🟡 Important — documented gaia tui run transcript is stale (docs/reference/cli.mdx:2934-2946, duplicated at 3230-3242)

The PR swapped the run: line but left the rest describing pre-auto-start behaviour. After this change checkInit calls autoStartLemonade first, so the row reads not running — GAIA could not start it with detail GAIA tried to start the local model server and could not. and the remedy is lemonadeAutoStartFailedRemedy(detail) — the daemon's own refusal, with gaia init attached only when no Lemonade is installed. The <the start command resolved for this machine> replacement therefore describes a remedy this path no longer produces.

The prose at 2934 / 3230 — "Against an unreachable dependency that is about a second" — and $ echo $? # 1, after about a second are also wrong now: the down-server case attempts a start first. Both copies need the update (CLAUDE.md: a functional change updates every doc that describes it).

🟡 Important — the "what to do" assertion can no longer fail (hub/agents/email/python/tests/test_query_route.py:478)

Line 473 already asserts "lemonade server is not reachable" in lower, so the "lemonade" alternative on 478 is always satisfied and the actionable-remedy leg of the #2139 contract is unasserted. The intent in the comment ("names SOME real remedy") is right; the substring list is what's too loose.

    assert any(c in lower for c in ("gaia daemon start", "gaia init"))

🟢 Nit — ctx_size=0 is guarded on two paths and forwarded on the third

StartRequest.ctx_size has gt=0 and _ask_the_daemon drops a falsy value (lemonade_service.py:2498 in-diff), but ensure_lemonade_running → supervisor.ensure_running(ctx_size=0) → build_start_command emits LEMONADE_CTX_SIZE=0 / --ctx-size 0. src/gaia/ui/server.py:259 really does pass min_context_size=0; only the process boundary keeps it off that branch today. Normalising non-positive to None in ensure_lemonade_running closes it.

🟢 Nit — comment at the Agent UI's Lemonade probe is now wrong (src/gaia/ui/server.py:254-259)

"Pre-warm LemonadeManager — check reachability only" / "Only check reachability — don't trigger model reloads". It now starts the server and, via daemon_client.start_or_attach(), can spawn a daemon — with the "Checking LLM server" startup task visible for up to ~150s.

🟢 Nit — shutdown() waits on the same lock a 120s start holds (lemonade_supervisor.py:2779 in-diff)

_build_deregister → lemonade.shutdown() blocks on self._lock, which ensure_running can hold for the full start budget plus the 20s occupied-port grace. gaia daemon stop during a cold start can therefore appear hung for ~140s. Reasonable as designed (don't kill mid-start), but worth a line saying so, or a bounded acquire.

Strengths

  • The single-owner argument is carried through, not asserted. install_supervisor for in-daemon callers vs. _ask_the_daemon for everyone else means no second process can spawn a server, and owned is reported by the daemon rather than assumed — so a server the user launched from the tray is attached to and never reaped.
  • Every failure branch is a specific, actionable error. Not-installed, remote URL, non-default port, stranger-on-the-port, died-on-launch and never-answered each name what failed, what to do and where to look — and _start_failed_error renders the command through the launcher so the env-carried context window survives a copy-paste. No silent fallbacks anywhere in the new code.
  • Test coverage is genuinely thorough, including the failure shapes that usually go untested: launcher hands off with exit 0, concurrent callers start exactly one server, shutdown never kills a found server, a real spawn inherits the parent environment, and a probe against a closed port gives up promptly. The health_check(timeout=…) addition with its (2, 5) probe budget is the right fix for the 15-minute-liveness-probe trap and is called out where it matters.
  • The API-version test was fixed rather than re-pinned — turning == "1.1" into a floor check removes the incentive to skip MINOR bumps, which is what would actually break clients.

@github-actions

github-actions Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Skill audit

Skill Verdict Claimed tier Cleared tiers Findings Rules
hub/agents/email/npm ✅ ALLOW experimental experimental, community 2 medium, 1 info code.suppression, supply.undeclared_dependency
hub/agents/gaia/npm ✅ ALLOW experimental experimental 1 high body.injection.credential_request

✅ 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 skill-audit-reports artifact from this run. Offending source text is withheld from CI everywhere — reproduce it locally with gaia skill audit <dir> --show-snippets.

@github-actions

Copy link
Copy Markdown
Contributor

Approve with suggestions

The daemon supervision feature is well-designed end-to-end: fail-loud errors, correct lock discipline in _autostart mirroring _try_preload_with_ctx, daemon-side process ownership guards, and a thorough doc sweep. One test assertion introduced in this PR no longer enforces the contract it claims to.


🟡 The "what to do" assertion in _assert_actionable_lemonade_detail is always true

The middle predicate of the three-part contract check passes trivially — "lemonade" appears in every Lemonade-down error message because the immediately-preceding assertion ("lemonade server is not reachable" in lower) already guarantees it. Any error message that names Lemonade as down will satisfy any(c in lower for c in ("gaia daemon start", "gaia init", "lemonade")) even if it gives the user no actionable next step. The "names SOME real remedy" contract is unenforced.

Before this PR the assertion was "lemonade-server serve" in lower or "gaia init" in lower — specific strings that could actually fail. The new form was clearly meant to handle per-machine describe_start_hint() output, but the "lemonade" catch-all defeats the intent.

🔍 Technical details

hub/agents/email/python/tests/test_query_route.py:478:

# Current (always true once the first assert passes)
assert any(c in lower for c in ("gaia daemon start", "gaia init", "lemonade"))

"lemonade server is not reachable" in lower (line 473) contains "lemonade", so the any() is always True at line 478. No matter what the error message's remedy section says, the assertion cannot fail.

The fix is to drop "lemonade" from the tuple. "gaia daemon start" and "gaia init" are both stable strings that appear in the current start_advice() output and will fail meaningfully if the remedy is stripped:

assert any(c in lower for c in ("gaia daemon start", "gaia init"))

If describe_start_hint().instruction could produce output containing neither, the right answer is to mock start_advice() in the relevant tests and return a fixed string — not to accept any string that happens to mention Lemonade.

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator Author

Rebased onto current main, which brought the flagship agent package (#3120) carrying six fresh copies of lemonade-server serve — and six tests asserting it. Fixed in 03499dd: a suite that pins a dead literal reports the remedy as verified every time it runs, which is how the command survived removal in the first place.

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 gaia llm and the daemon-relay gate both come up with nothing typed; go test ./... is fully green (the three failures I'd recorded as pre-existing are gone on this base).

@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

Note: The gh CLI was unavailable in this run (bwrap sandbox failure), so I could not verify whether a prior review exists. This review covers the full PR. Ignore if a prior review was already posted.

This introduces daemon-owned supervision of the local model server: LemonadeSupervisor starts/reaps Lemonade as a child, lemonade_service.py routes every caller (daemon-internal, CLI, TUI) through one verb, and lemonade_routes.py exposes POST /daemon/v1/lemonade/start as the only front-end entry point. The architecture is correct — the daemon is already single-instance, so no second lock is needed for cross-process exclusion. The lock in LemonadeSupervisor serializes the daemon's own threads, not processes. Test coverage is thorough and notably includes a real-spawn test (test_a_real_spawn_inherits_the_parent_environment_and_carries_the_ctx_window) and a real-client-signature test (test_the_probe_call_is_one_the_real_client_actually_accepts) that catch the class of bug mocks cannot — both directly addressing CLAUDE.md's "mocks prove we called it" rule.

🟡 Missing CLI evidence — the PR changes user-observable behavior at every GAIA entry point that calls LemonadeManager.ensure_ready: a stopped Lemonade previously printed instructions and returned False; it now starts the server. The rubric requires real gaia <subcommand> output showing the before and after. test_lemonade_manager_autostart.py mocks ensure_lemonade_running, so it proves the call was made but not that the server actually started. If this evidence is in the PR description or a linked comment, ignore this finding — I could not fetch the description in this run.

🟢 Nit: lemonade_service.py imports _probe by name from lemonade_supervisor.py. A private symbol crossing module boundaries is a soft coupling violation — _probe is a public operation (does Lemonade answer health right now?) that happens to have a private name. Renaming it to probe_lemonade removes the ambiguity.

🟢 Nit: checkTimeout was raised from 90 s to 210 s in model.go. The comment explaining why is good, but the constant daemonStartBudget is duplicated between model.go and autostart_test.go — a single exported constant from lemonade_supervisor (the Python side already has DEFAULT_START_TIMEOUT_S) would eliminate the skew risk if the timeout changes again.

🔍 Technical details

Evidence gap (lemonade_manager.py:888–962, test_lemonade_manager_autostart.py): test_a_stopped_server_is_started_rather_than_described patches ensure_lemonade_running at the module level and verifies ctx_size reaches the call. This is the correct shape for a unit test. The rubric's "real-world evidence" requirement is separate — it asks for a live terminal trace showing gaia llm (or similar) auto-starting Lemonade when it is down, which is the surface that changed from the user's perspective.

Private import (lemonade_service.py:9): from gaia.llm.lemonade_supervisor import ... _probe — the underscore signals "don't import me". Suggested rename: probe_lemonade(client) -> bool in lemonade_supervisor.py, exported and imported publicly.

checkTimeout duplication: tui/internal/ui/preflight/model.go:36 has checkTimeout = 210 * time.Second; autostart_test.go:4188 has const daemonStartBudget = 120 * time.Second. When DEFAULT_START_TIMEOUT_S on the Python side changes, the Go test and the timeout ceiling both need manual updates. Not a blocking issue — the invariant test TestTheStartCallOutlastsTheDaemonsOwnStartBudget would catch a violation — but a shared constant would be cleaner.

Shutdown ordering (server.py:199–213): lemonade.shutdown() is called AFTER registry.shutdown_all() — correct. A model call mid-sidecar-teardown would see the server die at exactly the worst moment; ordering it last avoids a wave of connection errors in the logs. The comment explains this.

_probe broad exception catch (lemonade_supervisor.py:~582): except Exception as e: # noqa: BLE001 — flagged but intentionally sound here. ANY failure (connection refused, timeout, parse error) means "server is not answering", and the exception is logged at DEBUG level. This is not a silent fallback: False is the correct semantic result, not a guess. The # noqa note acknowledges the violation. Pre-existing tech debt in src/gaia/ui/ is worse.

@github-actions

Copy link
Copy Markdown
Contributor

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 _autostart (drop-lock-for-duration, matching _try_preload_with_ctx) is correct, and the _require_supervisable_port guard in the supervisor correctly refuses non-default-port requests. Test coverage of the new code paths (supervisor, service, daemon routes, manager autostart) is comprehensive. Documentation is updated consistently across all surfaces.

One concrete correctness gap in the SD integration test prerequisites, noted below.

🟡 The SD integration test is missing its model-pull step. gaia daemon start + gaia init replaces lemonade-server serve + lemonade-server pull SD-Turbo, but gaia init downloads the default chat model (Gemma-4-E4B-it-GGUF), not SD-Turbo. The test's own docstring says it requires "SD-Turbo model available", so anyone following the new prerequisites will set up for that test and hit an immediate skip/fail.

🔍 Technical details

tests/integration/test_sd_integration.py (lines 10–14 after the change):

Prerequisites:
    gaia daemon start
    gaia init

The test module docstring (line 5) still reads: "These tests require Lemonade Server running with SD-Turbo model available." gaia init with no profile pulls the default Gemma-4-E4B-it-GGUF, not SD-Turbo. The original second step (lemonade-server pull SD-Turbo) needed a replacement, not just removal.

Fix: add the equivalent SD model pull. If gaia download covers it:

Prerequisites:
    gaia daemon start
    gaia download SD-Turbo

or, if gaia init --profile sd exists and does the right thing, use that. The exact command may depend on the current SD install path, but the step must survive.

No other blocking issues found. The _is_loopback guard (remote-URL refusal), the _occupied_port_grace logic (attach-if-up-within-window), the start_new_session / CREATE_NEW_PROCESS_GROUP tree-kill correctness, the _wait_for_health exit-on-nonzero-exit-code path, and the daemon-side _profile_ctx_size → GaiaConfigError 503 (instead of guessing the wrong profile) are all correct.

@github-actions github-actions Bot added dependencies Dependency updates cli CLI changes labels Aug 28, 2026
@github-actions

Copy link
Copy Markdown
Contributor

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 details

Lock discipline in _autostart — the finally: lock.acquire() inside _autostart is correct and mirrors _try_preload_with_ctx. Worth confirming for anyone reading lemonade_manager.py:965: Python executes finally before the return False in the enclosing except block, so the lock is reacquired before the function exits on failure.

start_advice() trailing clause — readiness.py:1513 always appends "Otherwise: {describe_start_hint().instruction}" even when the daemon path is fully operational. The phrase "Otherwise:" reads a bit odd after "GAIA starts it automatically". No functional impact (tests pass, content is accurate), but consider "If it still won't come up: {describe_start_hint().instruction}" for clarity.

uv.lock Python floor rollback — uv.lock changes requires-python from >=3.13 to >=3.12. If this was generated by a CI environment rather than intentional, it is worth a sanity-check: the project's stated minimum is 3.10 (setup.py), so 3.12 is consistent, but a drift between the lock file and the actual runtime matrix can produce subtle surprises.

Timeout ordering test — autostart_test.go::TestTheStartCallOutlastsTheDaemonsOwnStartBudget directly asserts lemonadeStartHeaderTimeout > daemonStartBudget and checkTimeout > lemonadeStartHeaderTimeout. This is the right way to pin a property that is easy to regress by changing one constant without the other. Good pattern.

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator Author

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. ensure_ready asked the daemon to start the model server, and that ask start-or-attached a daemon. So constructing an agent — in a unit test, in any library caller — 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 passing; the only symptom was a timeout. Fixed in ca58e3c: a readiness check may only attach to what is already running, and the CLI opts in explicitly because a user-facing command is where bringing up a background service belongs. gaia llm still comes up on a cold machine; the down path is now ~1s slower than before this branch rather than ~26s.

Also fixed: three assertions this change invalidated, in files this machine cannot run (the tests/unit/agents/ tree fails to collect locally because the editable install resolves gaia_agent_email to another worktree, and every TestClient test is blocked by the Windows socket guard). The deregister-order test now pins where the model server is reaped — after the sidecars, so an agent finishing a model call mid-teardown doesn't have the server pulled out from under it.

77 pass, 1 fail, and the failure is the runner. rag_quality + … dies in its preflight: llama-server cannot load user.embeddinggemma-300m-GGUF, and the job's own error says "cannot be served on this runner under any condition tried… do not re-run hoping it clears." The eval never executed, so the integrity gate correctly refused to compare. This workflow has no recent green run on any branch (skipped / startup_failure / action_required), so there is no baseline it regressed from.

My only touch anywhere near it is health_check gaining an optional timeout; the default path is byte-identical (timeout is None → the original call), and load_model never calls health_check. Happy to be told otherwise if someone reads it differently.

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator Author

Both remaining CI failures are environmental, and each names itself:

  • Email Triage Eval — anthropic.BadRequestError: Your credit balance is too low to access the Anthropic API. The judge never ran. Worth raising on its own: this will silently blunt every judge-scored eval in the repo until the account is topped up. The harness behaved correctly — it reported "no verdict produced… read it as missing evidence, not as a pass" rather than going green on an eval that did not happen.
  • rag_quality + … — llama-server cannot load user.embeddinggemma-300m-GGUF on that runner; the job's own message says "cannot be served under any condition tried… do not re-run hoping it clears." The eval never executed and the integrity gate refused to compare. No recent green run on any branch, so nothing regressed.

77 pass, 2 fail, zero code failures. Ready for review.

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

🟡 The three "Request changes" items from the previous review are still open — none were fixed in this push.

The most important: readinessCheckTimeout in tui/internal/ui/oneshot.go is still 90 seconds. The interactive gate's checkTimeout was raised to 210 s specifically to cover the auto-start path, and the comment directly above readinessCheckTimeout states the invariant ("same value as the gate's checkTimeout, over the same call — two paths must not disagree"). A scripted gaia tui run --query against a cold server cancels at 90 s while the start is still in progress, producing the wrong-cause error the PR explicitly set out to prevent.

The other two open items: the _assert_actionable_lemonade_detail test in hub/agents/email/python/tests/test_query_route.py still includes "lemonade" as an accepted remedy string (line 478), which is always satisfied by the preceding assertion — the actionable-remedy contract remains unenforced. And the daemon control-plane table in docs/reference/cli.mdx still has no rows for POST /daemon/v1/lemonade/start or GET /daemon/v1/lemonade/status, nor any mention of the API version bump.

🔍 Technical details

tui/internal/ui/oneshot.go:505

	readinessCheckTimeout = 210 * time.Second

The comment on lines 502–504 names this invariant; update it to reference the new value.

hub/agents/email/python/tests/test_query_route.py:478

    assert any(c in lower for c in ("gaia daemon start", "gaia init"))

"lemonade" is already guaranteed by line 473 — it cannot discriminate.

docs/reference/cli.mdx — add after the existing /daemon/v1/status row:

| `POST /daemon/v1/lemonade/start` | start-or-attach the local model server (blocking; 503 + `detail` on refusal). Host API ≥ 1.2 |
| `GET /daemon/v1/lemonade/status` | whether this daemon supervises a server, its pid, and its log path |

The stale terminal transcript at cli.mdx:2758-2759 ("after about a second", <the start command resolved for this machine>) was also flagged and is unchanged.

Ovtcharov added 4 commits September 8, 2026 09:37
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.
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator Author

Merged main in — conflicts resolved, one of them worth flagging.

main landed its own auto-start test file at the same path as this branch's. They are not rival implementations: main tests the local runner (the TUI spawns the launcher itself), this branch tests the daemon runner (the TUI asks gaia daemon to). Both paths exist and both should stay covered, so the two test bodies now live side by side in separate files rather than one overwriting the other.

One test on this branch also needed a fix to survive the merge — unrelated to the feature, just a mock that main grew a new call against.

🔍 Technical details
  • tui/internal/ui/preflight/autostart_test.go — add/add. Kept main's body in place (TestCanAutoStart, stubProbe, winProbeWithServer, linuxProbeWithUnit, TestMain); moved this branch's body to a new daemon_autostart_test.go with a header naming which runner it protects. Zero identifier overlap between the two, verified before splitting. Local path: local.go:325 → tryAutoStartLemonade. Daemon path: check.go:537 → autoStartLemonade → t.StartLemonade(ctx), with LemonadeStartRefused in transport.go.
  • tests/unit/test_lemonade_manager_autostart.py — main's _honest_context_size() now calls client.get_model_max_context_window() ([Bug]: GAIA reports 65,536-token context while effective llama.cpp context remains 40,960 #2992 ctx clamping). The MagicMock here returned a MagicMock for it, so the clamp comparison raised TypeError: '<=' not supported between instances of 'MagicMock' and 'int'. Stubbed it to None, matching the convention already used in tests/unit/test_lemonade_manager_preload.py:63. 4/4 pass.
  • hub/agents/gaia/python/gaia_agent/server.py — kept both sides' imports; both start_advice and route_console_logging_to_stderr are used in the merged file.
  • Docs conflicts (docs/playbooks/chat-agent/part-1-getting-started.mdx, hub/agents/email/npm/README.md) — main's wording contradicted this branch's prose about who starts the model server; reworded rather than picking a side.

Go build / vet / tests green. Python failure set is byte-identical to a pristine origin/main worktree (36 pre-existing Windows-only TestClient failures from the _block_network fixture vs ProactorEventLoop); zero new failures.

kovtcharov added a commit to kovtcharov/gaia that referenced this pull request Sep 24, 2026
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]>
kovtcharov-amd pushed a commit to kovtcharov/gaia that referenced this pull request Sep 25, 2026
…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]>
pull Bot pushed a commit to bhardwajRahul/gaia that referenced this pull request Sep 25, 2026
…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.
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Sep 26, 2026
hub/agents/gaia/npm/SKILL.md, SCORECARD.md, server.py, stdio.py and
gen_scorecard.py no longer name the removed lemonade-server CLI --
their fixes landed via amd#4181/amd#4293/amd#3122. Only the email-side entries
are still genuinely pending.
kovtcharov added a commit to kovtcharov/gaia that referenced this pull request Sep 26, 2026
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]>
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Sep 26, 2026
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
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Sep 26, 2026
Merged via the queue into main with commit f687b81 Sep 26, 2026
67 of 72 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the claudia/task-47a27e1c branch September 26, 2026 09:19
kovtcharov-amd added a commit that referenced this pull request Sep 28, 2026
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.
kovtcharov-amd added a commit that referenced this pull request Sep 28, 2026
…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.
kovtcharov-amd added a commit that referenced this pull request Sep 29, 2026
… 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.
kovtcharov pushed a commit to kovtcharov/gaia that referenced this pull request Nov 10, 2026
…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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent::email Email agent changes agents cli CLI changes daemon Daemon supervisor / sidecar control plane dependencies Dependency updates devops DevOps/infrastructure changes documentation Documentation changes llm LLM backend changes performance Performance-critical changes sidecar Agent sidecar contract / harness tests Test changes tui Go terminal UI (gaia-tui)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants