Skip to content

feat(diagnostics): save a local problem report when a model call fails - #6665

Merged
kovtcharov-amd merged 18 commits into
amd:mainfrom
kovtcharov:kalin/model-failure-records
Nov 6, 2026
Merged

kovtcharov-amd merged 18 commits into
amd:mainfrom
kovtcharov:kalin/model-failure-records

Conversation

@kovtcharov

@kovtcharov kovtcharov commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

When a local model call failed, users saw "Couldn't reach the local LLM" and we couldn't tell why. Their report didn't say which address the agent called, whether Lemonade or FastFlowLM was running, or what GAIA had asked it to load (#6632). Now the failure saves a local problem report on the spot, and the error names it (GF-20261104-192233-3f2a). One report is enough to root-cause the failure without follow-up questions. Nothing is sent anywhere: the user saves it with Save a troubleshooting report, under the failed answer or in Settings → Privacy, and attaches it themselves.

English Arabic
Failed answer with its report button The same, in Arabic
  • What the report holds: the last load requests and how their context window was chosen (inputs and the free-memory check), and the chat request's size: estimated prompt tokens, tool count and schema size, max_tokens, stream. Never the message text. Also:
    • timing and the HTTP outcome
    • the agent's address next to Lemonade's
    • the NPU and the FLM/llama.cpp backends as Lemonade reports them
    • lemond/llama-server/flm liveness and lemond's exit
    • the lemond.log tail
  • Where it's saved: the agent's failure answer, Agent UI chat errors, failed setup runs, agents that never start, and gaia llm. Errors that already say what happened (out of memory, context overflow, a stop) get no report.
  • Privacy: keys, URL passwords and the home folder are redacted. Only a Lemonade on this PC is read, with no proxy or redirect. Ten reports kept, 256 KB each. gaia diagnostics bundles them, and leaves them out with --no-logs.

Refs #6632

Test plan

  • python -m pytest tests/unit/test_failure_record.py tests/unit/cli/test_cli_diagnostics.py: one test per failure class, redaction, size cap, loopback-only probing, and an FLM crash during load whose report carries every NPU chat fails with "Couldn't reach the local LLM" on embedded Lemonade (rc4) #6632 field
  • python -m pytest tests/unit: 37,411 passed locally. Two Windows-only tests (System32 guard, tar symlink) fail only after another test leaves platform.system patched; they pass on their own and fail the same way on main
  • cd src/gaia/apps/webui && npm test && npm run test:rtl: 2,941 and 340 passed; covers a live chat error keeping its report name and button, and a visual test of the failed answer in English and Arabic
  • On a machine with a stopped Lemonade, send a chat. The answer names a GF- report, ~/.gaia/failures/ holds it, and Save a troubleshooting report downloads a bundle that contains it
🔍 Technical details
  • New gaia.llm.failure_record (builds and writes the record) and gaia.llm.call_ledger (in-memory notes of each load and chat request; finished loads also go to failures/recent-loads.json, because in the Agent UI the backend loads the model and the agent's own process chats with it).
  • LemonadeClient.load_model, chat_completions and resolve_ctx_size feed the ledger. A streamed reply's entry closes when the stream ends, fails or is dropped.
  • Recording is guarded at its boundary: a record that can't be built logs and returns None, so the user's real error always goes through. Setup records on its own thread, so the runner frees as soon as the run ends. The UI's non-streamed path records off the event loop.
  • Live chat errors that the UI rewords keep the GF- id and the button (classifyChatError appends it). The setup report waits up to 30 s for the run's record. recent-loads.json is written under a file lock, so loads finished at once by several processes are all kept.
  • Unit tests stub the record outside tests marked failure_records: a real one takes ~2 s and its threads were slowing unrelated timing tests under -n 8.
  • The process scan reads names only, then status and start time for the few matches. Reading all of it took 30–50 s on Windows.
  • The Agent UI button reuses POST /api/setup/report, which already runs gaia diagnostics. StageLogs now uses the same shared component.
  • The lemonade-logs-in-ui work adds a log reader. Once it lands, _lemond_log_tail can switch to it, and a user-installed Lemonade's log stream can join the record.

"Couldn't reach the local LLM" told a maintainer nothing: not the address the
agent used, whether Lemonade or FastFlowLM was alive, or what GAIA asked it
to load. Now the failure itself writes a redacted JSON record under
~/.gaia/failures/ and the error names it (GF-YYYYMMDD-HHMMSS-xxxx).

The record holds versions, OS and kernel, Lemonade's devices and backend
states (FLM/llama.cpp versions, NPU), the agent's address against Lemonade's,
whether a key was sent (never the key), loaded models, lemond/llama-server/flm
liveness and lemond's exit, the last load requests and how their window was
chosen, the chat request's size (never its words), timing, the HTTP outcome,
and the lemond.log tail. Ten kept, 256 KB each. It only reads a Lemonade on
this PC, with no proxy or redirect; nothing is sent anywhere.

Recorded from the agent's failure answer, the Agent UI chat errors, failed
setup runs, sidecars that never start and `gaia llm`. `gaia diagnostics`
bundles the records, and a "Save a troubleshooting report" button sits under
a failed answer and in Settings > Privacy, reusing setup's report.
@github-actions github-actions Bot added documentation Documentation changes llm LLM backend changes cli CLI changes tests Test changes electron Electron app changes performance Performance-critical changes agents daemon Daemon supervisor / sidecar control plane sidecar Agent sidecar contract / harness labels Nov 4, 2026
@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Verdict: Request changes

When a local model call fails, GAIA now saves a redacted problem report on the user's PC and names it in the error, so one bug report carries the fault. The recording is well guarded: a report that can't be built never replaces the user's real error, only a Lemonade on this PC is probed, and keys and the home folder are redacted. One gap in the Agent UI needs fixing first.

  • The live chat can lose the report name and its button. When a failure ends the turn as a stream error (a model that won't load, say), the chat swaps the server's text for its generic "model server did not answer" message. That drops the GF-… id, so Save a troubleshooting report isn't shown under that answer. The id only comes back once the chat reloads the saved message. The agent's own "couldn't reach the model" answer is not affected. Fix: also look for the id in the failure's original text.
  • No screenshot on the PR. The new button changes the chat and Settings screens. The visual test takes English and Arabic shots, so embed one of each in the description.
  • Follow-up: the sentence naming the saved report is English-only, so Arabic users read it in English. The rest of the failure answer already has this problem. File it as an issue if this PR doesn't fix it.

Real-world evidence

N/A: no evidence bundle was produced for this run. The verdict rests on static review alone. The chat, setup and CLI failure paths weren't exercised here.

🔍 Technical details

🟡 Streamed chat errors drop the record id in the live view (src/gaia/apps/webui/src/components/MessageBubble.tsx:699)
_stream_chat_impl puts _model_failure_text(...), which includes the GF-… note, into result_holder["error"]. That is sent as an SSE error event. ChatView.tsx:1255 then replaces the content with classifyChatError(err).text. That text is chatError.modelServer in most cases, since MODEL_SERVER_RE matches "Lemonade" and "LLM". The original text survives only in failureText, and the button reads only message.content. keepFailedReply restores the server row on a later refetch, but the bubble the user sees first has no id and no button. It shows a "Report it on GitHub" link instead.

                    {message.role === 'assistant' && !isStreaming && (namesFailureRecord(message.content) || namesFailureRecord(message.failureText ?? '')) && (

It would be better still to show the record id in that live bubble, so the user can quote it. A test in MessageBubble.failureReport.test.tsx should cover a failed message whose content is the generic text and whose failureText names a record.

🟡 Agent UI change without screenshot evidence. visual/rtl.visual.ts already captures failed-answer-report-{en,ar}. Embed those as raw.githubusercontent.com images in the PR description.

🟡 Follow-up: the report note isn't localized. record_note() (src/gaia/llm/failure_record.py:1747) returns English text that the Arabic UI shows unchanged. The rest of _model_failure_answer has the same problem today. Suggested issue title: "Agent failure answers are English-only in the Arabic UI".

🟢 Nits

  • PrivacySettings.tsx:419: the settings-report root class has no CSS rule, so the Settings card gets no layout, unlike .msg-report and .setup-report. Add a rule or reuse an existing class.
  • setup_runner.py:2025: run.note("Problem report saved as …") runs on a background thread after the run ends. If setup-report.json was already written, the record id is missing from it. Worth a check.
  • call_ledger._share_load: two processes finishing a load at once can each drop the other's entry from recent-loads.json. os.replace prevents corruption, so the cost is a missing diagnostic line. Acceptable, but a comment would help.

Strengths

  • Failure isolation at each boundary: record_failure / record_local_failure log and return None. Each record section that can't be read is listed under unreadable rather than silently omitted.
  • Privacy is handled carefully: probes are loopback-only with trust_env=False and no redirects. URL credentials and query strings are stripped, field names that look like secrets are blanked, and the home folder is matched in any case and with any separator. Tests cover each of these.
  • is_recordable keeps refusals that already explain themselves (out of memory, context overflow, a user stop) out of the ten kept reports, so real crashes aren't pushed out.

A failed turn the chat put in its own words dropped the GF- id, so the
"Save a troubleshooting report" button only appeared after a reload. The
chat error now names the saved report in the user's language.

- A setup report asked for as a run fails waits for its problem report.
- Two processes noting a model load at once no longer drop one: the
  shared load file is written under GAIA's cross-process file lock.
- The setup journey stopped leaking the daemon and agent sidecars, which
  start in their own session and kept writing into a home being deleted.
- Settings' report card gets its own layout rule.
A real problem report scans every process and probes Lemonade (~2 s), and
setup tests left those threads running into later tests, which made
unrelated timing-sensitive tests flaky under -n 8. Tests that exercise the
report opt in with the failure_records marker.
…irzakhani-5df4d1

# Conflicts:
#	src/gaia/agents/base/agent.py
#	src/gaia/apps/webui/src/i18n/locales/ar.ts
#	src/gaia/apps/webui/src/i18n/locales/en.ts
@kovtcharov

Copy link
Copy Markdown
Contributor Author

All review points are fixed in d448e6b and the commits before it.

  • Live chat errors kept the report: a failure the UI rewords still names the GF- report and shows Save a troubleshooting report. Tested both ways: from the live error, and when only the raw failure text names the report.
  • Screenshots: both languages are now in the description.
  • Nits: .settings-report has its layout rule. The setup report waits for the run's record, and says so if it is still saving. recent-loads.json is written under a file lock: a 6-process test lost entries without the lock and keeps them all with it.
  • English-only failure text in the Arabic UI: not fixed here. The backend's answer and record note stay English; the button and note around them are translated.

The Settings load tests sent their request on a per-request event loop, which
cancels the background load task on exit; when the load thread had not started
yet, the load never ran. They now keep one loop open for the client's life.
The path-access tests waited for the pending-answer flag, which is set before
the request is queued, then read the queue at once; they now wait for the
request itself. Both failures reproduce every time with a forced delay and
pass with it after this change.
The queued request must be granted once a 50 ms lease lapses, but the test
allowed 1 s, which a loaded Windows runner exceeded before scheduling the
waiter. 5 s still proves the wake-up: without it the request either hangs or
gives up at its 10 s limit, and the test fails that way when the wake-up is
removed.
…irzakhani-5df4d1

# Conflicts:
#	src/gaia/apps/webui/e2e/harness.ts
…irzakhani-5df4d1

# Conflicts:
#	src/gaia/cli.py
…irzakhani-5df4d1

# Conflicts:
#	src/gaia/agents/base/agent.py
…irzakhani-5df4d1

# Conflicts:
#	src/gaia/ui/_chat_helpers.py
amd#6777 stopped sending a separate error event, so a failed turn's error now
rides on the closing done event. This integration test still looked for the
old event and failed on main as well.
…port

The test made the cancel undeliverable by closing the fake daemon's
listener. Under `go test ./...` another test process can bind that freed
port and answer the cancel, so Close saw no error. The fake now drops the
cancel's connection without an answer, which fails the same way every time.
The purge test ran the runner's real update-desktop-database and
gtk-update-icon-cache over /usr/share, which outlasted its 5 s timeout on a
busy Linux runner. It now stubs them, as the file's other maintainer-script
tests already do.
@github-actions github-actions Bot added the tui Go terminal UI (gaia-tui) label Nov 6, 2026
…irzakhani-5df4d1

# Conflicts:
#	tests/integration/test_chat_ui_integration.py
…ffectionate-mirzakhani-5df4d1

# Conflicts:
#	src/gaia/llm/lemonade_client.py
…ffectionate-mirzakhani-5df4d1

# Conflicts:
#	src/gaia/ui/_chat_helpers.py
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Nov 6, 2026
Merged via the queue into amd:main with commit 8e6b983 Nov 6, 2026
99 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/model-failure-records branch November 6, 2026 20:36
@kovtcharov-amd kovtcharov-amd mentioned this pull request Nov 7, 2026
6 of 12 tasks
kovtcharov-amd added a commit to rezamuliawijaya/gaia that referenced this pull request Nov 7, 2026
## Why this matters

v0.26.0 makes the first reply in a new chat much faster by loading tools
on demand (amd#6449), and adds long recordings and video links (amd#6451),
read aloud in both apps (amd#6489), a live system usage strip (amd#6548),
cloud spend in the composer (amd#6775), local problem reports for failed
model calls (amd#6665) and GAIA on stock GNOME without a tray (amd#6868).
Among the fixes, a duplicated edit can no longer damage a file and
long-running agents on macOS keep answering. 31 commits since v0.25.4;
the notes are in `docs/releases/v0.26.0.mdx` and credit 4 outside
contributors.

This is a minor: 7 `feat` commits, and dynamic tool loading drops two
environment variables and the old Beta toggle (listed under Breaking
Changes). Merging it moves main to 0.26.0 so `v0.26.0-rc1` can be tagged
right after v0.25.4 publishes. The changelog is regenerated before the
final.

## Test plan

- [x] `python util/validate_release_notes.py docs/releases/v0.26.0.mdx
--tag v0.26.0` passes, and with `--tag v0.26.0-rc1`
- [x] `mintlify validate` (from `docs/`) passes; the notes have no
unescaped `<` or `{`
- [x] Narrative word count is 391, under the 600 cap for a minor
- [x] `python util/release_versions.py --check`, `python
util/check_doc_links.py --internal-only` and `python
util/check_doc_versions.py` pass
- [x] `python util/check_component_core_api.py --release-version 0.26.0`
passes
- [x] `pytest tests/unit/test_docs_json_release.py
tests/unit/test_check_component_core_api.py
tests/unit/test_release_tag.py tests/unit/test_hub_core_version_gate.py
tests/unit/test_release_versions.py
hub/agents/gaia/python/tests/test_npm_doc_min_version.py`: 232 passed
- [ ] CI green on the merge commit
- [ ] `release_train_dryrun.yml` passes on that commit before the RC tag

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

- `test_release_versions.py` simulated a core bump to a hard-coded
`0.26.0`, which is a no-op once the tree is on 0.26.0. It now bumps to
the next minor above whatever the tree declares.
- The flagship agent stays at 0.3.5; its `amd-gaia` floors and
`min_gaia_version` move to 0.26.0 through `--stamp`, and its npm
CHANGELOG's `[Unreleased]` quotes the new minimum.
`hub/components/agent-ui/` is no longer published and is left alone.
- `RELEASED_DAEMON_API` no longer exists (amd#5394); the core API guard
reads released versions from PyPI.
</details>

## Evals to re-run on the RC tag

LLM-affecting PRs merged without per-PR evals; run these on
`v0.26.0-rc1`:

- `gaia_tool_selection`, `tool_selection`, `gaia_core` and
`context_retention` for dynamic tool loading (amd#6449, amd#6842)
- `gaia_media` and `gaia_voice` (amd#6451, amd#6489, amd#6825)
- `gaia_data` and `gaia_honesty` (amd#6828, amd#6831, amd#6817)
- `gaia_files` (amd#6844)
- `adversarial` (amd#6837)
- `memory` and `gaia_memory` (amd#6828, amd#6843)
- `gaia_email` (amd#6842)

## Release checklist

- [ ] Merge once v0.25.4 has published; amd#6114 (flagship follows core) is
not part of this release PR
- [ ] Freeze main, wait for green CI on the exact commit, pass
`release_train_dryrun.yml`, then push `v0.26.0-rc1` (the RC freezes its
own flagship; no agent release needed)
- [ ] Before the final: release the flagship from the release commit
(`agent-pkg-gaia-v<next>`), merge its pin-lock PR, and pass
`check_flagship_release.py`
- [ ] Regenerate the changelog if main gains commits before the final
tag
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents cli CLI changes daemon Daemon supervisor / sidecar control plane documentation Documentation changes electron Electron app 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