Skip to content

fix: Agent UI and agent bugs found in an end-to-end UI test - #5311

Merged
kovtcharov-amd merged 26 commits into
amd:mainfrom
kovtcharov:kalin/ui-main-fixes
Oct 19, 2026
Merged

kovtcharov-amd merged 26 commits into
amd:mainfrom
kovtcharov:kalin/ui-main-fixes

Conversation

@kovtcharov

@kovtcharov kovtcharov commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

An overnight end-to-end test of the Agent UI, run against a live backend with every open UI PR merged, turned up these bugs in code already on main. Each one wasted the user's time or misled them.

  • Approval that meant nothing: GAIA asked "Allow writing file?" for a path in the system temp folder, then refused the write anyway after the user clicked Allow.
  • A dozen drive-wide searches: given a wrong file path, the agent searched the whole drive a dozen times over nearly three minutes before saying the file wasn't there.
  • A stranger's file in an unrelated chat: a file named in a past chat's error, stored in memory, came back as "read it now" in a chat that had nothing to do with it.
  • History lost early on cloud models: Fireworks chats dropped older messages after two short turns.
  • Silent or garbled send failures: a send that died early showed nothing at all, and a server error showed a raw JSON body.

After this PR, each of these works as the user would expect.

  • Agent and tools:
    • A write to a path no approval can grant is refused before the approval card appears.
    • A missing file allows one search, then the agent asks the user.
    • The answer check reads the user's own words, not the recalled memory prepended to them.
    • A cloud model's reply no longer takes space from its 64K history budget: about 12K of history before, about 32K now.
    • The summarize skill keeps its 3-bullet cap when asked to reformat an earlier answer.
    • Each indexed document is listed with its path, so the agent stops searching the disk for a file the user already attached.
    • A document query counts as the search an answer reports, ending false "no search ran" corrections.
    • Every file tool's missing-file error carries the one-search stop rule.
    • An access prompt that is declined or left unanswered isn't asked again for the same folder in that turn. One unanswered prompt used to cost three 10-minute waits.
  • Agent UI:
    • A send's errors read as sentences.
    • A stream that closes before any answer shows an error.
    • A message sent while a chat is still loading is no longer wiped by the late history load.
    • The live line names the running tool in words.
    • Status and message polling pause while the window is hidden.
    • Escape closes Scheduled tasks.
    • .mdx, .markdown and .rst can be added to the document library.
    • Mobile access drops its QR box when ngrok is missing.
    • Privacy shows the real data folder.
    • The memory list's page buttons have names for screen readers.

Several of these change what the model sees: the tool error wording, the grounding input, the history budget and the summarize skill. Categories to watch on the next RC: error_recovery, rag_quality, context_retention, tool_selection. A local run on Fireworks scored tool_selection 7/7 and context_retention 4/4. With the document and access-prompt fixes, all 12 rag_quality scenarios passed (csv_analysis went from 5.4 to 10/10), where this morning's run passed 9 of 12.

Test plan

  • python -m pytest tests/unit/agents tests/unit/chat passes
  • npx vitest run and npx tsc --noEmit -p . in src/gaia/apps/webui pass
  • python util/lint.py --black --isort passes
  • gaia chat --ui: ask GAIA to write a file under %TEMP%; it refuses without showing an approval card
  • gaia chat --ui: open a chat and send immediately; the message stays after the history loads
  • gaia chat --ui on a Fireworks model: after four or five turns, the earliest messages are still in view
🔍 Technical details
  • read_first_preflight refuses when PathValidator.unaskable_reason() is non-empty (temp dir, blocked or secret dirs, env scope), and the refusal is still audited as denied. Askable out-of-scope paths are unchanged.
  • missing_file_error() in path_access.py is shared by read_file and index_document; the old error told the model to search elsewhere.
  • _grounding_findings and _note_ungrounded use _original_user_input, as the plan executor already does.
  • history_budget subtracts no reply reserve for Lemonade cloud models. Local models and Claude are unchanged, and the doc in agent-ui.mdx is updated. feat(agent): move already-read tool results out of the prompt before the window fills (opt-in) #5310 also edits history.py, so whichever lands second has a small conflict.
  • consumeSSEResponse takes silentCloseIsError from sendMessageStream only, so re-attach still treats an empty replay as done.
  • setVisibleInterval pauses the system-status and message-count polls only. The chat list and active-run polls keep running, because they drive notifications while the user is in another app.
  • System status gains data_dir; api.gen.ts and api.schemas.json are regenerated.

@github-actions github-actions Bot added documentation Documentation changes rag RAG system changes tests Test changes electron Electron app changes security Security-sensitive changes performance Performance-critical changes agents labels Oct 18, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This PR fixes a batch of real bugs from an end-to-end Agent UI run. GAIA no longer asks to approve writes it would refuse anyway. A wrong file path no longer sets off a drive-wide search loop. Recalled memory no longer passes for the user's request. Cloud chats stop dropping history after a couple of turns. Failed sends now show a readable error. Each fix is small, scoped and covered by a focused test, and I found nothing blocking.

  • One test file uses Windows-style paths that don't contain the backslashes they appear to, so it is weaker than it looks. It's a one-line fix (details below).
  • Four changes affect what the model sees: the missing-file wording, the grounding input, the cloud history budget and the summarize skill. The PR already names the eval categories to watch on the next RC (error_recovery, rag_quality, context_retention, tool_selection), and a local Fireworks run is reported.

Real-world evidence

N/A: no evidence bundle was produced for this run. The verdict rests on static review alone. The Agent UI changes (approval refusal, send-while-loading, error text, Privacy folder, mobile-access error state) still need the gaia chat --ui checks listed in the test plan, with before→after screenshots once the strix-halo lane runs.

🔍 Technical details

Issues

🟢 Backslashes vanish from the test path (src/gaia/apps/webui/src/components/settings/__tests__/PrivacySettings.dataDir.test.tsx:176-178). In a JS string, 'D:\gaia-home\chat' becomes D:gaia-homechat because \g and \c are not escape sequences. The test still passes because both sides lose the backslashes the same way, but it never checks a real Windows path.

        useChatStore.setState({ systemStatus: { data_dir: 'D:\\gaia-home\\chat' } as SystemStatus });
        render(<PrivacySettings />);
        expect(screen.getByText('D:\\gaia-home\\chat')).toBeInTheDocument();

🟢 Dropped initial load leaves the message count unsynced (ChatView.tsx around line 333). When a send lands during the initial load, lastMsgCountRef is set to the pre-send server count. The next visible poll then sees a different count and calls setMessages. That is harmless once streaming has ended, and the poll already skips while isStreaming. The comment says the turn's own refetch syncs the list; it's worth confirming that refetch always runs on the error path too.

Checked and fine

  • read_first_preflight only short-circuits when unaskable_reason is non-empty. It still audits the denial, and access_denied_message supplies the "No approval can grant it" wording the test asserts. Askable out-of-scope paths still return None, so the tool asks its own question.
  • history_budget sets the reply reserve to 0 only for cloud and not _use_claude. Local models and Claude keep max_tokens, and both branches have tests.
  • _request_text falls back to query when _original_user_input is unset, and memory.py resets it per turn.
  • silentCloseIsError is set only from sendMessageStream, so re-attach still treats an empty replay as done. The new error branch reuses the existing parseErrorDetail, getFriendlyError and ApiError helpers.

Strengths

  • missing_file_error puts the read and index error paths behind one helper with a clear stop rule, and keeps the NOT_EXECUTED marker.
  • test_markdown_extensions.py pins the web UI's extension list to the server's ALLOWED_EXTENSIONS, so the two can't drift silently again.
  • setVisibleInterval is small, returns its own cleanup, and its doc comment warns against using it for notification polls.

@kovtcharov

Copy link
Copy Markdown
Contributor Author

Both suggestions are handled. The data-folder test now uses a real Windows path. On the initial-load question: on the error path no refetch runs, but the next visible poll sees the changed count and syncs the list from the server. That's correct; the comment now says so instead of claiming a refetch.

One more change came out of testing the open UI PRs together: api.ts would cross the 50 KB per-file limit in the Electron installer test once they all land. The connector calls, which no open PR touches, moved to their own module and are re-exported, so callers don't change.

The latest Linux unit-test failure is a timing flake in test_sse_handler.py (7.7 s against a 5 s budget), in code this PR doesn't touch. It passed on macOS and Windows; it needs a re-run by someone with rights to re-run jobs.

🔍 Technical details

The Agent UI asked "Allow writing file?" for a path in the system temp folder; the user clicked Allow, and the write was then refused as off-limits. The write tools' preflight now refuses such paths up front, still audited as denied.
Given a wrong absolute path, the agent ran a dozen whole-drive searches over nearly three minutes before saying the file wasn't there; read_file's error even told it to search elsewhere. read_file and index_document now share one error: name what is missing, allow one search, then ask the user.
A file a past chat's error left in memory (eval/corpus/adversarial/empty.txt) was sent back as "you haven't read empty.txt, read it now" in an unrelated chat: memory is prepended to the message, and the grounding check treated every path in it as part of the request. Both grounding entry points now use the clean request, as the plan executor already does.
…swer

Asked for "the same report as bullets", the agent let the request override the 3-bullet cap and wrote five. The limits now hold for a reformat too; only a number the user names overrides them.
Dropping a .mdx doc was rejected as unsupported, though it is Markdown; .markdown and .rst had an extractor but no way in.
It was the one dialog that ignored Escape.
…start

With ngrok missing it showed a red 'Failed to connect' QR placeholder and 'Scan the QR code' steps under the real reason.
Screen readers heard two unnamed buttons under Memory > Advanced.
…budget

On Fireworks, older messages dropped out of view after two short turns: the 64K cloud input budget also reserved 32K for the reply, leaving ~12K for history although the reply is written into the provider's own, far larger window. Cloud models now reserve nothing there; local models are unchanged.
A server error during send showed 'HTTP 500: {"detail": ...}' under an all-caps mono label; it now shows the server's reason in the sentence-case banner. A send whose stream closed before any answer left the message with no answer and no error; it now reports that the connection closed.
A minimized Agent UI kept asking for system status every 5 s and the open chat's message count every 3 s. Both now pause while hidden and refresh once shown; the chat-list and active-run polls keep running because they raise notifications while the user is in another app.
…l in words

Sending right after opening a chat could lose the message: the history load that started first landed later and replaced the list. A load that began before a send now leaves the list to the turn's own refetch.

The live line said "Running search_web" while the step row said "Searching web"; it now uses the step's wording.
It always said ~/.gaia/chat/, wrong for anyone with GAIA_HOME set. System status now reports the chat database's folder, and the row shows only once it is known.
'D:\gaia-home' in a JS string drops its backslashes, so the test compared two backslash-free strings. Also corrects a comment: after a failed send, the next poll (not a refetch) syncs the message list.
api.ts is 41 KB on main, and the open Agent UI PRs together take it to 51 KB, past the 50 KB per-file limit the Electron installer test enforces. Main would fail that test once they all land. The connector section, which no open PR touches, moves to connectorsApi.ts, and api.ts re-exports it, so no caller changes.
…rches for it

The per-turn [Indexed documents: ...] line gave filenames only. For an attached CSV the agent searched the disk, found many copies and opened the wrong one, then hit an access denial. Each entry now carries its path. csv_analysis went from 5.4 to 10/10; rag_quality has no regressions.
After query_specific_file ran, the answer check still said no search ran this turn, so the agent re-ran its searches and sometimes left the check's note in the answer. Tools named query_* now back a search claim, and "I ran two searches" reads as a search, not a command.
…oking

get_file_info, the edit tools and the filesystem read returned a bare 'File not found', so the agent searched folder after folder and asked for access to whole directories. They now use the shared error with its one-search stop rule.
When an access prompt went unanswered, every tool that touched the same folder asked again and waited out the 10-minute timeout again. skill_document_brief_gaps spent 30 minutes on one turn that way. A path declined or left unanswered is now refused without asking for the rest of the turn, along with anything inside it; the next turn asks afresh.
# Conflicts:
#	src/gaia/apps/webui/src/App.tsx
#	src/gaia/apps/webui/src/components/ChatView.tsx
#	src/gaia/apps/webui/src/services/api.ts
# Conflicts:
#	src/gaia/apps/webui/src/components/AgentActivity.tsx
#	src/gaia/apps/webui/src/components/settings/PrivacySettings.tsx
# Conflicts:
#	src/gaia/apps/webui/src/App.tsx
# Conflicts:
#	src/gaia/ui/database.py
# Conflicts:
#	src/gaia/apps/webui/src/components/ChatView.tsx
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This PR fixes about fifteen bugs found in an end-to-end run of the Agent UI. The worst of them: an approval card that couldn't actually grant the write, the agent searching the whole drive a dozen times for a file that was never there, a file from an old chat's memory showing up in an unrelated chat, cloud chats losing their history after two turns, and send failures that showed nothing or a raw JSON body. Each fix is small and has a test, and the backend and frontend changes agree with each other. I found no correctness bugs that block a merge.

  • Missing proof on the real app. Every gaia chat --ui item in the Test plan is still unchecked, and the PR shows no screenshots or route output. The ones that matter most are the temp-folder write that's now refused without a card, and a message sent while a chat is still opening. Add them before merge, or say they're waiting on the strix-halo lane.
  • Run the evals on the next RC. This changes what the model sees: the missing-file wording, the grounding input, the cloud history budget and the summarize skill. The PR already names error_recovery, rag_quality, context_retention and tool_selection. Watch those four on the next RC.

Real-world evidence

N/A: no evidence bundle was produced for this run. The verdict rests on reading the code and the PR's unit and vitest tests. None of the Agent UI flows above were exercised here.

🔍 Technical details

Issues

🟡 No real-world evidence for UI-visible changes. The PR changes the Agent UI (send errors, the live tool label, Mobile access, Privacy's data folder, Escape on Scheduled tasks) and the /api/system/status response (data_dir). The description has neither screenshots nor route output. A curl /api/system/status | jq .data_dir and one before/after screenshot of the temp-write refusal would cover most of it.

🟢 A failed initial load can still wipe a just-sent message (ChatView.tsx catch branch of loadMessages). The success path now checks sentRef, but the catch path still calls setMessages([]) when isInitial. If the history fetch fails while a send is in flight, the user's bubble disappears, which is the same race this PR fixes on the success path.

                if (isInitial) {
                    log.chat.error(`Failed to load messages for session=${sessionId}`, err);
                    if (sentRef.current === sentBefore) setMessages([]);
                }

🟢 _refused_paths grows for the life of the agent (agent.py, _ask_path_access area). Only entries for the current turn are ever matched, but old ones are never dropped. It's harmless in practice, but it would be cleaner to clear the list when _turn_seq changes, or to store a (turn, set) pair and reset it.

🟢 Circular import between api.ts and connectorsApi.ts. connectorsApi.ts imports apiFetch/UI_HEADER from ./api, and api.ts does export * from './connectorsApi'. This works today because both names are only read inside function bodies at call time. A future top-level use of either in connectorsApi.ts would hit an uninitialized binding. Moving apiFetch/UI_HEADER into a small apiCore.ts would remove the cycle.

Strengths

  • The approval-card fix is in the right place. read_first_preflight now asks grant_refusal_reason and refuses before the prompt, still audits the refusal as denied, and askable out-of-scope paths are unchanged. Both branches have tests.
  • missing_file_error() puts one stop rule into every file tool (read/edit/info/index/filesystem), where there used to be six ad-hoc strings. One of those old strings told the model to keep searching.
  • test_markdown_extensions.py pins the webui SUPPORTED_EXTENSIONS to the server's ALLOWED_EXTENSIONS, so the two lists can't drift apart again.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 19, 2026
Merged via the queue into amd:main with commit 761d89c Oct 19, 2026
102 of 111 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/ui-main-fixes branch October 19, 2026 19:39
grtninja pushed a commit to grtninja/gaia that referenced this pull request Oct 20, 2026
…md#5326)

Before, a chat didn't show where it ran, what it could touch, or what it
changed on disk, and its folder and internet settings weren't enforced.
Now each chat has a session panel with this answer's sources, where the
chat runs, the folders it may use, an internet switch, everything it
produced, and every file it changed, plus a whole-chat diff, Undo all,
and a git Commit or PR that runs only after you confirm. Removed folders
and internet-off are enforced by the agent itself, before any approval
prompt. Only true loopback addresses count as "this PC", and a commit
never stages files git ignores.

It also carries fixes found testing the merged UI: Retry with… lists
friendly model names, names update once they load, local models get
their own still-waiting hint, New chat focuses the message box and its
task cards come back on their own, the panel's resize edge is easier to
grab, and a web call that internet-off refused no longer shows as a
failed lookup or as a site GAIA contacted.

This PR now replaces amd#5283 (closed). It was rebuilt on main so it
carries only what isn't merged yet.

## Test plan

- [x] `npx tsc --noEmit`, `npx vitest run` (1465 passed) and `npm run
build` in `src/gaia/apps/webui`
- [x] `npx jest` in `tests/electron`: all pass on Linux line endings;
ChatView is 101.6 KB of the 102.4 KB limit
- [x] `pytest tests/unit/agents tests/unit/chat/ui` plus the security
and shell suites; the only failures also fail on main on this machine (a
background thread trying to start the daemon, and `test_step_timing`)
- [x] `python util/lint.py --black --isort`
- [x] Agent UI on a fresh GAIA home with a local model: a turn edits two
files in a git folder, the panel shows them under Outputs and Changes,
Review changes shows the diff, Commit commits only those files, and Undo
all restores them (screenshots in the evidence comment)
- [x] Agent UI with internet off: web search and a page fetch are
refused before running, the message box says the chat is offline, and
the panel doesn't claim a failed lookup or a contacted site
- [ ] Flagship eval at the next RC: the agent loop now refuses calls up
front when internet is off or a folder was removed

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

- Rebuilt from `origin/main` by cherry-picking the amd#5283 commits and
this PR's own fixes. Commits already on main via amd#5275 or amd#5311 were
dropped (the Retry with… turn-queue fix, the live-line tool label,
`visibleInterval`). API types were regenerated with `export_openapi` +
`gen:api-types` and match the merged files.
- Conflicts were resolved keeping main's behaviour.
`PathValidator.validate_read` keeps main's
missing-file-instead-of-prompt flow and checks removed folders first.
Main's deepest-first removal of created folders moved into the new
shared `_apply` used by Undo and Undo all. `ContextPanel` was split into
`ContextDetails` (shown in the panel) and the standalone sheet, starting
from amd#5275's final per-section error handling.
- New: `useJumpToMessage` moves jump-to-turn out of ChatView to keep it
under the size budget. `turn_summary._ran` skips calls whose result says
they never ran (`executed: False` or `status: denied`) when it counts
sites and live-data failures. The guide no longer says localhost pages
stay fetchable offline, because the web tools refuse private addresses
on their own.
</details>

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents documentation Documentation changes electron Electron app changes performance Performance-critical changes rag RAG system changes security Security-sensitive changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants