Skip to content

fix(ui): busy model server is not reported as stopped; polls stop piling up - #5317

Merged
kovtcharov-amd merged 9 commits into
amd:mainfrom
kovtcharov:claude/rel-webui-status-poll
Oct 19, 2026
Merged

kovtcharov-amd merged 9 commits into
amd:mainfrom
kovtcharov:claude/rel-webui-status-poll

Conversation

@kovtcharov

@kovtcharov kovtcharov commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Before: on a busy machine the Agent UI's 5 s status poll stacked a new request behind every slow one, and the banner then said the model server had stopped, or that the connection to GAIA was lost, when both were only busy. After: one status request runs at a time and the poll backs off while answers are slow. A backend that keeps answering late reads "GAIA is slow to answer". A model server that is listening but slow reads "not answering, may be busy", keeps the reason, and offers the restart command only for if it stays that way. "Stopped responding" and "Lost the connection" now mean nothing is listening. Check again shows "Checking…" until it answers. Lands after v0.25.0.

Reproduced by src/__tests__/App.statusPoll.test.tsx: on main, 5 status requests are in flight at once, 13 probes run in 60 s against a busy server, and the busy wording never appears. All pass here.

Test plan

  • npx vitest run in src/gaia/apps/webui: 872 passed; npx tsc --noEmit clean
  • App.statusPoll.test.tsx (6), ConnectionBanner.test.tsx and statusPoll.test.ts: three timeouts in a row read as slow, not lost; a 45 s answer is accepted; stopping the poll aborts the request in flight and reports nothing; Check again shows progress
  • Live, Vite :5319 against a fake backend: with a busy model server the probes ran at 0, 11 and 32 s, and the banner read "The model server is not answering (Lemonade health query failed)... If it stays this way, restart it: ...". With 45 s status answers there was never more than one request in flight.
🔍 Technical details
  • services/statusPoll.ts: single-flight check(), a setTimeout chain, a 60 s AbortSignal per request (the status handler's sequential probes, health 10 + models 10 + catalog 5 + stats 3 + system-info 3, already exceed 30 s), backoff 5→10→20→30 s while slow. A generation counter keeps a StrictMode double start from making two chains.
  • "Unresponsive" is lemonade_running: false with lemonade_error set. The backend sets that for a probe timeout as well as for a non-200 answer or an httpx.ConnectTimeout, so the banner keeps the remedy. A backend field telling these apart, and a bound on the handler's total time, are with the UI-backend reliability session.
  • Outcomes: a refused request, or a 502 from a proxy or tunnel with nothing behind it, is unreachable; a 500/503 is "answered with an error"; a timeout or a gateway 504 is slow (five minutes of it is lost).
  • Merge note: feat(ui): model picker shows real device, fit and live status #5244 removes the setDetectedDevices line that moved into applyStatus, a one-line conflict in App.tsx.

@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

On a busy machine, the Agent UI used to stack up status requests and then wrongly tell the user the model server had stopped. This PR fixes that: only one status check runs at a time, checks slow down while answers are slow, and a server that is running but slow now reads "not answering, may be busy" while still showing the restart command. The fix matches what the backend actually reports. "Nothing is listening" (connection refused) still shows "stopped responding", and every other failed health check now shows the softer wording. The new tests reproduce the pile-up and the wrong wording.

Nothing blocks the merge. Two small things to consider:

  • A health check that fails for a reason that isn't load, such as a wrong API key, will now also say "may be busy". The PR already names this limit; a follow-up backend field that tells a timeout apart from an error would let the banner be exact.
  • The banner text changed, but the PR has no screenshot of it, only a text description from a fake-backend run. Please add a before→after screenshot when one is easy to capture.

Real-world evidence

N/A: no evidence bundle was produced for this run. This is an Agent UI change, and its rendered screenshot is deferred to the strix-halo lane. The verdict rests on static review, plus the author's description of a live Vite run against a fake backend: probes at 0, 11 and 32 s, the "not answering" banner, and 45 s answers cut off at 30 s with no overlap.

🔍 Technical details

Issues found

🟢 A throw in the outcome handler becomes an unhandled rejection (services/statusPoll.ts:428-446). If onOutcome throws, inFlight rejects. tick's void check().finally(...) still reschedules, but it re-raises the rejection, which nobody catches. The risk is low because applyStatus only calls setters. Logging it keeps the failure visible without stopping the poll:

    const tick = (gen: number) => {
        check()
            .catch((err) => log.system.error('System status handler failed', err))
            .finally(() => {
                if (gen === generation) timer = setTimeout(() => tick(gen), nextDelay());
            });
    };

(This needs import { log } from '../utils/logger';.)

🟢 "Unresponsive" covers every non-200 health answer (statusPoll.ts:384-387, ConnectionBanner.tsx:269). routers/system.py:788 and :800 set the same "Lemonade health query failed" for a timeout, a non-200 answer such as a 401 from a mismatched LEMONADE_API_KEY, and any other exception. Only httpx.ConnectError leaves lemonade_error unset. Because the banner keeps the restart remedy, the wording stays safe. It just can't say which case it is; this is the follow-up the PR already describes.

🟢 Retry doesn't reset the backoff. onRetry={checkSystemStatus} probes right away, but the timer already scheduled (up to 30 s away) still runs. A successful retry clears slowStreak, so the next delay after that is 5 s again. This is fine as it is; noted so it isn't mistaken for a bug later.

Strengths

  • The generation counter handles StrictMode's start→stop→start correctly. The second chain shares the first chain's in-flight probe, and the first chain's finally doesn't reschedule.
  • Separating slow (aborted by our own 30 s timer, checked through controller.signal.aborted) from unreachable keeps "connection refused → disconnected right away" while letting a busy backend miss two answers.
  • The tests drive the real App with fake timers and check what the user would see (maxPending, request counts, banner text), not internals. They also cover the "still shows the start command when it's down" path.

@kovtcharov

Copy link
Copy Markdown
Contributor Author

Review follow-up: a backend that keeps answering late now reads "GAIA is slow to answer" and is never marked lost. Each change below has a test that fails without it.

  • Repeated status timeouts show the slow banner; only a refused request means unreachable
  • The request limit is 60 s, above the status handler's own sequential probes (31 s+)
  • Stopping the poll aborts the request in flight and reports nothing for it
  • Check again / Retry shows "Checking…" until it answers; the test's sequence comment is fixed

Not in this PR, and passed to the UI-backend session that owns system.py:

  • counting httpx.ConnectTimeout as down;
  • a field that tells a probe timeout apart from an error answer, which would also settle the bot's wrong-API-key point;
  • a bound on the handler's total time.

The banner keeps the restart remedy until that field exists, so no case loses its next step.

@kovtcharov

Copy link
Copy Markdown
Contributor Author

Second review round: a backend that accepts connections but never answers no longer stays on "slow to answer" forever. After five minutes with no status answer, the banner switches to "Lost the connection to GAIA" and its "check that GAIA is still running" step (test: calls a backend that has answered nothing for five minutes lost).

@kovtcharov

Copy link
Copy Markdown
Contributor Author

Third review round, each fix with a test that fails without it:

  • A 5xx answer to the status request is its own outcome, not "unreachable". The banner says "GAIA's backend answered with an error (HTTP n: …)" and the poll backs off. The review's repro is in statusPoll.test.ts.
  • After an outage, a slow answer marks the backend connected again, so "Lost the connection" doesn't stick.
  • An outcome handler that throws is logged, and the poll carries on.

#5344 (UI backend) adds a lemonade_probe field (ok/down/timed_out/error). Once it lands, the model-server banner can read it instead of inferring from lemonade_error.

@github-actions

Copy link
Copy Markdown
Contributor

🟡 A gateway 504 now marks a busy backend as lost. A 504 means a proxy or tunnel did reach the backend but gave up waiting for it, which is the "slow, not gone" case this PR exists to fix. The status handler can take 31 s+ under load, so behind any gateway with a shorter timeout, a single slow poll now drops the connection at once (no five-minute grace) and turns off the backoff, so the poll keeps hitting the busy machine every 5 s. Suggest treating only 502 as unreachable and 504 as slow.

🔍 Technical details
  • statusPoll.ts probe(): 504 now falls through to { kind: 'unreachable' }. In App.tsx applyStatus, unreachable sets backendConnected=false on the first occurrence and resets slowSince, which skips the BACKEND_SILENT_LOST_MS window that slow gets. isSlow() also ignores unreachable, so nextDelay() stays at 5 s.
  • 502 (the upstream refused or reset the connection) is a fair match for "nothing listening". 504 (upstream timeout) is closer to the client-side abort that already returns { kind: 'slow' }.
if (httpStatus === 504) return { kind: 'slow' };

The it.each([502, 504]) test would split the same way.

@kovtcharov

Copy link
Copy Markdown
Contributor Author

Round-3 review: a 502 or 504 now reads as an unreachable backend. The status handler never sends those; a dev proxy, reverse proxy or tunnel does when nothing answers behind it. A 500 or 503 still reads "answered with an error". The tests pin both pairs, replacing the old 504-as-error case.

Nits fixed:

  • The single-flight guard is tested, with Check again pressed during a slow probe.
  • A restart right after a stop (React StrictMode) sends a fresh request at once instead of reusing the cancelled one.

@kovtcharov

Copy link
Copy Markdown
Contributor Author

Took the round-4 suggestion: a backend coming back from an outage that still hasn't answered shows "GAIA is slow to answer" at once, instead of no banner for the 2–3 minutes until three timeouts. Any answer, including an HTTP error, clears it. The test that pinned the old behaviour now expects the slow banner. This push also re-runs the Linux unit check that hit the known timing flake.

kovtcharov and others added 7 commits October 18, 2026 23:26
…olls stop piling up

On a busy machine the 5 s status poll stacked a new request behind every slow one, and after three slow answers the banner said the model server stopped and told the user to start it, when it was only busy.

- One status request in flight at a time, each bounded at 30 s; the poll backs off to 10, 20, then 30 s while answers are slow, so it adds no load to a busy server.
- A slow backend counts as lost only after three missed answers in a row; a refused connection is still immediate.
- A model server that is listening but fails its health check reads "not answering ... may be busy", keeps the reason, and offers the restart command only for if it stays that way; one that is not listening still reads "stopped responding".
…s it is checking

Three status requests in a row that timed out marked the backend disconnected, so the banner said "Lost the connection to GAIA" about a backend that was only busy. The 30 s request limit was also below what the status handler itself can spend on its sequential probes.

- Repeated timeouts now show "GAIA is slow to answer" and leave the connection state alone; only a refused request means unreachable.
- Each status request gets 60 s, above the handler's health, models, catalog, stats and device probes.
- Stopping the poll aborts the request in flight and reports nothing for it.
- Check again and Retry show "Checking…" until the check answers.
…es, not slow forever

Review found that a backend which accepts connections but never answers stayed on "GAIA is slow to answer… GAIA keeps checking" with no end and no next step. Busy does not last that long: after five minutes with no status answer, the banner switches to "Lost the connection to GAIA", which tells the user to check that GAIA is running and retry.
…ction banner recovers after an outage

The second review found two wrong banners. A 500/504 answer to the status request was classed with a refused connection, so the banner said "Lost the connection to GAIA" about a backend that was answering. And after an outage, a slow answer never marked the backend connected again, so "lost" stayed up while it was back.

- An HTTP error from the backend is its own outcome: the banner says "GAIA's backend answered with an error (HTTP n: …)", and the poll backs off as it does for slow answers.
- A slow answer marks the backend connected again; only five minutes of nothing turns it back to lost.
- An outcome handler that throws is logged and the poll keeps going, instead of an unhandled rejection.
The status handler never raises 502 or 504 itself; a dev proxy, reverse proxy or tunnel sends them when nothing answers behind it. They were classed as an erroring backend ("may be overloaded") with the connection kept, so with Vite running and no backend the banner never said the connection was lost. They now count as unreachable; 500 and 503 stay "answered with an error".

Also from the review: each probe carries its own cancel state, and stop() detaches the cancelled request, so a restart right after a stop (React StrictMode) sends a fresh request at once instead of waiting a cycle. The single-flight guard is now tested with Check again pressed during a slow probe.
… as slow at once

Right after an outage, a status request that times out marked the backend connected but showed no banner until three timeouts in a row, two to three minutes with no word while it still had not answered. It now shows "GAIA is slow to answer" straight away; an answer of any kind clears it.
A 504 means a proxy or tunnel reached the backend and gave up waiting,
the busy case this change exists for. It now backs the poll off and gets
the five-minute grace before the banner says the connection is lost. A
502 still means nothing answered and reads as unreachable.
@kovtcharov-amd
kovtcharov-amd force-pushed the claude/rel-webui-status-poll branch from 6ebd6e7 to 80fabb7 Compare October 19, 2026 06:27
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Oct 19, 2026
…sy (amd#5344)

Before: when Lemonade didn't answer a connection in time, the Agent UI
showed "status unavailable", as if the server were busy, when nothing
was answering at all. A server that accepted the connection but never
answered held every `/api/system/status` request for the sum of its
probes' timeouts (up to about half a minute), so the UI's status poll
piled up. After: a refused connection, or a connect timeout to a remote
server, reads as "not running". A connect timeout to a Lemonade on this
machine reads as busy: it's up, just not accepting, so the UI no longer
tells you to start it. The probes share a 20-second budget, and a new
`lemonade_probe` field says how the probe ended, so clients can tell
"down" from "busy" from "error".

Reproduced by `tests/unit/chat/ui/test_status_probe_bounds.py`: on main,
a connect timeout sets `lemonade_error`, and a server that never answers
holds the request for 30 s. Here it's "down" with no error, and answers
in under 1 s with `timed_out`.

Asked for by the clients reliability work (amd#5316/amd#5317), which can now
drop its 60-second client wait.

## Test plan
- [x] `pytest tests/unit/chat/ui tests/unit/test_model_server_info.py`:
all pass
- [x] `npx tsc --noEmit` and `npx vitest run` in `src/gaia/apps/webui`
- [x] `python util/lint.py --black --isort --pylint --flake8
--test-lanes`

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

- The Lemonade probe block in `system_status` moved into a nested
`_probe_lemonade()` and runs under `asyncio.wait_for(...,
_STATUS_PROBE_BUDGET_S=20)`. Fields it set before the budget ran out are
kept.
- `httpx.ConnectError` → `down`, no error. `ConnectTimeout` → `down` for
a remote URL, `timed_out` with an error for a loopback one (a wedged
local server with a full accept queue times out the same way). Any other
`httpx.TimeoutException` → `timed_out` plus an error. Anything else →
`error`. A completed probe → `ok`, or `error` when Lemonade answered
non-200.
- `SystemStatus.lemonade_probe` is new and optional, typed
`Literal["ok","down","timed_out","error"]`. If `/health` answered but
the slower probes ran out of budget, it stays `ok` with a probe warning.
The API schema and types are regenerated.
- Not LLM-affecting.
</details>

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
The new chat screen from main fetches its start cards on mount; unstubbed, the auto-mock returned undefined and every App status-poll test threw.
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 19, 2026
Merged via the queue into amd:main with commit 873c686 Oct 19, 2026
36 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the claude/rel-webui-status-poll branch October 19, 2026 11:33
kovtcharov pushed a commit to kovtcharov/gaia that referenced this pull request Oct 30, 2026
…er (amd#5404)

The proactive Claude reviews were failing about half the time, and each
failure was lost. The code and security audits failed 5 of the last 10
nights, and the doc walkthrough failed 4 of its last 5 runs. Running
three audits every night used up both Claude accounts' weekly limit by
mid-week, so most of those runs stopped before reviewing anything and
blamed a missing file. The next run never went back for the missed work.
Now one audit runs each night between 2 and 4am Pacific, so each audit
runs every third night. Each run checks Claude is available before
starting, and says plainly when it isn't. It picks up everything since
its last successful run, starts from what merged since then, and checks
against the bug types past audits missed. The dedup pass no longer
re-files duplicates that were already closed: 34 of them were closed
alongside this change.

## Test plan

- [ ] `python -m pytest tests/unit/test_audit_synthesis_prep.py
tests/unit/test_audit_history.py tests/unit/test_audit_rotation.py
tests/unit/test_require_claude.py tests/unit/test_recent_changes.py
tests/unit/test_miss_analysis.py
tests/unit/test_claude_audit_workflow_contract.py
tests/unit/test_closed_duplicates.py -q` passes (277 tests)
- [ ] After merge: `gh workflow run claude-audit-rotation.yml -R
amd/gaia -f dry_run=true`. The summary names tonight's audit and the
next five nights, and nothing is dispatched.
- [ ] After merge: `gh workflow run claude-nightly-audit.yml -R amd/gaia
-f dry_run=true`. Check the preflight summary: the mode, a window
reading "since this audit's last successful run", the Claude probe
passing, and "Recent changes read first". At the end, "Dry run
confirmed: no issue created".
- [ ] After merge: `gh workflow run claude-weekly-doc-walkthrough.yml -R
amd/gaia -f doc_filter=docs/quickstart.mdx -f dry_run=true`. The guide
is walked, "Using bash.exe from …" appears, and the dry-run watermark
step passes (it crashed before this change).
- [ ] After merge: `gh workflow run claude-security-audit.yml -R
amd/gaia`. Semgrep scans `tui`, `installer` and `.github/workflows`, and
the SARIF uploads.
- [ ] First scheduled night (10:13 UTC): the dispatched run is titled "…
rotation night N", files at most what's new, and an issue it files
carries `audit-cluster` / `audit-key` markers.

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

**Root causes (last ~2 weeks)**
- Code and security audits, Oct 7/10/12/13/14/17: every lens returned
`is_error` in under a second with "You've hit your weekly limit". The
primary account ran out on Oct 10, the secondary on Oct 12–14, both on
Oct 17. The account switch fired correctly; both accounts were spent.
- Walkthrough Oct 12: same weekly limit on every guide, queued over 57
hours on the Strix Point pool. Oct 5 and Oct 19: the `xsj-aimlab-stxp`
images have no Git for Windows (only WSL's `bash.exe`). Also on Oct 5,
the executor step's `GITHUB_OUTPUT` got UTF-16 appended by
`start-lemonade.ps1` under PowerShell 5.1 `>>`. Sep 21–28: Application
Control blocked `LemonadeServer.exe` and the job landed on Strix Halo
machines; both were fixed by the move to the `xsj-dispatch` pool on Oct
1.
- The walkthrough's two dry-run steps had a literal `\n` mid-command, so
`dry_run=true` always failed.

**Schedule.** One cron, `13 10 * * *` = 03:13 PDT / 02:13 PST. Only
10:00–11:00 UTC is inside 2–4am Pacific in both seasons. Slot = days
since epoch mod 3 → code audit, security audit, doc walkthrough. The
audits lost their own crons; `workflow_dispatch` still runs any of them
on demand. Deep code sweep: whenever the last successful one is over 8
days old (every third turn, retried on the next turn if it fails).

**Dedup bug.** The 2026-09-07 burst (78 issues) predates the dedup pass:
the run checked out main 7 hours before amd#3310 merged. Three duplicate
pairs still got through after amd#3310 (amd#3832/amd#3471, amd#3825/amd#3414,
amd#5199/amd#4875). Backlog matching compared findings against issue titles
only, so a same-section duplicate worded differently scored 0.05–0.15,
below the 0.18 threshold. Now matching includes each audit issue's own
markers (all 13 known pairs rank 1st–2nd). Closed duplicates hand their
keys to the open canonical, so consolidating into amd#1077/amd#4331 does not
trigger re-filing. Both syntheses share the `claude-audit-issue-filing`
concurrency group. The security audit files to private code scanning,
not issues, so it cannot duplicate the other two.

**Closed as duplicates (34):** into amd#4331: amd#3204 amd#3413 amd#3422 amd#3439 amd#3466
amd#3476. Into amd#1077: amd#3173 amd#3412 amd#3418 amd#3426 amd#3429 amd#3430 amd#3433 amd#3437 amd#3442
amd#3449 amd#3454 amd#3455 amd#3464 amd#3468 amd#3475 amd#3477 amd#3482. Into amd#3198: amd#3436
amd#3462. Others: amd#3425→amd#3169, amd#3457→amd#3195, amd#3440→amd#3180, amd#3486→amd#3064,
amd#3471→amd#3832, amd#3414→amd#3825, amd#3434 amd#3485→amd#3219, amd#5199→amd#4875.

**Miss-analysis (merged `fix` PRs, Jun 21–Oct 19).** 29 of 1005 (3%)
closed an issue an audit filed first. Missed, by title: no deadline 90
(amd#5346 amd#5384 amd#5380), release/CI ordering 71 (amd#5127 amd#5147), Windows
behaviour 38 (amd#5018 amd#5377), dishonest status 36 (amd#5112 amd#5317), shared
state across processes 34 (amd#5337 amd#5282 amd#5378), model output handling 27
(amd#4973 amd#5103), doc drift 27, cold start / non-default setup 26 (amd#4951
amd#5130). About 380 more were Agent UI/TUI or agent-behaviour fixes, which
a static read rarely catches. Noise: of the audit issues closed as
duplicate or not planned, 31 were duplicates of amd#1077, 12 of the
test-coverage umbrella amd#2988, and 6 each of amd#4331, amd#3149, amd#3308 and
amd#2922. What changed: `scripts/audit/missed_bug_classes.md` has a
checklist per class and a "Don't report" list, and all three prompts
read it at run time. The code audit gets a deterministic list of calls
with no deadline. The security audit's semgrep run and worklist now
cover TypeScript, Go, the installer and the workflows.
`scripts/audit/miss_analysis.py` refreshes the evidence monthly.

**Recent changes.** Each audit's first job writes `recent-changes.md`:
first-parent commits since the commit its last successful run checked
out, read from the run history, with PR title, a short body excerpt and
the paths each touched, capped at 30 KB. If that commit is unknown it
covers 3 days and says so.
</details>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants