Skip to content

fix(ui): Model server panel names the model GAIA chats with - #7646

Merged
kovtcharov-amd merged 1 commit into
amd:mainfrom
tylerbea:fix/7593-advanced-chat-model
Nov 12, 2026
Merged

kovtcharov-amd merged 1 commit into
amd:mainfrom
tylerbea:fix/7593-advanced-chat-model

Conversation

@tylerbea

Copy link
Copy Markdown
Contributor

Settings > Advanced could tell a user their chat model was a cloud model running remotely, while every chat was answered on their own PC. The panel showed whichever model the model server used last, even when another app loaded it. Now "Chat model" names the model GAIA chats with, and any other loaded model, cloud ones included, gets its own row marked as such.

Closes #7593

Before After

Test plan

  • pytest tests/unit/test_model_server_info.py tests/unit/test_users_lemonade_untouched.py tests/unit/test_lemonade_server_down.py tests/unit/test_lemonade_load_error_not_network.py, including 4 new tests that fail on main
  • black and isort
  • Built app against a real Lemonade with Gemma 4 E4B and a cloud model both loaded: "Chat model: Gemma 4 E4B · Metal", and the cloud model on its own "Remote (cloud)" row
  • With GAIA's chat model unloaded, the Chat model row reads "None loaded"
🔍 Technical details
  • model_server_info._chat_entry now takes the model GAIA chats with (the user's custom_model setting, else resolve_default_chat_model()) and matches it ignoring the user. prefix. The two /model-server endpoints in routers/system.py pass it in.
  • Behavior change to review: when GAIA's chat model isn't loaded, the row says "None loaded" and the Reload button hides, instead of showing another app's loaded model as GAIA's.
  • test_users_lemonade_untouched.py builds a bare app, so it now supplies the database dependency the endpoint needs.
  • The "GAIA agent isn't installed" banner in the after shot comes from the empty scratch home used for the test.

Settings > Advanced showed the server's last-used model as GAIA's chat model, so a cloud model another app used could read as "Runs on: Remote (cloud)" while chats ran locally. It now names GAIA's own chat model (or none while it isn't loaded) and lists other loaded models, cloud ones marked Remote, on their own rows.

Closes amd#7593
@github-actions github-actions Bot added llm LLM backend changes tests Test changes performance Performance-critical changes labels Nov 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This fixes the Settings › Advanced "Model server" panel. On a server shared with other apps, it named whichever model was used last, so it could call a cloud model GAIA's chat model when chats were really answered locally. Now the panel names the model GAIA chats with: your override, or else the configured default. Every other loaded model, cloud ones included, gets its own row marked as such. The fix is small and covered by tests that fail on main, and the before/after screenshots show the right result.

  • Follow-up: the TUI status line still has the old bug. It picks the chat model the same old way, by last-used model and then the first one loaded. With a cloud model loaded last on a shared server, the TUI still reports that model as the chat model. Fix it the same way or file an issue before merge. It doesn't block this PR.
  • If you pick a cloud model that the model server doesn't list, the Chat model row now reads "None loaded" and the local model drops into the "other" list. That's more honest than before, but worth a second look.

Real-world evidence

N/A: no evidence bundle was produced for this run. The PR description embeds before/after screenshots of the real panel against a real Lemonade with Gemma 4 E4B and a cloud model both loaded. Those screenshots show the fix working. The "None loaded" state is covered only by a unit test, and its manual test-plan item is still unchecked. Beyond the screenshots, this verdict rests on static review.

🔍 Technical details

🟡 Follow-up: TUI status line uses last-used model (tui/internal/lemonade/serverinfo.go:144-151)
describeServer sets info.Chat from health.ModelLoaded, else chat[0], which is the logic this PR removes from model_server_info._chat_entry. StatusLine() then shows that model. The panel docstring says describe_model_server feeds "the Model server panel and the TUI status line", but the TUI computes this itself in Go, so it doesn't get the fix. Suggested issue title: TUI status line names the last-used model, not GAIA's chat model, on a shared Lemonade. The sidebar popover's _chat_entry (src/gaia/ui/routers/providers.py:1855) also prefers the root model_loaded. It skips cloud entries, so it can't show this exact bug, but it can still name another app's local model.

🟢 Cloud chat model not on the server reads "None loaded" (src/gaia/ui/routers/system.py:1355)
chat_model_id=custom_model or _default_model_name() is correct for a local pick: providers.py model selection writes custom_model. But a cloud custom_model that Lemonade doesn't list now makes chat_model None and hides Reload. Consider having the panel say the chat runs in the cloud instead of "None loaded".

🟢 Duplicate prefix normalizer (src/gaia/llm/model_server_info.py:174)
_model_key duplicates _norm_model_id in src/gaia/ui/routers/system.py:75. Since system.py already imports from model_server_info, it could reuse _model_key (made public), so the user. rule lives in one place.

Strengths

  • Passing chat into _other_loaded_entries, instead of recomputing it, keeps the "chat" and "other" lists consistent by construction.
  • Other loaded models now get is_cloud, so a cloud model shows as "remote" in its own row instead of with a misleading local backend.
  • The tests cover the shared-server case, GAIA's model not loaded, and the user.-prefix match, plus one route-level test through the real endpoint.

@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Thanks @tylerbea, this is a clean, well-tested fix and the before/after shots made it easy to verify. The TUI status line has the same bug in its own Go code; that's now tracked in #7714 so it doesn't hold this up.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Nov 12, 2026
Merged via the queue into amd:main with commit 2dd8cde Nov 12, 2026
48 checks passed
kovtcharov pushed a commit to kovtcharov/gaia that referenced this pull request Nov 15, 2026
…ade (amd#8224)

## Summary

The TUI status line (`gaia-tui status`, the Local row in the model
picker) now names the model GAIA chats with, not whichever model
Lemonade loaded last, on a Lemonade shared with other apps.

## Why

`describeServer` in `tui/internal/lemonade/serverinfo.go` took the chat
model from `/health`'s `model_loaded`, else the first loaded chat model.
On a shared server that is often another app's model, for example a
cloud model it just used, so the status line said GAIA was chatting with
it while GAIA actually chats with its local Gemma. amd#7646 fixed the same
mistake in the Agent UI's Settings > Advanced > Model server panel
(`model_server_info._chat_entry`); the TUI computes the chat model on
its own and still had it.

## Linked issue

Closes amd#7714

## Changes

- **`GaiaChatModel()`** resolves the model GAIA chats with, as
`resolve_chat_model` does: config.json's `last_model` (the user's last
pick in the TUI or Agent UI), else `default_model`, else
`Gemma-4-E4B-it-GGUF`. A `hybrid` choice resolves to its cheap model,
the one a session starts on (`start_model`). It returns `""` if
config.json can't be read.
- **`describeServer(..., chatModel)`**: with a chat model, `Chat` is
only that model, compared ignoring the `user.` prefix and case
(`SameLocalID`, as `_model_key`). Without one, behavior is as before.
`ServerInfo` passes `GaiaChatModel()`.
- When GAIA's local model isn't loaded, the line says `· <model> not
loaded` instead of naming another app's model, and the Local row doesn't
borrow another app's local model either. A local model beside a cloud
chat model is still shown there, as before.
- One existing test fixture (`TestServerInfoSurvivesAMissingSystemInfo`)
loaded a model called `M`, which is no longer GAIA's chat model with no
config. It now loads Gemma; the test still checks the missing
`/system-info` case it was written for.

## Test plan

- [x] New in `serverinfo_test.go`, all against a fake shared Lemonade
whose `model_loaded` is another app's cloud model:
- `TestASharedServersLastModelIsNotGaiasChatModel` (no config: GAIA's
default Gemma).
- `TestTheChatModelFollowsConfigIgnoringTheUserPrefix` (`default_model`;
`last_model` as `user.X` wins; `hybrid` uses its cheap model).
  - `TestGaiasChatModelNotLoadedIsSaidNotReplaced`.
  - `TestAnUnreadableConfigNamesNoChatModel`.
- [x] The three shared-server tests fail against `main`: each one names
`fireworks.kimi-k2p7` as the chat model. They pass here.
- [x] `go test ./...` in `tui/` (Go 1.27): all packages pass. `go vet
./...` and `gofmt -l .` are clean.
- [x] `python util/lint.py --all`: all checks passed.

## Evidence

`ServerInfo(...).StatusLine()` against a Lemonade with another app's
cloud model loaded last and GAIA's Gemma beside it, with no GAIA config
(so GAIA chats with its default Gemma):

```
===== main =====
Lemonade 10.8.1 (yours) at localhost:13305 · fireworks.kimi-k2p7 (cloud, runs remotely)
===== this PR =====
Lemonade 10.8.1 (yours) at localhost:13305 · Gemma-4-E4B-it-GGUF on Vulkan, 64K ctx
```

- [x] **Agent exposed in the Agent UI**: N/A, TUI only. The Agent UI
panel was fixed in amd#7646.
- [x] **MCP tools / servers**: N/A.
- [x] **CLI**: `gaia-tui status` prints this line (`printModelServer`);
shown above.
- [x] **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`,
and `go test ./...` / `go vet ./...` in `tui/`).
- [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: the
status line text explains itself; no doc page quotes it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llm LLM backend changes performance Performance-critical changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Settings can say the chat model is a cloud model while GAIA chats on the local one

2 participants