Repository navigation
fix(agent): tell the flagship its own folders and the Agent UI's scheduler - #5564
Conversation
…duler Asked to "summarize vendor_contract.md in my documents folder", the flagship spent 8-11 tool calls trying ~/Documents and the home folder before finding GAIA's documents folder, which it could read all along. The system prompt now names the session's folders (existing, deduplicated, GAIA's documents folder labelled) and says to look there first. The line is computed once per session so the cached prefix stays stable, and the fast chat profile, which has no file tools, gets none. Asked to set up a recurring task in the Agent UI, it said it had no scheduler and pointed at Windows Task Scheduler. Agent UI sessions now get one line pointing at the Scheduled tasks page. Nothing told the agent which front-end it serves, so ChatAgentConfig gains `surface`, set to "agent_ui" by the in-process UI paths and sent by the relay as `/query`'s new `surface` field (contract 2.19, only to sidecars that advertise it).
|
Verdict: Request changes (evidence only; the code looks ready) This PR fixes two ways the flagship lost turns. It now tells the model which folders the session can use, with GAIA's own documents folder listed first. In the Agent UI it also tells the model that the sidebar has a Scheduled tasks page, so it stops saying it can't schedule anything. The new The one thing missing is proof that it works on the surface users touch. Both Agent UI test-plan items are unchecked, and there's no captured Real-world evidenceN/A. No evidence bundle was produced for this run. The verdict rests on static review and the PR's unit-test results. The Agent UI behaviour (the folder lookup and the scheduler pointer) and the real 🔍 Technical details🟡 Missing real-world evidence
🟢 Nits
Checked and fine
Strengths
|
The new prompt-context tests import gaia_agent_chat, which the plain unit lane does not install, so that lane's wholesale-skip check failed. They now run in test_chat_agent.yml and are allowlisted for the unit lane. SPEC also says which folders the prompt names and when.
|
The evidence is now in the PR body. It shows a real Agent UI turn carrying 🔍 Technical detailsEvidence (PR body, "Evidence" section). The real sidecar ran under uvicorn and built the real CI root cause.
Nits.
Tests run.
Commit: 6fee703 |
…5610) Four timing-sensitive unit tests failed 8 unrelated PRs this week (#5537, #5539, #5562, #5563, #5564, #5565, #5566, #5568) and one of main's last 11 completed runs. Each still guards the same bug, but no longer races the clock on a busy runner. Every rewritten test was checked by breaking the code: it fails on the real bug and passes 50/50 runs, including under full CPU load. The PR also keeps three tests out of the developer's real `~/.gaia`. ## Test plan - [x] `pytest tests/unit/mcp/client/test_stdio_hung_server.py tests/unit/test_file_lock.py tests/unit/test_mcp_bridge_concurrency.py tests/unit/chat/ui/test_agent_model_override.py tests/integration/test_folder_indexing.py -n 4`: 316 passed, 3 skipped - [x] The four de-flaked tests, run 50x each: 250/250 serial, and 250/250 under xdist (32 workers) with all 32 cores also running busy loops. Main's versions in that same loaded run: redaction failed 10/50. - [x] Each test fails when its bug is put back in the code (see details) - [x] `tests/integration/test_folder_indexing.py -n 4`, 5 runs: all pass. Main's version fails 7 to 9 tests per run. - [x] Test 841 passes with `GAIA_HOME` set to a temp dir. Main's version fails. - [x] Electron `npx jest`: 1098 passed. The one failure, `test_electron_chat_installer.js` (component size 103,725 > 102,400), also fails on main and is unrelated. - [ ] CI green on Linux, macOS and Windows unit lanes <details> <summary>🔍 Technical details</summary> **`test_redaction_stays_fast_on_dense_escapes`** (Linux, 2.01 to 2.03 s against a 2 s limit) - Cause: an absolute 2 s bound. Locally the worst text takes 0.19 s. On a 4-worker, coverage-traced runner it took about 10x that. - Fix: time one 1M-char text against eight 125K texts with the same total length, on the same machine. Linear code scores about 1.0 and a quadratic scan scores 8, so the test asserts < 3. It takes the best of up to three paired runs, and uses the lower of the wall-clock and CPU (`thread_time`) ratios. Contention inflates wall time, and Windows samples CPU time on ticks. The test also fails if the 1M text takes more than 15 s of CPU, which catches a per-position rescan: that is linear but takes minutes. - Break checks: a quadratic prefix copy in `_candidate_windows` (`len(text[:start].rstrip("\\"))`) gives a ratio of 5.9x and the test fails. Main's 2 s test passed that same regression locally (1.57 s). A per-anchor rescan without merging takes 56 s and hits the 15 s ceiling. **`test_children_of_an_exited_server_are_still_stopped`** (Linux) - Cause: the test slept a fixed 2 s for the child watcher. The watcher backs off (0.5, 1, 2, 4 s…), so on a slow start its next scan came after the launcher had exited and the child was never recorded. - Fix: poll until `child_pid in transport._children`, with a deadline of 3 × `_CHILD_SCAN_MAX_S`. - Break checks: never recording children fails with "never recorded". Clearing `_children` before stopping fails with "kept running". Delaying the watcher's first scan by 2.5 s reproduces the CI failure on main's test, and the new test passes. - Note for the product side: a launcher that spawns a child and exits inside a backoff window still orphans that child. Real `npx`/`uvx` launchers outlive the window. **`test_the_next_waiter_takes_the_lock_within_milliseconds`** (macOS, median 6.5 to 8.1 ms against 5 ms) - Cause: macOS stretches `sleep(0.001)` under load, and the 5 ms median left no headroom. - Fix: the test wraps `_poll_interval`, which records each interval and signals the moment the waiter starts a poll's sleep. The lock is released right then, so the whole interval stands between the waiter and the lock. - Assertions: every interval the front waiter asks for is ≤ 2 ms, and the median hand-off is < 15 ms. A 20 ms poll always waits at least 20 ms, so it fails the median even with the bound widened. - Break checks: `_NEXT_POLL_SECONDS = 0.02` or `0.1` fails the interval assertion. Sleeping `_POLL_SECONDS` directly, so `_poll_interval` is bypassed, fails the median (20.8 ms). **`test_a_dropped_idle_connection_is_logged[True]`** (Linux) - Cause: the test asserted that `"Traceback"` was absent from the stderr captured by `capsys`. The traceback in that run came from a fake Lemonade server that `test_lemonade_shared_server.py` left running on the same xdist worker (`BrokenPipeError`). - Fix: the `serve` fixture records the bridge server's own `handle_error` calls, and the test asserts that list is empty. socketserver calls `handle_error` before it closes the connection, so the check doesn't race. A plugin that writes a traceback to stderr during the test fails main's version and passes the new one. - Break check: making `log_error` also call the base `log_error`, and reverting `str(args[0])`, raises `TypeError` in the handler, and the test fails. **Isolation fixes** - `test_folder_indexing.py`: `temp_folder` now lives in `isolated_gaia_home`, a per-test fake home, so `ensure_within_home` still admits it. Parallel workers no longer share or delete `~/.gaia/test_temp`. - `test_issue_841…`: the test now sets `GAIA_HOME` itself, so an inherited value can't override the patched `Path.home`. - `tests/electron/setup.js`: `os.homedir()` points at a per-file temp dir. It is assigned rather than spied, so `jest.restoreAllMocks()` can't undo it. Setting `HOME` would not work, because Jest's sandboxed `process.env` never reaches `os.homedir()`. - The "Ignoring invalid agents section in …\.gaia\tray-config.json" log came from `crash-loop-notification.test.cjs`, which mocks `fs` with a config the validator rejects. The real file was never read, but the path now names the temp home. </details>
…-folders Main shipped contract 2.19 for changes_turn_id (amd#5553), so surface moves to contract 2.20: the server, relay floor, npm API_VERSION, OpenAPI artifact, bundled docs and tests now say 2.20, and the relay sends both fields to a sidecar that takes them.
|
Merged main. Main already used contract 2.19 for file-change undo (#5553), so 🔍 Technical details
|
|
Heads-up: this PR and #5649 both add a |
# Conflicts: # hub/agents/gaia/npm/CHANGELOG.md # hub/agents/gaia/npm/README.md
Head branch was pushed to by a user without write access
|
Merged current main in; two doc conflicts, both kept additively, and the tests pass.
Tests: |
# Conflicts: # src/gaia/ui/_chat_helpers.py
# Conflicts: # hub/agents/chat/python/gaia_agent_chat/agent.py
…t errors (amd#5649) A headless caller of the `/v1/gaia/*` service whose model server went down got "Cloud request through Lemonade failed … check the TUI provider settings". That was wrong on three counts: the model was local, no Lemonade was involved, and there was no TUI (amd#5295). The investigation went toward cloud credentials instead of a LAN host that couldn't be reached. Now a failed model request names the server that failed (host:port, credentials stripped), and says "through Lemonade" only when it was. `/query` takes an optional `surface` field, so the advice fits the caller: headless callers are pointed at the server's base URL, while the TUI and the Agent UI keep their own wording. The first half of amd#5295, failed runs ending as normal answers, was already fixed by amd#5432. Closes amd#5295 - Contract 2.20: `surface` is the same optional field amd#5564 added (`agent_ui`, `tui`, `cli`); leaving it out now means a headless caller for error wording. The TUI and the Agent UI relay send it only to a 2.20+ sidecar. A front-end older than this release gets the headless wording; the CHANGELOG notes this skew. - Exception classes and classifier anchor strings are unchanged, so error classification is the same. One eval-sensitive string is left as is: "Couldn't reach the local LLM". Watch `error_recovery` on the next RC; only the failure-answer wording changed. - Memory's startup notice also names a user-set model server instead of "the Lemonade embedding service". ## Test plan - [x] Real repro of the report: the flagship's headless service pointed at a local stub that returns 502 for everything, model `gpt-oss-20b`, POST `/v1/gaia/query` with no `surface`. The `final` event has `failed: true`, names `127.0.0.1:<port>` once, and doesn't mention the TUI. - [x] Fake-server tests for a local endpoint returning 502, streaming and non-streaming: the host is named, and the backend's JSON error body still parses - [x] TUI (Go) sends `surface: "tui"` only to a gaia sidecar at 2.20+; the Agent UI relay does the same - [x] Affected suites: 921 pass; `util/lint.py --all` passes; OpenAPI artifact `--check` is current --------- Co-authored-by: Kalin Ovtcharov <[email protected]>
…5844) Asked to save a file "in my Documents folder", GAIA wrote it into `~/.gaia/documents`, its own hidden folder, every time, so the user would never find it. Now it saves to the user's `~/Documents`. Finding an existing file "in my documents folder" still checks GAIA's folder first, which is what #5564 fixed. Refs #5843. It stays open until #5885 lands: on a Windows PC with Documents moved to OneDrive, or Linux with a translated Documents folder, this still names a folder the user won't find. **LLM-affecting** (system prompt). No eval hardware here; watch `tool_selection`, `gaia_tool_selection` and `error_recovery` on the next RC. ## Test plan - [x] Live, from source, same model as the report (DeepSeek V4.1 Flash via Lemonade → Fireworks), Agent UI folder scope, every write denied: - "save … shopping.txt in my Documents folder": `main` targets `~/.gaia/documents/shopping.txt` 3/3; this branch targets `~/Documents/shopping.txt` 3/3, in one call - "summarize vendor_contract.md in my documents folder" (file seeded in GAIA's folder): both read it from GAIA's folder on every run, never touching `~/Documents`; 2.6 vs 3.2 calls on average over 5 runs, within run-to-run noise - [x] `tests/unit/chat/test_session_prompt_context.py`: 11 passed; the new test fails on `main` - [x] Prompt, budget and profile-spec tests in `tests/unit/chat` and the chat and gaia hub suites: no new failures against `main` - [ ] Next RC eval: the three categories above No before/after screenshot: the change is one sentence of system prompt, and what it changes is which path the model picks. The live runs above, from source with the same model and the Agent UI's folder scope, measure that directly. The before state, an approval prompt naming `~/.gaia/documents/shopping.txt`, is in #5843. <details> <summary>🔍 Technical details</summary> The extra sentence is added only when GAIA's documents folder is in scope, since that's the only time the two folders can be confused. I tried two other wordings: one that didn't name the path, and one that rephrased the "look here first" sentence. The first sent a denied write back into GAIA's folder on a retry. The second made reads search first. This one kept both cases right. </details> --------- Co-authored-by: Kalin Ovtcharov <[email protected]>
Before: asked to "summarize vendor_contract.md in my documents folder" (or "delete notes.txt in your documents folder"), the flagship took 8–11 tool calls. It tried
~/Documents, was refused the home folder, and only then found GAIA's own documents folder, which it could read all along. Asked to set up a recurring task in the Agent UI, it said it had no scheduler and sent the user to Windows Task Scheduler. After: GAIA looks in its own folders first, and in the Agent UI it points recurring requests at Scheduled tasks and helps word a valid schedule.LLM-affecting. No eval hardware here. Watch these on the next RC:
rag_quality,tool_selection,error_recovery,gaia_tool_selection.Test plan
pytest tests/unit/chat tests/unit/agents hub/agents/chat/python/tests hub/agents/gaia/python/tests -n 4: 7119 passed. The 3 failures need Playwright, which isn't installed here, and fail the same way onmain.main(1 budget case plus 15 rows intest_profilespec_characterization.py). This PR adds no new failures.python util/lint.py --black --isort~/.gaia/documentson the first or second callEvidence: Agent UI vs TUI session, no model
The real sidecar ran under uvicorn on a loopback port and built the real
GaiaAgentfor each session. Onlyprocess_querywas replaced, so each turn reports the folders and scheduler lines from the agent's own system prompt. The Agent UI turn went through the UI's real relay (_dispatch_sidecar_query→relay_query→SidecarProxy) over HTTP, using the scope the UI computes for a chat with nothing attached. The TUI turn sent the bodytui/internal/client/sse.gosends, which has nosurfaceand noallowed_paths. Home andGAIA_HOMEpointed at a temp folder.(Captured before main took 2.19 for #5553; this branch now reports
2.20.)The TUI session gets the default scope, which is the home folder, so its line names that folder and has no scheduler line.
🔍 Technical details
Folders line.
ChatAgent._get_system_promptappends it on every profile exceptchat/fast (early_return). It lists the session'sallowed_pathsthat are folders and exist, deduplicated, with GAIA's documents folder first and labelled. It is computed once per agent, so a folder created mid-session doesn't change the cached prefix. Attached files are left out because the indexed-documents line already names them.Its size is about 130 characters plus the paths, so around 180–240 characters (~60–75 tokens) in a typical UI session.
Scheduler line. This is 298 characters (~72 tokens) and appears only when
config.surface == "agent_ui":Host signal. Nothing told the agent which front-end it serves.
ui_session_iddoesn't work for this because the TUI sendssession_idtoo. This PR addsChatAgentConfig.surface:_session_agent_kwargs, which also covers warm-up) and autonomous ticks set it to"agent_ui"./query's newsurfacefield ("agent_ui" | "tui" | "cli"). That makes the contract 2.20 (2.19 went tochanges_turn_idin fix(ui): show a relayed agent's file changes in Outputs, Changes and Undo #5553), gated bymin_surface_api_version, so older sidecars never get a field they would 422.openapi.gaia.json,lifecycle.tsAPI_VERSION, SPEC, SKILL, README, CHANGELOG anddocs/guides/gaia.mdxare updated together.