Skip to content

feat(ui): type while GAIA works, see context fill, retry with another model - #5241

Merged
kovtcharov-amd merged 26 commits into
amd:mainfrom
kovtcharov:claude/ui-composer-context-retry-779e65
Oct 19, 2026
Merged

kovtcharov-amd merged 26 commits into
amd:mainfrom
kovtcharov:claude/ui-composer-context-retry-779e65

Conversation

@kovtcharov

@kovtcharov kovtcharov commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Local turns take minutes, but the Agent UI refused any message sent while a reply ran, said nothing about how full a 32K–64K context was until it had already dropped older turns, and comparing two local models meant retyping the question and losing the first answer. Now a message typed mid-turn waits in a visible queue and runs as its own turn, in order (or, on request, is added to the running reply), a context meter shows what fills the window and names the turns about to leave view, and Retry with… puts a second local model's answer next to the first, with time and speed, so you can keep either. Lands after v0.25.0.

Closes #5224
Closes #5227
Closes #5248

  • Queued messages belong to their chat. Switching to another chat or reloading keeps them, they go out when that chat's reply ends even if it isn't open, and a send that fails stays in the queue as Not sent with Send again instead of vanishing.
  • No compaction or summarising: the meter only makes the existing history budget visible.
  • Retry with… doesn't rerun tools (no repeated side effects). The other model answers from the turn's recorded evidence, and the retry is refused while another chat is answering, so it never unloads a model that chat is using.

Test plan

  • npx vitest run (1340 passed, incl. three back-to-back messages) and npx tsc --noEmit in src/gaia/apps/webui
  • Queue across chats (queueDispatch.test.ts, ChatView.queueAcrossChats.test.tsx): switch away mid-turn then the turn ends; switch away and back before it ends; back and forth repeatedly; two chats each with a queue; an added-to-reply message read or returned while nobody watched; a send failing after the user left; reload; chat deleted mid-send; order kept behind a failed message; turn end racing a poll sends once
  • python -m pytest tests/unit/chat tests/unit/agents passes (new: test_followups.py, test_answer_retry.py, test_context_usage.py). The full tests/unit run's remaining failures are in untouched files and come from this dev box's live Lemonade/daemon
  • python util/lint.py --all passes
  • npx jest in tests/electron (847 passed)
  • Running app (backend 4303, Vite 5303): three messages sent back to back (RED, GREEN, BLUE) each got their own answer, in order (fix(ui): messages sent quickly one after another are silently dropped #5248)
  • Running app: a message added to the running reply was taken by that turn and answered in the same reply
  • Running app: attaching a 65 KB file moved the meter from empty to 46%, with 11K under Documents; checked at phone width
  • Running app: Retry with… menu lists the PC's downloaded models; the comparison and "Keep this answer" work, with the two retry endpoints stubbed in the page
  • Running app: queue two messages, open another chat, and see them sent when the first chat's reply ends
  • Before/after screenshots of the queue surviving a chat switch
  • Retry with… against a real second model (Qwen3.5-4B next to Gemma-4-E4B; screenshots in feat(ui): type while GAIA works, see context fill, retry with another model #5241 (comment))
  • Eval categories to watch on the next RC: context_retention, rag_quality, gaia_rag (history replay was refactored, behaviour unchanged)

… model

You couldn't send a message while a reply ran, the chat only said older
turns were gone after they were cut, and comparing two local models meant
retyping the question and losing the first answer.

- Messages typed mid-turn go to the running reply, which reads them at its
  next step. When it can't take them, they wait in a visible queue and go
  out in order once the reply ends. Stop puts them back in the composer.
- A context meter beside the model chip shows how full the window is, split
  into system prompt, tools, documents and conversation. Before older turns
  leave the model's view, a note names them by their question. Nothing is
  summarised or compacted.
- "Retry with…" on the latest answer asks another local model from the
  same evidence (tools are not run again) and shows both answers with time
  and speed. Keeping one continues the chat from it.

Refs amd#5224, amd#5227
@github-actions github-actions Bot added documentation Documentation changes tests Test changes electron Electron app changes agents labels Oct 16, 2026
The chat now prompts "Add to this request, or queue the next one" while a
reply runs, so the source check looks for all three placeholders.
Messages sent back to back went into the running reply, and a model that
ends its turn without addressing them left them unanswered (amd#5248). Each
message typed during a reply now waits in the queue and runs as its own
turn, in order. "Add to this reply" on a queued message still hands it to
the running turn when the user wants that.
…returns

A named constant compiles against both the current and the extended
getActiveRuns type, so merge order no longer matters for these files.
kovtcharov added a commit to kovtcharov/gaia that referenced this pull request Oct 17, 2026
…oud models

Each turn recorded its model as stats.model for the speed list, but a kept
"Retry with..." answer (amd#5241) uses that same key to name the model it was
kept from, so in a merged build every answer footer claimed a retry. The
speed sample is now stats.measured_model, which no other code reads.

Settings > Advanced's Model server panel showed a cloud chat model as its
raw routing id (fireworks.deepseek-v4p1-flash); it now shows the name, with
the id in the tooltip.
Once turns record their model (amd#5244), the footer's "kept from Retry
with…" label would show on every answer. A kept retry now carries
retried: true and the footer keys on that.
…retry tests

After each reply ChatView refetches messages, and it polls the count every
3 s. The mocks answered with an empty or fixed list, so on a slow machine a
refresh replaced the messages the test was checking. The mocks now return
what the chat already shows, which makes a refresh a no-op.
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This PR adds three things to the Agent UI. Messages typed during a reply now queue up and run as their own turns. A meter shows how full the model's context is. Retry with… puts a second local model's answer next to the first so you can keep either. The design is careful: follow-ups are only saved once the agent has actually taken them, untaken ones come back to the queue, and retries never rerun tools. Tests cover each new backend piece. Two things are worth fixing:

  • A retry blocks every other chat for as long as it runs. It holds the shared model slot through loading the second model and a reply that may take up to 15 minutes. A message sent in a different chat during that time waits 60 seconds, then fails with "server busy". Either tell the user that other chats are paused while comparing, or let those chats wait for the slot instead of failing.
  • The retry talks to the model server with raw HTTP calls instead of going through GAIA's existing Lemonade client. That duplicates the address, auth and stats handling the client already owns, so a later fix to the client won't reach this code.

Real-world evidence

N/A: no evidence bundle was produced for this run. The PR's test plan describes manual checks in a running app (three back-to-back messages answered in order, a follow-up added to a running reply, the meter moving from empty to 46% after a 65 KB attachment, the comparison working against stubbed endpoints), but no screenshots are embedded. Retry with… against a real second model is still unchecked. For the Agent UI surface, this verdict rests on static review plus the author's described checks.

🔍 Technical details

🟡 Retry holds chat_semaphore for the whole comparison (src/gaia/ui/routers/chat.py:707-723)
async with session_lock, chat_semaphore: wraps answer_with, which allows up to 120 s for the load (_PREFLIGHT_LOAD_TIMEOUT_S) plus a 900 s httpx.post. Meanwhile /api/chat/send in another session runs asyncio.wait_for(chat_semaphore.acquire(), timeout=60.0) (chat.py:126) and returns 429. The same session is protected because the UI queues while comparing, but other sessions aren't. Options: shorten the retry timeout, surface "comparing, other chats paused" in the UI, or have the send path tell the user that a comparison is holding the slot. Also, the PR description says the retry "waits for the shared model slot", but the code refuses with 409 when the slot is taken (that matches the SDK doc, so only the description is off).

🟡 Direct Lemonade HTTP calls (src/gaia/ui/answer_retry.py:149-251)
_is_loaded (GET /health), the POST /chat/completions and GET /stats all use httpx directly, which the review checklist flags as a pattern violation. LemonadeClient already resolves the base URL and auth headers, and already reads /health and /stats. Routing through it keeps error classification and auth in one place. If a non-streaming chat_completions with max_tokens is all that's needed, the client already covers it.

🟡 Agent UI evidence (once, per rubric)
This is a user-visible Agent UI change. Please embed before→after screenshots of the queue, meter and comparison in the PR description (raw.githubusercontent URLs render). The described manual runs are good. A screenshot of a real two-model comparison would also close the unchecked test-plan item.

🟢 Follow-up rows break text-only history replay (src/gaia/agents/base/history.py, transcript_turns)
_followup_taken saves the follow-up as its own user row before the assistant answer. For a turn saved with model_messages that's harmless. For a turn saved without them (the text-only path), pending is overwritten by the follow-up, so the original question drops out of replay. split_latest_turn would also offer the follow-up as "the question" to a retry. This path is rare, but worth a test.

🟢 FollowUpInbox matches by text (src/gaia/ui/followups.py:33-37)
_reported is a list of strings, so after requeue_taken, two identical follow-ups (e.g. "yes" twice) can suppress a followup_taken that should have been reported. This is an edge case, but tracking by a counter or an id would remove it.

Strengths

  • The follow-up inbox design is correct by construction: one lock covers wiring, delivery and unwiring, close_inbox returns untaken messages, and requeue_taken covers the model-reload rerun.
  • The _plan_history refactor means the meter uses the exact eviction plan select_history uses, instead of a parallel approximation, so the "about to leave view" list can't drift from what actually happens.
  • Errors follow the fail-loudly rule: RetryError carries an HTTP status plus a remedy, there is a 413 when the question doesn't fit the window, and a refused pre-load is detected instead of letting Lemonade load the model at a smaller window.

kovtcharov-amd pushed a commit to kovtcharov/gaia that referenced this pull request Oct 19, 2026
…d#5316)

Before: a message the backend never started spun forever; a connection
that went half-open (tunnel, laptop sleep, phone) or was cut (Wi-Fi
switch, proxy reset, restart) froze the answer or ended in "send your
message again", which then hit a 409 because the run was still alive;
and a busy server ended in a raw `HTTP 429: {"detail": ...}`. After: the
send is bounded and says it is waiting, a silent or cut stream
reconnects on its own and shows "Reconnecting (attempt n of 3)", prompts
the user already answered stay answered across a reconnect, an answer
lost to a restart says so, and every one of these errors is a plain
sentence with a next step. Lands after v0.25.0.

Reproduced by `src/services/__tests__/api.streamReliability.test.ts` and
`src/components/__tests__/ChatView.streamReliability.test.tsx`: the API
cases fail on main with the exact symptoms (no error after 30 s of
silence, no end to an unanswered send, a cut stream reported as a
generic network error, the 429 as a plain string), and pass here.

## Test plan
- [x] `npx vitest run` in `src/gaia/apps/webui`: 896 passed; `npx tsc
--noEmit` clean
- [x] `api.streamReliability.test.ts` (19) and
`ChatView.streamReliability.test.tsx` (15): silent and cut streams
re-attach with 0/3/10 s waits (about 13 s, to span a backend restart),
Stop cancels a pending reconnect and closes a stopped turn locally, a
replayed prompt keeps its answer, a prompt the run moved past is
dismissed, the waiting notice clears when the backend answers, a 404 on
re-attach loads the saved answer
- [x] Live, Vite :5319 against a fake backend with injected faults: a
stream gone silent mid-answer was cut at 30.0 s and re-attached, and the
whole answer appeared; a 429 read "GAIA is busy with another chat..."; a
send never answered showed "Waiting for GAIA to start this answer…" at 3
s and a plain error at 90.0 s; a run lost to a "restart" read "The
answer to your last message was lost..."

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

- `consumeSSEResponse` races each read against a 30 s timer; the
backend's padded keepalive every 5 s resets it for the whole turn. A
`status` with `phase: "queued"` (amd#5242's turn queue, which sends nothing
until the position changes) raises the limit to 10 min. A read that
fails mid-stream becomes `StreamDroppedError`; an attach that cannot
connect does too. A send that cannot connect stays a connection error,
since nothing may be running.
- Silence or a cut after `done`, or after an `agent_error` that is not
`recoverable`, ends the reader without reporting anything.
- `/chat/send` waits up to 90 s for headers (main's chat semaphore holds
a send 60 s before its 429); `/chat/attach` up to 30 s.
`StreamTimeoutError` carries which endpoint timed out.
- Replayed `permission_request`s whose `confirm_id` is already known are
skipped; `tool_start`/`tool_end`/`tool_result` and answer text dismiss
prompts still open, since the agent only gets past a prompt once it is
answered. Status events are excluded because keepalive statuses arrive
during a prompt wait.
- After a stop, the server can sit in `producer.join` without
keepalives; the client now closes such a turn locally instead of
reconnecting. The backend side is with the UI-backend reliability
session.
- Merge notes: trivial conflicts with amd#5241, amd#5242 and amd#5275 in
ChatView.tsx, and with amd#5242 in `attachToRun` (both add the same 404
branch).
</details>
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Oct 19, 2026
Before: two Agent UI chats on different models swapped models on every
turn, and starting a turn unloaded models that other apps sharing
Lemonade were answering with. When GAIA couldn't get the model (lease
timeout, not enough memory, server not answering), it showed a warning
and answered anyway, so Lemonade loaded the model itself and skipped the
free-memory check. Settings → Load and the auto-title went straight to
Lemonade with no lease or lock, so either could evict a model
mid-answer, and a title could load a second model. After: GAIA only ever
unloads models it loaded itself, and only to make room. A turn that
can't get its model fails and says why. Titles run on the side slot and
never load anything. Load asks before interrupting a chat that's
answering.

- **Shared server, shared rules.** Settings → Load, the post-download
auto-load and titles take the same lease and lock a chat turn does, in
the same order.
- **Stop is honoured before a load.** A turn stopped while waiting for
the model slot or another chat's load ends there: no load, no query. The
wait for another chat's load is shown.
- **A restart still knows GAIA's own models.** Chat models already on
GAIA's own Lemonade at startup count as its own, so they can be unloaded
to make room; on a server you run, nothing is.

Reproduced by `tests/unit/chat/ui/test_model_slot_discipline.py`; each
case fails on main and passes here, including a whole turn stopped
during the pre-flight.

Overlaps amd#5241 and amd#5275 (both edit `_chat_helpers.py`; different
functions). Builds on the amd#4772 discussion without fixing amd#4772 itself:
the title still uses the model it's given, but it can no longer load it.

**Merging with amd#5328:** whichever of the two lands second also carries,
as agreed with that PR's author:
- `except LeaseWaitCancelled` (quiet) in `_preflight_load`, ahead of its
catch-all;
- the chat title's wait for the model wrapped in `lease_wait_limit(30)`,
with the 504 logged at info and the title skipped that turn, plus a test
that it gives up.
- keep this PR's own raises of `InsufficientMemoryError` and
`ModelInUseError` ahead of that clause.

**Merging with amd#5337:** the two PRs conflict in one hunk of
`_chat_helpers.py` next to `model_load_lock`. Both sides only add code
there, so keep both. I ran a trial merge of the two locally: the UI
suite and amd#5337's non-streamed timeout test passed 8 times out of 8.
That test was racy with amd#5336's stop check, and amd#5337 now fixes it.

## Test plan
- [x] `pytest tests/unit/chat/ui tests/unit/test_chat_preflight.py
tests/unit/test_model_server_info.py
tests/unit/test_users_lemonade_untouched.py tests/unit/test_ui_warmup.py
tests/unit/test_broker_wiring.py`: all pass
- [x] `npx vitest run` in `src/gaia/apps/webui`: all pass, new
`api.loadModel.test.ts`
- [x] `python util/lint.py --black --isort --pylint --flake8`
- [ ] Live: two chats on two models that both fit, and confirm neither
is unloaded between turns

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

- `_maybe_load_expected_model` no longer unloads other resident chat
models. On `InsufficientMemoryError` it unloads only models in
`_models_loaded_here` (pre-flight and Settings loads record there, with
names normalized), says so in a status event, and loads once more.
Otherwise it raises.
- Exceptions now raised instead of a warning status:
`BrokerUnavailableError` (with the model and what to check),
`InsufficientMemoryError` (unchanged text), and `RuntimeError` for
anything else, including a non-200 `/health`. The streaming and
non-streamed paths both show the reason. The non-streamed path used to
substitute "make sure Lemonade is running" for every unclassified error.
- `_maybe_load_expected_model` wraps `_preflight_load`: any exception
raised while the turn's Stop flag or its own cancel event is set is read
as the Stop. That covers turns that pass those in, which the streamed
turn does. A non-streamed turn's Stop reaches the wait only through
amd#5328's `interactive_turn(cancel=...)`, so there only the `except
LeaseWaitCancelled` clause above keeps it quiet. amd#5328's
`test_stop_during_a_queued_preflight_stays_quiet_on_the_non_streaming_path`
guards that.
- A failed Settings or post-download load shows in `/api/system/status`
`probe_warnings` until a load succeeds.
- `model_load_lock` is taken with `_take_model_load_lock` (polls, shows
status, returns on Stop) after the lease. `_load_through_the_slot` in
`routers/system.py` uses the same lease-then-lock order.
- Title: `LemonadeClient.chat_completions` under one background-priority
`model_lease` spanning the residency check and the call;
`id_slot=SIDE_SLOT` when the model has two slots; `auto_download=False`.
- Ownership: the UI keeps a record of the models it loaded (`<GAIA
home>/ui/loaded_models.json`, written whole under a lock): pre-flight
and Settings loads, and any load its own agents make (a `LemonadeClient`
load listener). Models Lemonade no longer has loaded drop out of it. A
same-name copy at too small a window is reloaded only if the UI loaded
it or it is an auto-load (Lemonade's 4096 default or the supervisor's
profile window); otherwise `ModelInUseError` says another app has it.
- `/api/system/load-model` gains `force`. Without it the endpoint
returns 409 while any run is active. `loadModelAskingFirst` turns that
into a `confirm()` in Settings. The API schema and types are
regenerated.
- Updated tests that pinned the old behaviour: unload-before-load
(amd#1382's double-load case is now covered by the free-memory check),
swallowed pre-flight failures, and raw-HTTP titles.
- Not changed here: the retry-on-error path that re-runs the whole query
is amd#5338.
- LLM-affecting? Error surfacing only; prompts and tools are unchanged.
Categories to watch on the next RC: `rag_quality`, `gaia_core`.
</details>

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
kovtcharov-amd pushed a commit to kovtcharov/gaia that referenced this pull request Oct 19, 2026
amd#5266)

**Held until after v0.25.0.**

During a long turn the Agent UI gave little sign it was working, and its
motion was 84 hand-picked timings that reduced motion only partly
stopped. Now one live status line carries a subtle sweep while the model
works. Plan steps tick over, the side rail slides in, and queued
messages ease into place. Every timing comes from a small set of tokens,
reduced motion stops all of it (including the status typewriter and
smooth scrolling), and an idle window runs no animation at all.

- **Expect a merge-order conflict with the checklist, rail and queue PRs
(amd#5245, amd#5246, amd#5241, amd#5242).** Their motion lives in `motion.css` and
keys on their class names, so their files are untouched. Whichever lands
second must reconcile two things. The new lint fails on amd#5242's literal
`sb-dot-pulse 1.4s ease-in-out`, which becomes `var(--duration-pulse)
var(--ease-in-out)`. And a class renamed there would quietly switch this
motion off, so recheck the `motion.css` selectors once each of those PRs
merges.
- **Small visible changes from the token move:** spinners now share one
0.9 s turn (were 0.7–1 s), the typing cursor blinks at 1 s (was 0.6 s),
and the old 300–400 ms panel timings share 320 ms.

**Live status line, before and after, from real local turns** (main vs
this branch, same backend and prompt; reduced motion emulated in the
page):

![Live status line: before and after, normal and reduced
motion](https://raw.githubusercontent.com/kovtcharov/gaia/pr-assets/5266/live-status-before-after.gif)

- Before: only the cursor blinks, and with reduced motion on the label
still types itself out.
- After: a slow highlight sweeps the label while the model works. With
reduced motion on, the label appears whole, has no sweep, and
`document.getAnimations()` reports nothing running.
- The GIF is stitched from frames captured about 0.3 s apart, so the
sweep looks steppier than it does live.

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

- Tokens:
`--duration-fast|--duration|--duration-slow|--duration-spin|--duration-blink|--duration-pulse|--duration-shimmer`,
`--ease|--ease-in-out|--ease-linear|--ease-step`, `--stagger`,
`--toast-hold`.
- The shimmer is an alpha `mask-image` sweep, not a gradient fill (the
design language bans those). Its dim stop is 80%, which keeps the 11 px
label above AA in both themes.
- The global reduced-motion rule keeps 0.01 ms rather than `none`, so
`forwards` fills and toast holds still land. It now also forces
`scroll-behavior: auto`. JS motion reads `prefersReducedMotion()` from
`utils/motion.ts`.
- `motion.test.ts` rejects literal times, raw easings, `var()` fallbacks
and non-motion variables in any `animation*`/`transition*` declaration.
It also requires every loop to sit on a live-state selector.
- Queue-place changes animate only on remount. Adding `key={place}` on
amd#5242's `.sb-row-queue` span makes each change replay.
- With amd#5245 merged there are two live lines (`Thinking… · 24s` in the
bubble, `Waiting on the model · 8s` in the summary). Only the bubble
line shimmers. Folding the two into one is a product follow-up.
</details>

## Test plan
- [ ] `cd src/gaia/apps/webui && npx vitest run`: 857 pass, including
`styles/__tests__/motion.test.ts` and
`MessageBubble.liveMotion.test.tsx`
- [ ] `npx tsc --noEmit` is clean
- [ ] Run a multi-step turn in the Agent UI and send a second message
while it works. Check that the status line sweeps, the queued row drops
in, the rail slides in, and once the turn ends
`document.getAnimations().filter(a => a.playState === 'running')` is
empty.
- [ ] Turn on reduced motion in the OS (or emulate it in DevTools) and
repeat. The label appears whole with no sweep, spinners stand still, and
the rail and queue appear without movement.

Verified locally on main merged with amd#5245, amd#5246 and amd#5241 (backend
:4309, Vite :5309, real local turns), with reduced motion emulated in
the page.
kovtcharov-amd pushed a commit to kovtcharov/gaia that referenced this pull request Oct 19, 2026
The line under an answer showed developer stats ("1012ms TTFT · 68 → 510
tokens · 38.1 tok/s"), and permission prompts named internal tools
("Always allow `write_file on prompt-test.txt` in this chat", "ran
'write_file' without asking"). Now the footer reads "Answered in 40 s on
your GPU · first word in 1 s" (or "via Fireworks AI" for a cloud turn),
with the exact numbers one click away. Prompts read "Allow writing
file?" and "Always allow writing prompt-test.txt in this chat", and the
full-access notice says what ran: "Full access is on, so GAIA didn't ask
first. Writing file: prompt-test.txt".

Part of amd#5260. The suggestion-card item (cards wrapping 3 + 1) is
already fixed in amd#5240, which lays the cards out as a 2-column grid, so
this PR leaves it alone. On merges: this PR and amd#5241 both edit the
stats row under an answer, so expect a small conflict there. It also
touches the permission-request handling in the chat view next to code
that amd#5241, amd#5242, amd#5244 and amd#5245 change. It lands after v0.25.0.

## Screenshots
Footer (expanded by a click) and permission card, before → after:

| | Before | After |
|---|---|---|
| Light |
![](https://raw.githubusercontent.com/kovtcharov/gaia/efd1d2e456449ca32044b4bff748197a1353e1ce/before-light.jpg)
|
![](https://raw.githubusercontent.com/kovtcharov/gaia/efd1d2e456449ca32044b4bff748197a1353e1ce/after-light.jpg)
|
| Dark |
![](https://raw.githubusercontent.com/kovtcharov/gaia/efd1d2e456449ca32044b4bff748197a1353e1ce/before-dark.jpg)
|
![](https://raw.githubusercontent.com/kovtcharov/gaia/efd1d2e456449ca32044b4bff748197a1353e1ce/after-dark.jpg)
|

Footer before the click:
![](https://raw.githubusercontent.com/kovtcharov/gaia/efd1d2e456449ca32044b4bff748197a1353e1ce/after-dark-footer-collapsed.png)

## Test plan
- [x] `npx vitest run`: 860 passed. `npx tsc --noEmit` is clean
- [x] `pytest` on the Agent UI, permission, stdio, shell-prompt and
agent suites plus the flagship package tests: 6798 passed. The 3
failures are tool-count checks in `hub/agents/gaia` (87 tools found vs
95 declared). Optional dependencies are missing from the local venv, and
this PR doesn't touch tool registration
- [x] `python util/lint.py --black --isort --pylint` passes
- [x] Checked in the running app, in light and dark, before and after
(screenshots above). The footer shows plain words and expands on click,
and the permission card shows no tool ids
- [ ] Reviewer: run a turn on a local model and check that the footer
names the right device. Then run one on a cloud model and check that it
says "via …"

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

- Each turn's stats gain `place`, set by `_turn_place`. For a cloud
model it is the provider's name. For a local model it is the `device`
that Lemonade's `/health` reports for that model. Older messages have no
`place`, so their footer makes no claim about where they ran. The cloud
provider is resolved from the model before any Lemonade call, so a cloud
turn names it even with Lemonade stopped.
- `permission_request` gains `tool_label` (from `tool_phrase`, built on
`derive_narration`) and `always_label` (from `grant_phrase`, which uses
the same `_VERB_FORMS`). `always_scope` is unchanged because
`agent_ui_control` matches it exactly. Shell scopes get no label because
they are already the command itself.
- `GrantScope` gains an optional `subject` (the file or skill), so the
label can be worded without parsing it.
- The MCP `turn_view` footer still returns the raw numbers. Only its
docstring and the guide line about it changed.
</details>
@kovtcharov-amd kovtcharov-amd added the ready_for_ci Run CI workflows on draft PR without requesting review label Oct 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This PR does three things in the Agent UI. Messages typed while GAIA is answering now wait in a visible queue and run in order, or can be added to the reply that is running. A meter shows how full the model's context is. And Retry with… puts a second local model's answer beside the first. I found no correctness bugs. The queue hand-off can't lose a message: one lock means a message is either taken by the running reply or handed back to the chat. The retry refuses to run while any chat is answering, and it holds the model slot for the whole retry.

Two things to close before merge:

  • Add screenshots of the three features to the PR. The test plan describes checks in the running app, but nothing shows them. This rubric asks for before→after images for Agent UI changes.
  • Run Retry with… once against a real second model. It's still unchecked in the test plan. It's also the only part of the PR whose load-and-answer path ran only against stubbed endpoints.

Real-world evidence

N/A: no evidence bundle was produced for this run, so the Agent UI pixels and the real second-model retry are deferred to the strix-halo lane. This verdict rests on static review alone. Everything the PR says it tested in the running app is the author's own report; this run didn't reproduce any of it.

🔍 Technical details

🟡 Important

  • No visual evidence for an Agent UI change. The PR describes running-app checks (three back-to-back messages, a steered follow-up, the meter at 46%, the comparison panel) but embeds no screenshots. Per the rubric, add Playwright before→after images as raw.githubusercontent.com URLs. For the retry, include one run where both endpoints are real, not stubbed. answer_retry.answer_with's lease → _maybe_load_expected_model → _is_loaded → chat_completions chain has only been exercised through mocks in test_answer_retry.py.

🟢 Minor

  • A corrupt model_messages row becomes a bare 500 (src/gaia/ui/routers/chat.py, retry_with). db.get_message_record raises a ValueError with a useful message, but the handler only translates RetryError. Wrapping that call to return a 409/500 with the detail keeps the remedy visible in the UI:
    try:
        record = db.get_message_record(sid, request.message_id)
    except ValueError as exc:
        raise HTTPException(status_code=500, detail=str(exc)) from exc
  • The text-only retry path drops a taken follow-up (answer_retry.split_latest_turn). When a turn has no recorded model_messages, transcript_turns keeps only the last user row. A turn whose follow-up was folded in would then be retried with just the follow-up, not the original question. This only affects text-only turns; recorded turns carry both.
  • The PR description's merge note is stale. The branch already uses turn_queue (feat(ui): chat list shows what needs you, chats queue for the GPU, notification settings #5242's shape), so the "whichever merges second must switch retry_with" paragraph no longer applies. Trim it so a maintainer doesn't go looking for a missing commit.

Strengths

  • One lock covers wiring, unwiring and delivering in followups.py, and close_inbox hands untaken messages back with an identity check. A cached agent's next turn therefore can't have its inbox torn down, and a follow-up can't vanish. The 404/409 contract tells the client exactly when to keep a message queued.
  • context_usage reuses _plan_history, the same plan select_history follows, so the meter can't drift from what is actually replayed. The select_history refactor keeps its behaviour, and test_context_usage.py pins it.
  • The retry fails loudly and the user can act on each refusal: cloud model, not the latest answer, another chat busy, doesn't fit the window, empty answer from thinking. Each is a distinct status with a remedy. No tools are re-run, so there are no repeated side effects.
  • The docs cover the four new endpoints and their SSE events in docs/sdk/sdks/agent-ui.mdx, plus the user guide.

@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Request changes

This PR adds three things to the Agent UI. You can type while GAIA is answering, and the message waits in a queue and goes out as its own turn. A meter shows how full the model's context is. Retry with… answers the latest question on a second local model so you can compare the two. The backend is careful: retries reuse the turn's recorded evidence instead of running tools again, they are refused while any chat is answering, and every failure gives the user a reason. Two bugs can silently lose or break what the user typed, and both need fixing before merge:

  • Switching chats deletes the queue. If you queue messages, then open another chat while GAIA is still answering, those messages are gone when you come back. Nothing sends them and nothing warns you. The same happens to a message handed to the running reply when that reply ends while you're on another chat: the server returns it, but no open view receives it. The queue should be kept per chat (in the chat store, keyed by session) so it survives the switch and sends when the turn ends.
  • "Add to this reply" breaks file attachments. A normal message has its attachment links rewritten into file paths the agent can read. A message added to the running reply skips that step, so the agent receives a browser-only link and can't open the file.

Real-world evidence

N/A: no evidence bundle was produced for this run. The verdict rests on static review. The PR's test plan reports manual checks against a running app (three messages sent back to back, the meter reaching 46% with an attached file, the comparison view working with the retry endpoints stubbed). It has no screenshots, though, and Retry with… has not run against a real second model yet.

🔍 Technical details

🟡 Queue is dropped on session change (ChatView.tsx, the new useEffect on [sessionId] that calls setQueue([]))
queue is component-local state, and the reset effect wipes it whenever sessionId changes. The background run keeps going, but nothing will send its queued items. Items in delivered state are lost as well: close_inbox emits followup_returned, but the view now ignores the stale stream (isStale()), so those messages are only logged server-side ("returning them to the chat"). That is a silent drop of user input, which CLAUDE.md's fail-loudly rule forbids. Move the queue into chatStore, keyed by session. Either drain it when the view re-attaches, or drain it from wherever the run's done is observed. At minimum, warn before switching away from a non-empty queue. Add a test for queue → switch session → switch back.

🟡 Follow-ups bypass resolve_upload_links (src/gaia/ui/routers/chat.py, send_followup)
send_message passes resolve_upload_links(request.message) to the agent. followups.deliver passes the raw text, so a queued message with an attachment that is promoted via Add to this reply gives the agent [name](/api/files/uploads/…), which it cannot read. The fix has one constraint: the followup_taken event and the DB row must keep the original text, because messageQueue.taken() matches on exact text. So resolve the text only on the copy the agent sees. For example, have the inbox hold (original, resolved) pairs: get() returns resolved and on_take gets original. Alternatively, resolve inside Agent._drain_followups through a hook. A unit test asserting that the agent-side text carries the disk path would pin this down.

🟡 Agent UI change without screenshot evidence in the PR description
Per the review rubric, a change to the Agent UI needs before/after Playwright screenshots of gaia chat --ui embedded in the description: the queue panel, the context meter and its warning, and the comparison view. The test plan describes the checks but shows no images.

🟢 _pending retries outlive deleted sessions (src/gaia/ui/answer_retry.py)
store_pending holds one entry per session and nothing evicts it when a session is deleted. That is harmless at this size, but take_pending would happily serve a stale entry if a message id were ever reused. Dropping the entry from the session-delete path keeps the map honest.

🟢 A paused turn doesn't block a retry (retry_with, the turn_queue.locked() check)
A turn waiting on a permission prompt gives up its turn_queue slot, so Retry with… can load another model while that chat is technically still "answering". When the user approves the prompt, the paused turn pays a reload. This doesn't break anything, and the reload is bounded and visible, but the docs claim retries are refused "while GAIA is answering in any chat". Either check run_manager for any live run, or soften the doc line.

Strengths

  • The retry is built for safety. It never reruns tools, holds one broker lease across load and ask, and checks _is_loaded so Lemonade can't silently auto-load the model at a smaller window. Each failure maps to a 4xx/5xx with a remedy.
  • FollowUpInbox makes the agent's dequeue the moment a follow-up is recorded and announced, and the single _lock around open/close/deliver closes the gap where a message could land in an inbox nobody drains.
  • select_history was refactored into _plan_history, so the meter and the real cut share one plan and can't drift. It has good coverage: test_context_usage.py, test_answer_retry.py, and the queue/retry ChatView tests.

…adable

A follow-up handed to the running turn reached the agent with the browser's
upload link instead of the file's path, so the agent couldn't open the file.
The inbox now gives the agent the resolved path, while the chat still records
and matches the text as the user sent it.
# Conflicts:
#	src/gaia/agents/base/history.py
#	src/gaia/apps/webui/src/components/ChatView.tsx
…chat's turn ends

Messages queued while GAIA answered were dropped without a word when the
user opened another chat, and a message added to the running reply was lost
if that reply ended while the user was elsewhere. The queue now lives in the
chat store, keyed by chat, and is saved across reloads.

- An open chat sends its queue through its own view; any other chat's queue is
  sent in the background when a poll reports its turn over. One send per chat
  at a time, so a turn end and a manual send can't both send a message.
- A chat that missed its reply's end asks the new GET /api/chat/followup/{id}
  what that turn read and what it returned, so nothing is resent or dropped.
- A send that fails stays in the queue as "Not sent" with the reason and
  "Send again", and holds back the messages after it so order is kept. A send
  the server hasn't answered is no longer aborted when the user leaves.
- A message typed while others wait joins the end of the line.
- Deleting a chat deletes its queue; the delete button says how many first,
  and the chat list shows how many are waiting.
@kovtcharov-amd kovtcharov-amd added ready_for_ci Run CI workflows on draft PR without requesting review and removed ready_for_ci Run CI workflows on draft PR without requesting review labels Oct 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This lets you type while GAIA is still answering. The new message waits in a visible queue and is sent when the reply ends, even if you've switched to another chat. It also adds a meter showing how full the model's context is, and a Retry with… button that gets a second local model's answer to the same question and shows the two side by side. I didn't find any correctness bugs. The queue never drops a message without telling you: anything it can't confirm shows as Not sent. Retry doesn't run tools again, and it won't start while any chat is answering.

Still needed before merge:

  • Agent UI screenshots are missing. For an Agent UI change the rubric asks for before/after screenshots in the PR description. Three test-plan items are still unchecked: the queue surviving a chat switch, the screenshots themselves, and Retry with… against a real second model. Those are the parts a mocked test can't prove.
  • One note in the PR description is out of date. It says whichever of this PR and feat(ui): chat list shows what needs you, chats queue for the GPU, notification settings #5242 merges second must switch Retry with… over to the new turn queue. This branch already uses the turn queue, so that note should be removed.

Real-world evidence

N/A: no evidence bundle was produced for this run. The Agent UI screens (queue, context meter, comparison panel) need a live run on the strix-halo lane. This verdict rests on reading the code and on the author's own test notes; I didn't run anything.

🔍 Technical details

Issues found

🟡 No Agent UI screenshots for a UI-facing change (PR description)
The PR changes the composer, adds QueuedMessages, ContextMeter and AnswerComparison, and changes the Sidebar. The test plan describes running-app checks in words, but nothing is embedded, and "Before/after screenshots of the queue surviving a chat switch" is unchecked. Please add Playwright screenshots against gaia chat --ui, embedded as raw.githubusercontent.com images: the queue panel mid-turn, the queue still there after switching chats, the open context meter, and the comparison panel.

🟢 A pending retry outlives its deleted chat (src/gaia/ui/routers/sessions.py:403)
delete_session now calls followups.forget(sid) but not the equivalent for answer_retry._pending. A deleted chat's retried answer and its question stay in memory until restart. Add a forget next to store_pending/take_pending and call it here:

        followups.forget(session_id)
        answer_retry.forget(session_id)

(plus def forget(session_id): with _pending_lock: _pending.pop(session_id, None) in answer_retry.py, and answer_retry added to the import)

🟢 Keeping a retried answer drops the original footer fields (src/gaia/ui/routers/chat.py:840)
replace_answer overwrites inference_stats with the retry's stats, which have no steps or place. After Keep this answer, the message footer loses "on your GPU" and the step count from the original turn. If that's intended, a one-line comment would make it clear. Otherwise merge pending.stats over the original record's inference_stats.

🟢 Stop can't cancel a Retry with… (src/gaia/ui/routers/chat.py:791)
The retry holds turn_queue for model load plus generation (timeout=900), but it isn't registered with run_manager. A Stop click can't end it, and other chats' turns sit in line behind it with no indication of what they're waiting for. Fine as a follow-up, but worth tracking.

Strengths

  • followups.py handles wiring, unwiring and delivery under one lock, and checks identity before clearing _followup_queue. A follow-up therefore either reaches a live inbox or is refused with a 409, so it can't be stranded. reconcile marks anything the server can't account for as failed instead of guessing.
  • Moving select_history's planning into _plan_history lets context_usage reuse the same eviction logic instead of copying it, so the meter and the real history cut can't drift apart.
  • Retry re-checks that the model actually loaded before asking it. That stops Lemonade from auto-loading the model at a smaller window. Every refusal (cloud model, not the latest answer, another chat answering, too big for the window) returns an actionable status and message.

…ops its open comparison

Keeping a "Retry with..." answer replaced the message's stats outright, so its
footer lost the step count and where the turn ran. The retry's numbers now go
over the original's instead. Deleting a chat also forgets its open comparison,
which otherwise sat in memory until restart.
# Conflicts:
#	src/gaia/apps/webui/src/components/ChatView.tsx
#	src/gaia/apps/webui/src/services/api.ts
#	src/gaia/apps/webui/src/types/api.gen.ts
#	src/gaia/apps/webui/src/types/api.schemas.json
@kovtcharov-amd

kovtcharov-amd commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Checked in the real Agent UI with two real local models: messages queued mid-answer stay with their chat across a chat switch and are sent in order after the reply ends, even with another chat open; the context meter shows and moves; and Retry with… put a real Qwen3.5-4B answer beside the Gemma-4 one.

The Electron framework CI job had two real failures (ChatView over the 100 KB component limit, and a stale sidebar label test). Both are fixed in 4869e5ca0 with no behaviour change, and the whole run below was repeated on that commit with the same result, plus Keep this answer replacing the stored reply with Qwen's. The review's two 🟡 findings are fixed in 7ba44f563 with tests: a stopped turn keeps its original question when a message was added mid-reply, and a kept retry keeps its step count and where it ran.

🔍 Technical details

Run: PR head e033ab435, repeated on 4869e5ca0, vs origin/main 0749c8d37, webui built from each worktree (npm ci && npm run build), python -m gaia.ui.server on a free port with an isolated GAIA_HOME, Chrome driven by Playwright. Inference on the local Lemonade 11.8.1 (Vulkan GPU): Gemma-4-E4B-it-GGUF for chat, Qwen3.5-4B-GGUF for the retry.

Before (main): text typed while an answer streams just sits in the composer and is never sent; after switching chats and back it is gone (chat ends with 2 messages). No meter, no Retry with….

Typing mid-answer After the turn and a chat switch Answer actions
before typing before after before actions

After (this PR):

  1. Two messages queued while a 700-word essay streams; sidebar shows "2 to send".
    queue
  2. Switched to another chat mid-answer, then back while it was still running: the queue is still there.
    switched
    persists
  3. Left again and kept the other chat open until the essay ended. Both queued messages were sent while that chat was not open (it shows as unread in the sidebar), then answered in order.
    other chat open
    sent in order
  4. Context meter: 28% after the first turns, 29% after the essay and the two queued turns; the panel breaks down 19K of 66K tokens.
    meter
  5. Retry with… lists the downloaded models; picking Qwen3.5-4B-GGUF loaded it (9.5 s) and answered in 79.7 s at 49.6 tok/s, shown next to Gemma's 14.6 s / 33.4 tok/s answer.
    menu
    compare
  6. Re-run on 4869e5ca0: Keep this answer on the Qwen column; GET /api/sessions/{id}/messages then returns Qwen's text as the stored reply.
    kept
  7. On 7ba44f563: after keeping a retried answer, the footer still shows the step count and "on your GPU" without a reload.
    kept footer

Transcript of the first chat from GET /api/sessions/{id}/messages (the user left it at 21:07:58Z; the queued messages went out at 21:08:33Z and 21:08:43Z while the other chat was open):

21:07:43  user       Write a detailed 700-word essay on the history of lighthouses ...
21:08:32  assistant  Lighthouses are more than just tall towers; ... (essay)
21:08:33  user       Reply with exactly this and nothing else: QUEUED-ONE violet-otter-92
21:08:43  assistant  QUEUED-ONE violet-otter-92
21:08:43  user       Reply with exactly this and nothing else: QUEUED-TWO APAC-8610
21:08:48  assistant  QUEUED-TWO APAC-8610

GET /api/chat/active was empty after the last reply, so nothing was left running. Full JSON: transcript_chatA.json.

…ebar ARIA test

The Electron framework job failed on two checks: ChatView.tsx had grown past
the 100 KB per-component limit, and a source-text test still expected the old
delete-button label that the unsent-messages wording replaced.

- Move the Retry with... comparison state and handlers into
  useAnswerComparison, and the context meter's fetch/reset into
  useContextUsage. Behaviour is unchanged.
- Match the sidebar test to the new "Confirm delete <title> and its N unsent
  messages" label.
@kovtcharov-amd kovtcharov-amd added ready_for_ci Run CI workflows on draft PR without requesting review and removed ready_for_ci Run CI workflows on draft PR without requesting review labels Oct 19, 2026
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Oct 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🟡 Keeping a "Retry with…" answer still drops the step count and "where it ran" from the footer until the chat is reloaded. The server now keeps them, but the Agent UI rebuilds the message's stats from a fixed list of fields and leaves those two out. Use the stats the server sends back as they are.

🔍 Technical details

choose_retry in src/gaia/ui/routers/chat.py now returns {**record["inference_stats"], **pending.stats}, which includes steps and place. handleKeepAnswer in src/gaia/apps/webui/src/hooks/useAnswerComparison.ts copies only tokens_per_second, time_to_first_token, input_tokens, output_tokens, model, retried and seconds. So the bubble's message.stats?.steps (MessageBubble.tsx:540) and place are undefined until a reload fetches the stored row.

                        stats: {
                            ...m.stats,
                            ...s,
                            tokens_per_second: s.tokens_per_second ?? 0,
                            time_to_first_token: s.time_to_first_token ?? 0,
                            input_tokens: s.input_tokens ?? 0,
                            output_tokens: s.output_tokens ?? 0,
                            retried: true,
                        },

You'd also need to widen the chooseRetry return type so stats carries steps/place. A ChatView.retryWith test asserting the step count survives a kept retry would pin it.

@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This PR adds three Agent UI features. A message typed while GAIA is answering now waits in a queue instead of being refused. A context meter shows how full the model's window is and which old turns are about to drop out. Retry with… puts a second local model's answer next to the first so you can keep either one. The work is careful: queued messages stay with their chat across switches and reloads, a retry never reruns tools or evicts another chat's model, and every path has tests.

One edge case should be fixed before merge. If a turn is stopped or fails after it has already read a message added mid-reply, that chat's memory can lose the original question. The added message gets saved on its own, and when the stopped turn's full record is missing, the saved history pairs the answer with the added message instead. Later turns, and any Retry with… on that answer, then work from the wrong question.

Real-world evidence

N/A: the evidence stage produced no bundle for this run. The PR's test plan reports runs against the live app (three back-to-back messages answered in order, a mid-reply message picked up, the meter rising on attach, the queue surviving a chat switch). It also links screenshots of Retry with… against a real second model (Qwen3.5-4B next to Gemma-4-E4B) in a PR comment. I didn't re-run any of it, so this verdict is a static review plus the author's reported results.

🔍 Technical details

🟡 A stopped turn can drop its original question from history (src/gaia/ui/_chat_helpers.py, _followup_taken)
_followup_taken writes the added message as its own user row in the middle of the turn. transcript_turns keeps only the last user row before an assistant row (each new user row overwrites pending). That's fine when the assistant row has model_messages, because the recorded turn wins. But result_holder["model_messages"] is only set when process_query returns, so a turn that is stopped or errors has model_messages=None and gets the text fallback. That fallback pairs the answer with the added message, and the original question disappears from replay. It also feeds answer_retry.split_latest_turn, which uses turns[-1] when recorded is False. Two possible fixes: have transcript_turns join consecutive user rows into the pending turn, or save the turn's agent.conversation_history slice when it stops. Either way, add a test covering a stop after a follow-up was taken.

🟢 choose_retry drops the comparison before checking it can apply (src/gaia/ui/routers/chat.py, choose_retry)
take_pending pops the entry before the latest_message_id 409 check runs. If that check fails, the user can't choose "original" afterwards. The 409 text already says to run Retry with… again, so this is minor, but peek first and pop on success to keep the error recoverable.

🟢 Retry holds the global turn slot for up to ~15 min (answer_retry.answer_with, timeout=900)
While answer_with runs, every other chat's new turn waits in turn_queue. That's intended (so the retry doesn't evict another chat's model), but the docs don't say other chats queue behind a retry. Worth one line in docs/guides/agent-ui.mdx.

Strengths

  • context_usage runs the same _plan_history as select_history, so the meter can't disagree with what the model actually receives, and test_the_view_matches_what_select_history_replays checks that.
  • The follow-up inbox's single lock makes delivery all-or-nothing: a message is either in a live inbox or refused with 404/409. Untaken messages come back through followup_returned / last_outcome, so none are lost.
  • Retry errors follow fail-loudly: load, health, and answer failures each become a 503 that says what to do, with no silent fallback model.

… a kept retry keeps steps and place

A turn stopped after taking a message added mid-reply saves no model
messages, so history replay fell back to text and paired the answer with the
added message, dropping the original question from later turns and from Retry
with.... Consecutive user rows before an unrecorded answer are now joined into
that turn's question.

Keeping a retried answer also rebuilt the bubble's stats from a fixed field
list, so the step count and "where it ran" disappeared until a reload. The
stats the server returns are now applied as sent.
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Oct 19, 2026
@kovtcharov-amd kovtcharov-amd added ready_for_ci Run CI workflows on draft PR without requesting review and removed ready_for_ci Run CI workflows on draft PR without requesting review labels Oct 19, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This PR lets you type while GAIA is answering: the message waits in a queue that stays with its chat and goes out when that chat's reply ends. It also adds a meter showing how full the model's context is, and a Retry with… button that puts a second local model's answer beside the first so you can keep either. The backend side holds up: a retry takes the shared model slot so it can't unload a model another chat is using, follow-up messages can't be lost between delivery and the end of a turn, and deleting a chat clears its open comparison and follow-up record. Nothing blocks the merge. Three small points are below.

  • A retry can occupy the model for up to 15 minutes, and there is no way to stop it. Every other chat queues behind it until it finishes.
  • The change to history replay is not quite "behaviour unchanged". A question that never got an answer is now glued onto the next question in older text-only chats, where before it was dropped.
  • The "is this a cloud model?" check on Retry with… ignores cloud models the server discovered at runtime.

Real-world evidence

N/A: no evidence bundle was produced for this run. The PR description lists checks against the running app (three back-to-back messages answered in order, the queue surviving a chat switch, the meter moving to 46% after attaching a 65 KB file). It also links before/after screenshots and a real two-model Retry with… run (Qwen3.5-4B next to Gemma-4-E4B) in a PR comment. I couldn't run the Agent UI or the new Python tests on this runner (pytest isn't installed), so for those surfaces the verdict rests on static review plus the author's evidence.

🔍 Technical details

Issues found

🟢 A retry holds the model slot with no way to cancel it (src/gaia/ui/routers/chat.py:791). retry_with acquires turn_queue and holds it across answer_with (timeout=900). Chat turns in other sessions wait behind it. /api/chat/cancel only removes waiters (turn_queue.cancel), so it can't end a retry. Pass a cancel event, or document the wait in the UI's busy message. Not blocking, since retries are opt-in and the UI shows a pending state.

🟢 An unanswered question now gets merged into the next one (src/gaia/agents/base/history.py:236-241). Before, a user row with no answer was replaced by the next user row, so a failed or abandoned question was dropped from replay. Now it is joined with "\n\n" onto the next question whenever that turn is saved text-only (model_messages is None). Recorded turns are unaffected. Your tests cover the mid-reply follow-up case, but not "Q1 failed with no assistant row, then Q2 answered text-only". Worth either a test that pins the intended result, or limiting the merge to rows the follow-up inbox wrote. Either way, mention it alongside the context_retention eval category you already flagged.

🟢 The local-only check misses discovered cloud models (src/gaia/ui/routers/chat.py:757). cloud_model_provider(request.model, None) passes no metadata, so a cloud model Lemonade discovered at runtime counts as local. The request still fails, with a 503 from the loader, so this isn't a silent fallback. But the user sees "could not be loaded" instead of "pick a local model". Elsewhere the code uses LemonadeClient.cloud_model_provider(model), which reads the cached metadata.

Strengths

  • Follow-up delivery can't lose a message: followups.py delivers, closes the inbox and hands back untaken messages under one lock, the identity checks keep a cached agent's next turn from being unwired, and last_outcome lets a chat that wasn't open settle its queue against what the server actually recorded.
  • The retry is safe by construction. It never re-runs tools (so side effects aren't repeated), refuses while any chat holds or waits for the model, loads and asks under one model_lease, and turns loader and connection failures into RetryError messages that tell the user what to do. No silent fallbacks.
  • _plan_history is pulled out of select_history, so the meter's context_usage uses the same eviction logic as the real replay and can't drift from it. The frontend's cross-chat queue dispatch also has thorough race tests (turn end racing a poll, a chat deleted mid-send, a send failing after the user left).

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 19, 2026
Merged via the queue into amd:main with commit 63b51a6 Oct 19, 2026
65 of 68 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the claude/ui-composer-context-retry-779e65 branch October 19, 2026 22:23
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Oct 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents documentation Documentation changes electron Electron app changes ready_for_ci Run CI workflows on draft PR without requesting review tests Test changes

Projects

None yet

2 participants